We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a8082f1 commit a1325bcCopy full SHA for a1325bc
backtesting/test/_test.py
@@ -304,7 +304,7 @@ def almost_equal(a, b):
304
self.assertSequenceEqual(
305
sorted(stats['_trades'].columns),
306
sorted(['Size', 'EntryBar', 'ExitBar', 'EntryPrice', 'ExitPrice',
307
- 'PnL', 'ReturnPct', 'EntryTime', 'ExitTime', 'Duration']))
+ 'PnL', 'ReturnPct', 'EntryTime', 'ExitTime', 'Duration', 'Tag']))
308
309
def test_compute_stats_bordercase(self):
310
@@ -506,6 +506,18 @@ def coroutine(self):
506
stats = self._Backtest(coroutine).run()
507
self.assertEqual(len(stats._trades), 1)
508
509
+ def test_order_tag(self):
510
+ def coroutine(self):
511
+ yield self.buy(size=2, tag=1)
512
+ yield self.sell(size=1, tag='s')
513
+ yield self.sell(size=1)
514
+
515
+ yield self.buy(tag=2)
516
+ yield self.position.close()
517
518
+ stats = self._Backtest(coroutine).run()
519
+ self.assertEqual(list(stats._trades.Tag), [1, 1, 2])
520
521
522
class TestOptimize(TestCase):
523
def test_optimize(self):
0 commit comments