mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-16 11:18:05 +08:00
TST: Use testing market data with run_algorithm
so env doesn't need to download it
This commit is contained in:
+17
-10
@@ -88,6 +88,7 @@ from zipline.finance.asset_restrictions import (
|
||||
)
|
||||
from zipline.testing import (
|
||||
FakeDataPortal,
|
||||
copy_market_data,
|
||||
create_daily_df_for_asset,
|
||||
create_data_portal,
|
||||
create_data_portal_from_trade_history,
|
||||
@@ -99,6 +100,7 @@ from zipline.testing import (
|
||||
tmp_trading_env,
|
||||
to_utc,
|
||||
trades_by_sid_to_dfs,
|
||||
tmp_dir,
|
||||
)
|
||||
from zipline.testing import RecordBatchBlotter
|
||||
from zipline.testing.fixtures import (
|
||||
@@ -4760,13 +4762,18 @@ class TestPanelData(WithTradingEnvironment, ZiplineTestCase):
|
||||
check_panels()
|
||||
price_record.loc[:] = np.nan
|
||||
|
||||
run_algorithm(
|
||||
start=start_dt,
|
||||
end=end_dt,
|
||||
capital_base=1,
|
||||
initialize=initialize,
|
||||
handle_data=handle_data,
|
||||
data_frequency=data_frequency,
|
||||
data=panel
|
||||
)
|
||||
check_panels()
|
||||
with tmp_dir() as tmpdir:
|
||||
root = tmpdir.getpath('example_data/root')
|
||||
copy_market_data(self.MARKET_DATA_DIR, root)
|
||||
|
||||
run_algorithm(
|
||||
start=start_dt,
|
||||
end=end_dt,
|
||||
capital_base=1,
|
||||
initialize=initialize,
|
||||
handle_data=handle_data,
|
||||
data_frequency=data_frequency,
|
||||
data=panel,
|
||||
environ={'ZIPLINE_ROOT': root},
|
||||
)
|
||||
check_panels()
|
||||
|
||||
@@ -21,8 +21,9 @@ import pandas as pd
|
||||
|
||||
from zipline import examples
|
||||
from zipline.data.bundles import register, unregister
|
||||
from zipline.testing import test_resource_path
|
||||
from zipline.testing.fixtures import WithTmpDir, ZiplineTestCase
|
||||
from zipline.testing import test_resource_path, copy_market_data
|
||||
from zipline.testing.fixtures import WithTmpDir, ZiplineTestCase, \
|
||||
WithTradingEnvironment
|
||||
from zipline.testing.predicates import assert_equal
|
||||
from zipline.utils.cache import dataframe_cache
|
||||
|
||||
@@ -53,6 +54,9 @@ class ExamplesTests(WithTmpDir, ZiplineTestCase):
|
||||
serialization='pickle',
|
||||
)
|
||||
|
||||
copy_market_data(WithTradingEnvironment.MARKET_DATA_DIR,
|
||||
cls.tmpdir.getpath('example_data/root'))
|
||||
|
||||
@parameterized.expand(examples.EXAMPLE_MODULES)
|
||||
def test_example(self, example_name):
|
||||
actual_perf = examples.run_example(
|
||||
|
||||
Reference in New Issue
Block a user