ENH: Adds a new api_method called get_environment so that users may

check if their algorithm is running in zipline or on Quantopian.
This commit is contained in:
llllllllll
2014-08-07 16:23:21 -04:00
parent 4420e370ff
commit 7563124547
3 changed files with 26 additions and 0 deletions
+8
View File
@@ -53,6 +53,7 @@ from zipline.test_algorithms import (
SetMaxOrderCountAlgorithm,
SetMaxOrderSizeAlgorithm,
api_algo,
api_get_environment_algo,
api_symbol_algo,
call_all_order_methods,
call_order_in_init,
@@ -407,6 +408,13 @@ class TestAlgoScript(TestCase):
algo = TradingAlgorithm(script=api_algo)
algo.run(self.df)
def test_api_get_environment(self):
environment = 'zipline'
algo = TradingAlgorithm(script=api_get_environment_algo,
environment=environment)
algo.run(self.df)
self.assertEqual(algo.environment, environment)
def test_api_symbol(self):
algo = TradingAlgorithm(script=api_symbol_algo)
algo.run(self.df)