There was an error while loading. Please reload this page.
1 parent b0f55cf commit acd8c55Copy full SHA for acd8c55
1 file changed
backtesting/test/_test.py
@@ -231,6 +231,19 @@ def test_broker_params(self):
231
cash=1000, spread=.01, margin=.1, trade_on_close=True)
232
bt.run()
233
234
+ def test_absolute_size_order_warns_on_insufficient_margin(self):
235
+ class S(Strategy):
236
+ def init(self):
237
+ pass
238
+
239
+ def next(self):
240
+ self.buy(size=10_000)
241
242
+ bt = Backtest(GOOG.iloc[:3], S, cash=1000)
243
+ with self.assertWarnsRegex(UserWarning, 'insufficient margin'):
244
+ stats = bt.run()
245
+ self.assertEqual(stats['# Trades'], 0)
246
247
def test_spread_commission(self):
248
class S(Strategy):
249
def init(self):
0 commit comments