You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>If <code>finalize_trades</code> is <code>True</code>, the trades that are still
133
133
<ahref="https://kernc.github.io/backtesting.py/doc/backtesting/backtesting.html#backtesting.backtesting.Strategy.trades">active and ongoing</a> at the end of the backtest will be closed on
134
134
the last bar and will contribute to the computed backtest statistics.</p></div>
<p>The passed data frame can contain additional columns that
269
+
can be used by the strategy (e.g. sentiment info).
270
+
DataFrame index can be either a datetime index (timestamps)
271
+
or a monotonic range index (i.e. a sequence of periods).</p>
272
+
<p><code>strategy</code> is a <code><atitle="backtesting.backtesting.Strategy" href="backtesting.html#backtesting.backtesting.Strategy">Strategy</a></code>
273
+
<em>subclass</em> (not an instance).</p>
274
+
<p><code>cash</code> is the initial cash to start with.</p>
275
+
<p><code>spread</code> is the the constant bid-ask spread rate (relative to the price).
276
+
E.g. set it to <code>0.0002</code> for commission-less forex
277
+
trading where the average spread is roughly 0.2β° of the asking price.</p>
278
+
<p><code>commission</code> is the commission rate. E.g. if your broker's commission
279
+
is 1% of order value, set commission to <code>0.01</code>.
280
+
The commission is applied twice: at trade entry and at trade exit.
281
+
Besides one single floating value, <code>commission</code> can also be a tuple of floating
282
+
values <code>(fixed, relative)</code>. E.g. set it to <code>(100, .01)</code>
283
+
if your broker charges minimum $100 + 1%.
284
+
Additionally, <code>commission</code> can be a callable
<p><code>margin</code> is the required margin (ratio) of a leveraged account.
304
+
No difference is made between initial and maintenance margins.
305
+
To run the backtest using e.g. 50:1 leverge that your broker allows,
306
+
set margin to <code>0.02</code> (1 / leverage).</p>
307
+
<p>If <code>trade_on_close</code> is <code>True</code>, market orders will be filled
308
+
with respect to the current bar's closing price instead of the
309
+
next bar's open.</p>
310
+
<p>If <code>hedging</code> is <code>True</code>, allow trades in both directions simultaneously.
311
+
If <code>False</code>, the opposite-facing orders first close existing trades in
312
+
a <ahref="https://www.investopedia.com/terms/n/nfa-compliance-rule-2-43b.asp">FIFO</a> manner.</p>
313
+
<p>If <code>exclusive_orders</code> is <code>True</code>, each new order auto-closes the previous
314
+
trade/position, making at most a single trade (long or short) in effect
315
+
at each time.</p>
316
+
<p>If <code>finalize_trades</code> is <code>True</code>, the trades that are still
317
+
<ahref="https://kernc.github.io/backtesting.py/doc/backtesting/backtesting.html#backtesting.backtesting.Strategy.trades">active and ongoing</a> at the end of the backtest will be closed on
318
+
the last bar and will contribute to the computed backtest statistics.</p></div>
0 commit comments