mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-15 11:22:18 +08:00
Changes BcolzDailyBarWriter to not be an abc, data is passed as an iterator of (sid, dataframe) pairs to the write method. Changes the AssetsDBWriter to be a single class which accepts an engine at construction time and has a `write` method for writing dataframes for the various tables. We no longer support writing the various other data types, callers should coerce their data into a dataframe themselves. See zipline.assets.synthetic for some helpers to do this. Adds many new fixtures and updates some existing fixtures to use the new ones: WithDefaultDateBounds A fixture that provides the suite a START_DATE and END_DATE. This is meant to make it easy for other fixtures to synchronize their date ranges without depending on eachother in strange ways. For example, WithBcolzMinuteBarReader and WithBcolzDailyBarReader by default should both have data for the same dates, so they may use depend on WithDefaultDates without forcing a dependency between them. WithTmpDir, WithInstanceTmpDir Provides the suite or individual test case a temporary directory. WithBcolzDailyBarReader Provides the suite a BcolzDailyBarReader which reads from bcolz data written to a temporary directory. The data will be read from dataframes and then converted to bcolz files with BcolzDailyBarWriter.write WithBcolzDailyBarReaderFromCSVs Provides the suite a BcolzDailyBarReader which reads from bcolz data written to a temporary directory. The data will be read from a collection of CSV files and then converted into the bcolz data through BcolzDailyBarWriter.write_csvs WithBcolzMinuteBarReader Provides the suite a BcolzMinuteBarReader which reads from bcolz data written to a temporary directory. The data will be read from dataframes and then converted to bcolz files with BcolzMinuteBarWriter.write WithAdjustmentReader Provides the suite a SQLiteAdjustmentReader which reads from an in memory sqlite database. The data will be read from dataframes and then converted into sqlite with SQLiteAdjustmentWriter.write WithDataPortal Provides each test case a DataPortal object with data from temporary resources.
40 lines
965 B
Python
40 lines
965 B
Python
"""
|
|
Script for rebuilding the samples for the Quandl tests.
|
|
"""
|
|
from __future__ import print_function
|
|
|
|
import pandas as pd
|
|
import requests
|
|
|
|
|
|
from zipline.data.quandl import format_wiki_url
|
|
from zipline.utils.test_utils import test_resource_path, write_compressed
|
|
|
|
|
|
def zipfile_path(symbol):
|
|
return test_resource_path('quandl_samples', symbol + '.csv.gz')
|
|
|
|
|
|
def main():
|
|
start_date = pd.Timestamp('2014')
|
|
end_date = pd.Timestamp('2015')
|
|
symbols = ['AAPL', 'MSFT', 'BRK_A', 'ZEN']
|
|
for sym in symbols:
|
|
url = format_wiki_url(
|
|
api_key=None,
|
|
symbol=sym,
|
|
start_date=start_date,
|
|
end_date=end_date,
|
|
)
|
|
print("Fetching from %s" % url)
|
|
response = requests.get(url)
|
|
response.raise_for_status()
|
|
|
|
path = zipfile_path(sym)
|
|
print("Writing compressed data to %s" % path)
|
|
write_compressed(path, response.content)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|