mirror of
https://github.com/wassname/catalyst.git
synced 2026-09-10 11:50:32 +08:00
TST: adds future flip test
This commit is contained in:
@@ -442,6 +442,16 @@ class TestTargetValueAlgorithm(TradingAlgorithm):
|
||||
20 / (data[0].price * self.sid(0).contract_multiplier))
|
||||
|
||||
|
||||
class FutureFlipAlgo(TestAlgorithm):
|
||||
def handle_data(self, data):
|
||||
if len(self.portfolio.positions) > 0:
|
||||
if self.portfolio.positions[self.asset.sid]["amount"] > 0:
|
||||
self.order_target(self.asset, -self.amount)
|
||||
else:
|
||||
self.order_target(self.asset, 0)
|
||||
else:
|
||||
self.order_target(self.asset, self.amount)
|
||||
|
||||
############################
|
||||
# AccountControl Test Algos#
|
||||
############################
|
||||
|
||||
Reference in New Issue
Block a user