mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-11 00:49:36 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user