mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-05 12:50:21 +08:00
add account object to context
This commit is contained in:
@@ -34,6 +34,7 @@ from zipline.errors import (
|
||||
TradingControlViolation,
|
||||
)
|
||||
from zipline.test_algorithms import (
|
||||
access_account_in_init,
|
||||
access_portfolio_in_init,
|
||||
AmbitiousStopLimitAlgorithm,
|
||||
EmptyPositionsAlgorithm,
|
||||
@@ -687,6 +688,24 @@ def handle_data(context, data):
|
||||
|
||||
output, _ = drain_zipline(self, zipline)
|
||||
|
||||
def test_account_in_init(self):
|
||||
"""
|
||||
Test that accessing account in init doesn't break.
|
||||
"""
|
||||
test_algo = TradingAlgorithm(
|
||||
script=access_account_in_init,
|
||||
sim_params=self.sim_params,
|
||||
)
|
||||
set_algo_instance(test_algo)
|
||||
|
||||
self.zipline_test_config['algorithm'] = test_algo
|
||||
self.zipline_test_config['trade_count'] = 1
|
||||
|
||||
zipline = simfactory.create_test_zipline(
|
||||
**self.zipline_test_config)
|
||||
|
||||
output, _ = drain_zipline(self, zipline)
|
||||
|
||||
|
||||
class TestHistory(TestCase):
|
||||
def test_history(self):
|
||||
|
||||
Reference in New Issue
Block a user