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:
Scott Sanderson
2014-04-21 16:34:59 -04:00
parent 6412742799
commit 574415f434
3 changed files with 69 additions and 1 deletions
+11 -1
View File
@@ -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):