forked from pst-group/pysystemtrade
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstruments_csv_mongo.py
More file actions
executable file
·26 lines (20 loc) · 999 Bytes
/
Copy pathinstruments_csv_mongo.py
File metadata and controls
executable file
·26 lines (20 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Populate a mongo DB collection with instrument data from a csv
"""
from sysdata.mongodb.mongo_futures_instruments import mongoFuturesInstrumentData
from sysdata.csv.csv_instrument_data import csvFuturesInstrumentData
INSTRUMENT_CONFIG_PATH = "data.futures.csvconfig"
data_out = mongoFuturesInstrumentData()
data_in = csvFuturesInstrumentData(datapath=INSTRUMENT_CONFIG_PATH)
print(data_in)
instrument_list = data_in.get_list_of_instruments()
if __name__ == "__main__":
input("Will overwrite existing data are you sure?! CTL-C to abort")
# modify flags as required
for instrument_code in instrument_list:
instrument_object = data_in.get_instrument_data(instrument_code)
data_out.delete_instrument_data(instrument_code, are_you_sure=True)
data_out.add_instrument_data(instrument_object)
# check
instrument_added = data_out.get_instrument_data(instrument_code)
print("Added %s to %s" % (instrument_added.instrument_code, data_out))