Run settings
A script says what to trade and when. Everything else a run needs, its period, account, costs and limits, is a run setting. Run settings belong to the project, so every script in it runs under the same terms and their results compare like-for-like.
In the app they are in the Run Settings inspector (⌥⌘1), under the script's params. The less common ones are under Advanced. Each run keeps the settings it ran with, and Run Info (⌥⌘2) shows them, marking any that differ from the project's now.
Where they are stored
The project folder's rearview-project.json holds them under "run". On the command line, the same object goes in a file passed with --config, as {"run": {...}}. A field left out takes its default, and a field the engine doesn't know is an error rather than ignored.
The file counts in whole numbers so that every run is exact:
- Money is in millionths of a dollar:
100000000000is $100,000, and5000is half a cent. - Rates and shares are in millionths:
10000is 1%,500000is 50%, and100is one basis point. - Dates are
"YYYY-MM-DD".
{"run": {
"initial_cash": 250000000000,
"account": {"type": "reg_t"},
"commission": {"per_share": 5000, "min": 1000000},
"slippage": 500,
"cash_rate": 30000
}}That is $250,000 in a Reg T account, a commission of half a cent a share with a $1 minimum, 5 basis points of slippage, and 3% a year on idle cash.
Period
| Setting | In the file | Default |
|---|---|---|
| Start, End | start, end | The data's first stock or ETF bar to its last day |
Full History resets both. A run never starts before a stock or ETF trades, even when an index has older bars; see When a run starts.
Deposits and withdrawals (transfers) move cash into or out of the account on given days, after that day's trading: "transfers": [{"date": "2026-11-05", "amount": 5000000000}] deposits $5,000, and a negative amount withdraws. Live accounts set them from your statement, so the backtest beside your account gets the same deposits; see Trading it live. There is no control for them in Run Settings. With transfers, a run's returns are time-weighted, so a deposit isn't counted as a gain. A withdrawal isn't refused for want of cash: one that takes a cash account below zero warns CASH_NEGATIVE, since what the account holds from then on is on borrowed cash, charged only at the margin rate (0% by default), and its figures may overstate.
Account
| Setting | In the file | Default |
|---|---|---|
| Initial cash | initial_cash | $100,000 |
| Currency | currency: "AUD" | US dollars ("USD") |
| Type | account: {"type": "cash"} or {"type": "reg_t"} | Cash |
| Cash interest | cash_rate | 0%/yr |
| Margin interest | margin_rate | 0%/yr |
| Share step | quantity: {"share_decimals": 4} | Whole shares (0) |
| Coin step | quantity: {"coin_decimals": 8} | 0.00000001 (8) |
- Currency: shown when the data has securities or pairs in other currencies than US dollars. Initial cash and every amount of the account (cash, equity, P&L, commissions, interest, fixed sizes and margin minimums) are in it; each security's prices stay in its own currency and convert at the data's forex rates, at the open's rate for fills at the open and the close's for marks (the language reference, "Currencies and forex pairs"). At US dollars the file leaves
currencyout. - Cash: a buy needs the cash for it and its commission. No borrowing, and no shorts.
Reg T: a margin account as US brokers run one.
- A new position needs equity to spare for its initial margin: 50% of its value by default, long or short.
- Short sale proceeds are held as collateral and never add buying power.
- Interest is charged on borrowed cash at the margin rate and earned on idle cash at the cash rate, by calendar day over a 360-day year.
The maintenance check: at each close, if equity falls below the maintenance requirement, whole positions are sold at the next open, the biggest unrealised loss first, until the shortfall is covered. The requirement is 25% of the value of each long. For a short, it is the larger of:
- at $5 or more a share, 30% of its value or $5 a share;
- below $5, 100% of its value or $2.50 a share.
These are FINRA Rule 4210's minimums; your broker may ask for more.
- Wiped out: if equity reaches zero, the run stops on that day and is marked wiped out.
- Share step: stocks and ETFs trade in whole shares unless you choose a finer step, as many brokers sell them: 0.1, 0.01, 0.001, 0.0001 or 0.000001 of a share (
share_decimals1 to 6). Sizes, rebalances and trims then come out to that step rather than down to whole shares, so a small account can hold its weights. Money from a fraction (a fill's value, a dividend, a commission per share) is rounded to a millionth of a dollar, half to even. Shorts stay in whole shares, as brokers require. - Futures: a cash account backs each futures contract with cash for its full value at the day's mark, so it never borrows, and a futures short is refused. A Reg T account holds futures on margin, long or short: 10% of their value to open and 9% to keep by default, with no short proceeds or borrow fee. Futures settle at every close, so their gains and losses move cash each day, and their value counts toward exposure, which can pass 100% on margin. Commission per share is charged per contract.
- Forex pairs are settled and backed as futures are: a cash account holds each pair's full value back from cash and refuses a short, and a Reg T account holds pairs on margin, long or short, 5% of their value to open and 4% to keep by default. Each day a pair is held it earns or pays carry from the data's interest rates.
- Coin step: shown when the data holds coins. Coins trade in steps of 0.00000001 unless you choose a coarser one (
coin_decimals0 to 8). They are long only, and a Reg T account buys them with cash: a coin's margin requirement is 100% of its value, and the overrides below don't apply to it.
Advanced ▸ Margin sets the initial margin for longs and shorts and the maintenance for longs. The short tiers and per-security overrides are set in the file:
"account": {"type": "reg_t",
"initial_long": 500000, "initial_short": 500000, "maint_long": 250000,
"maint_short_tiers": [
{"min_price": 5000000, "pct": 300000, "per_share": 5000000},
{"min_price": 0, "pct": 1000000, "per_share": 2500000}],
"overrides": {"12": {"long": 400000, "short": 1000000}}}Tiers are listed from the highest min_price down, and the first one the price reaches applies. An override is keyed by the security's id from your data, and sets its maintenance for longs, shorts or both.
Advanced ▸ Futures margin, shown when the data holds futures, sets futures' initial and maintenance margin as a share of their value. A chain's own rates are set in the file:
"account": {"type": "reg_t",
"futures": {"initial": 100000, "maint": 90000,
"overrides": {"41": {"initial": 150000, "maint": 120000}}}}Maintenance can't be above initial margin. At the defaults the file leaves futures out. The maintenance check counts futures with everything else, so a margin call can sell them first if their loss is the biggest.
Advanced ▸ Forex margin, shown when the data holds forex pairs, does the same for pairs, as "forex": {"initial": 50000, "maint": 40000, "overrides": {…}}. US brokers ask 2% for major pairs: set 20000 for both to model one.
Commission and slippage
| Setting | In the file | Default |
|---|---|---|
| Per share | commission.per_share | $0 |
| Per trade | commission.per_trade | $0 |
| Of trade value | commission.pct | 0% |
| Minimum | commission.min | $0 |
| Slippage | slippage | 0 bps |
- A fill's commission is the per-trade amount, plus the per-share amount times the shares, plus the percentage of its value, and at least the minimum.
- Slippage moves the price against you on market fills, stops, trailing stops and forced sales: buys pay more and sells get less. Limit orders, targets and delistings fill at their own price, with no slippage.
Benchmark
| Setting | In the file | Default |
|---|---|---|
| Benchmark | benchmark: the security's id | None |
Type a ticker and Rearview looks it up in the project's data. Results then show the benchmark's growth, deepest fall, beta and correlation over the same days, with its dividends reinvested. The sample project's benchmark is SYNSPY.
Shorts
| Setting | In the file | Default |
|---|---|---|
| Borrow cost | borrow: {"type": "flat", "rate": 30000}, or {"type": "series", "rate": "borrow_rate", "htb": "htb"} | Flat, 0%/yr |
| Short rebate | short_rebate | 0%/yr |
- A short pays a borrow fee every night on its value at the previous close: one flat rate for every stock, or From the data, each stock's own rate by date from a
borrow_rateseries. A negative rate in that series is refused, since it would pay a short for being open. With anhtbseries too, a stock whose latesthtbvalue before the day isn't 0 can't be newly shorted that day. See Your own data: series("name") for adding series. - A flat rate, even 0%, marks every short trade "borrow assumed", and the run notes it.
- A short pays the dividends the stock pays while it's held.
- The rebate is interest earned on the proceeds of short sales.
- The short-sale price test (Reg SHO Rule 201) isn't modelled.
Exposure limits
| Setting | In the file | Default |
|---|---|---|
| Long, Short, Gross, Net | exposure.long, .short, .gross, .net | No limit |
Each is a share of equity. When an entry would break a limit, it shrinks to fit at the fill, and an entry that shrinks to nothing doesn't happen.
Liquidity
| Setting | In the file | Default |
|---|---|---|
| Volume cap | volume_cap | None |
No order fills more than this share of the day's volume. The rest of an entry is cancelled; the rest of an exit is sold at the next open. With no cap, a fill larger than all its bar traded is still filled, and the run warns FILL_OVER_VOLUME: results at that size aren't reachable.
Delistings
| Setting | In the file | Default |
|---|---|---|
| NYSE/American | delisting.nyse_amex | 30% |
| Nasdaq | delisting.nasdaq | 55% |
| Other | delisting.other | 30% |
| Price them as a total loss | delisting.stress_total_loss | Off |
A position in a stock that delists is closed at its last close, less a haircut that depends on why it delisted:
| Reason in the data | Closed at |
|---|---|
ACQUISITION | the last close |
STOCK_MERGER, SPINOFF | the last close, with the trade flagged |
PERFORMANCE | the last close less the exchange's haircut |
OTHER, UNKNOWN | the same as PERFORMANCE, with a DELIST_ASSUMED warning |
- The defaults follow the academic convention for delisting returns: about −30% on NYSE and NYSE American and −55% on Nasdaq. NYSE Arca counts as NYSE; Cboe, OTC and other exchanges use Other.
- A short in a stock that delists is bought back at the same reduced price, so the haircut is its gain.
- Price them as a total loss sets every haircut to 100%: a stress test of how much the result depends on delisted stocks.
- A stock whose bars simply stop, with no delisting in the data, is never treated as delisted. It stays open at its last price, and the run warns.
Tick sizes
| Setting | In the file | Default |
|---|---|---|
| Tick at $1 and above | tick.standard | $0.01 |
| Tick below $1 | tick.sub_dollar | $0.0001 |
Tick sizes are set in the file only. A limit order fills at its price only if the day trades through it by at least one tick; one that opens better fills at the open.