mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-15 11:22:18 +08:00
MAINT: Adding tests for Blotter handling of limit and stop orders.
Adds a test algorithm that tries to buy with very high limit prices/very low stop prices and tries to sell with very low limit prices/very high stop prices.
This commit is contained in:
+11
-1
@@ -42,7 +42,8 @@ from zipline.test_algorithms import (TestRegisterTransformAlgorithm,
|
||||
api_symbol_algo,
|
||||
call_all_order_methods,
|
||||
record_variables,
|
||||
record_float_magic
|
||||
record_float_magic,
|
||||
AmbitiousStopLimitAlgorithm
|
||||
)
|
||||
|
||||
from zipline.utils.test_utils import drain_zipline, assert_single_position
|
||||
@@ -264,6 +265,15 @@ class TestPositions(TestCase):
|
||||
self.assertEqual(daily_stats.ix[i]['num_positions'],
|
||||
expected)
|
||||
|
||||
def test_noop_orders(self):
|
||||
|
||||
algo = AmbitiousStopLimitAlgorithm(sid=1)
|
||||
daily_stats = algo.run(self.source)
|
||||
|
||||
# Verify that possitions are empty for all dates.
|
||||
empty_positions = daily_stats.positions.map(lambda x: len(x) == 0)
|
||||
self.assertTrue(empty_positions.all())
|
||||
|
||||
|
||||
class TestAlgoScript(TestCase):
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user