mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-15 11:22:18 +08:00
restricted list trading control added.
This commit is contained in:
@@ -55,6 +55,7 @@ from zipline.test_algorithms import (
|
||||
SetMaxPositionSizeAlgorithm,
|
||||
SetMaxOrderCountAlgorithm,
|
||||
SetMaxOrderSizeAlgorithm,
|
||||
SetDoNotOrderListAlgorithm,
|
||||
api_algo,
|
||||
api_get_environment_algo,
|
||||
api_symbol_algo,
|
||||
@@ -955,6 +956,27 @@ class TestTradingControls(TestCase):
|
||||
algo = SetMaxPositionSizeAlgorithm(max_shares=10, max_notional=61.0)
|
||||
self.check_algo_fails(algo, handle_data, 0)
|
||||
|
||||
def test_set_do_not_order_list(self):
|
||||
# set the restricted list to be the sid, and fail.
|
||||
algo = SetDoNotOrderListAlgorithm(sid=self.sid,
|
||||
restricted_list=[self.sid])
|
||||
|
||||
def handle_data(algo, data):
|
||||
algo.order(self.sid, 100)
|
||||
algo.order_count += 1
|
||||
|
||||
self.check_algo_fails(algo, handle_data, 0)
|
||||
|
||||
# set the restricted list to exclude the sid, and succeed
|
||||
algo = SetDoNotOrderListAlgorithm(sid=self.sid,
|
||||
restricted_list=[134, 135, 136])
|
||||
|
||||
def handle_data(algo, data):
|
||||
algo.order(self.sid, 100)
|
||||
algo.order_count += 1
|
||||
|
||||
self.check_algo_succeeds(algo, handle_data)
|
||||
|
||||
def test_set_max_order_size(self):
|
||||
|
||||
# Buy one share.
|
||||
|
||||
Reference in New Issue
Block a user