# Trading-bot capital: transparent sizing and cost arithmetic

These files accompany TensorParadigm's article on the capital required to operate a trading bot. They calculate deterministic examples from explicitly assumed inputs. They do not test a strategy, fetch market data, estimate an edge, predict income, optimize an allocation, or place orders.

Every fee, adverse execution allowance, price, quantity increment, minimum notional, monthly cost, trade count and return in `protocol.json` is invented for the exercise. None is a current exchange rule, broker fee or hosting quote. The assumptions were saved before calculating the reported results; this is not an independently registered empirical study.

## Quick start

Save `capital_calculator.py`, `test_capital_calculator.py` and `protocol.json` together in one folder. Use Python 3.10 or newer:

```sh
python capital_calculator.py
python -m unittest -v
```

On systems that call Python `python3`, use that command name instead. No extra packages, network connection, credentials, market-data files, installer or ZIP are needed. The calculator writes a `results` folder. The ten tests check exact arithmetic, rounding and input definitions; they do not establish trading-system performance.

Optional file locations:

```sh
python capital_calculator.py --protocol protocol.json --output-dir results
```

## File contents

- `protocol.json`: complete assumptions, formulas, definitions and exclusions.
- `capital_calculator.py`: Python standard-library calculations. Decimal arithmetic handles quantity increments and boundary conditions before final JSON serialization.
- `test_capital_calculator.py`: ten analytical, budget, rounding and output-reconciliation tests.
- `results/results.json`: all calculated examples and the SHA-256 fingerprint of the protocol used. JSON numbers are serialized as ordinary numeric values; calculations use Decimal internally.
- `results/position-sizing.csv`: four equity levels, rounded quantities, funded entry costs, planned risk and a separate assumed exit-minimum diagnostic.
- `results/break-even.csv`: 28 labeled scenarios covering account size, three fixed-cost tiers, four gross-return assumptions and four friction assumptions. Blank fields mean a field does not apply to that scenario. A blank break-even equity is accompanied by an explanatory status; it is not a zero-dollar capital recommendation.
- `results/consecutive-losses.csv`: exact fixed-fraction and fixed-dollar loss arithmetic for three assumed sequence lengths.
- `LICENSE`: MIT license for the code and constructed inputs.

## Position-sizing example

Assume unleveraged long spot exposure, reference price 50 USD, quantity increment 0.01 units, minimum reference notional 10 USD, planned account risk fraction 0.5%, and stop distance 2%. Entry and exit fees are each 0.1% of their respective execution values. Adverse execution allowances are each 0.05%.

The conservative linear planning allowance is 0.3% of reference notional for the round trip: two 0.1% fees plus two 0.05% execution allowances. Planned gap-free loss is reference notional times 2.3%. This is a planning approximation, not a guaranteed stop loss. The exact gap-free diagnostic uses a stop reference at the original price times `(1 - 0.02)`, applies the adverse sell allowance, and charges the exit fee on that value. The fee is paid in quote units, so it does not reduce the available asset quantity. Stops measured from a different reference, asset-denominated fees or actual gaps require different accounting.

Reserve entry cash as reference notional times `(1 + 0.0005) * (1 + 0.001)`. Compute risk-budget notional and cash-affordable notional, take the lesser, then round quantity down to its permitted increment. Never round up to meet a minimum if doing so breaks a budget. A result marked `EXECUTE_IN_MODEL` only passes these stated arithmetic checks; it is not an order instruction or a claim about a real venue.

The 46 USD entry-feasibility boundary follows from a 10 USD executable reference notional times 2.3%, divided by a 0.5% account risk budget. The funded-entry cash requirement is checked separately; the risk requirement dominates here. At 45.99 USD, rounding down leaves a below-minimum candidate, so the example skips it.

Entry feasibility is not exit feasibility. If the same 10 USD minimum also applies to the full-quantity stopped sell, an initial 0.20 units has assumed stopped-exit notional 9.7951 USD and fails that additional minimum. The next quantity increment, 0.21 units, requires 48.30 USD of equity under this risk budget and has stopped-exit notional 10.284855 USD. This added diagnostic is separate from the entry checker. It is not complete lifecycle validation for actual stop, reduce-only, market or dust-handling rules, and no gap-free execution is guaranteed.

Changing the assumed price to 51 USD and quantity increment to 0.03 units raises the smallest entry notional to 10.71 USD and the entry-feasibility equity to 49.266 USD. The quantity increment is an asset quantity step, not a price tick.

## Independent linear monthly cost model

The monthly example assumes 25% of fixed reference equity is deployed per round trip, 20 round trips per month, 0.4% gross return on deployed reference notional per round trip, 0.3% round-trip variable friction and 15 USD fixed monthly cost:

```text
monthly_net = 20 * 0.25 * equity * (0.004 - 0.003) - 15
            = 0.005 * equity - 15
```

The algebraic break-even equity is 3,000 USD. This is conditional on the assumed positive surplus. No positive capital covers a positive fixed cost when the gross-return assumption is less than or equal to variable friction. A larger account cannot repair a nonpositive per-dollar surplus in this model.

The 25% deployment assumption is independent of the sizing example, whose rounded position uses approximately 21.5%–21.735% of equity. Do not substitute one result for the other. The monthly model holds reference equity fixed, assumes no overlapping positions or capacity changes, and does not compound returns or generate an execution ledger.

The fixed-cost tiers 0/15/50 USD are hypothetical budgets. A zero tier means zero incremental fixed cost in the model, not a claim that hardware, labor, software or connectivity are free. Friction sensitivity uses 0.1%/0.3%/0.6%/1.0% per round trip to avoid presenting one cost assumption as universal.

## Income and consecutive-loss arithmetic

The income illustration asks what equity satisfies `(equity * assumed monthly return) - 15 = 1000`, before tax. Its hypothetical 0.5%/1%/2% monthly account returns are after variable trading costs and before fixed costs. Results of 203,000/101,500/50,750 USD are conditional arithmetic, not feasible or sustainable return targets, capital recommendations, probabilities or income forecasts. Negative months, withdrawals and their ordering, changing capital, taxes and capacity are not modeled.

The loss illustration assumes every loss event removes exactly 0.5% of then-current account equity. After `n` events, equity is `starting_equity * 0.995**n`. The comparison instead removes a fixed 50 USD after each event from the same starting 10,000 USD. Recovery is `starting_equity / remaining_equity - 1`; it is not equal to drawdown. There is no assigned probability of any sequence, and minimum order constraints, fixed monthly costs and actual stop execution are excluded from this isolated calculation.

The published files contain only code, assumed inputs and calculated outputs. There are no personal account records, credentials, market-data downloads or embedded machine-specific paths. The program uses its own file location to find the accompanying protocol; it does not inspect private directories.

Copyright (c) 2026 TensorParadigm. Code and constructed inputs are available under the MIT license.
