forked from robcarver17/pysystemtrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiple_and_adjusted_from_csv_to_arctic.py
56 lines (44 loc) · 2.03 KB
/
multiple_and_adjusted_from_csv_to_arctic.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from syscore.constants import arg_not_supplied
from sysdata.csv.csv_multiple_prices import csvFuturesMultiplePricesData
from sysdata.csv.csv_adjusted_prices import csvFuturesAdjustedPricesData
from sysproduction.data.prices import diagPrices
diag_prices = diagPrices()
def init_arctic_with_csv_futures_contract_prices(
multiple_price_datapath=arg_not_supplied, adj_price_datapath=arg_not_supplied
):
csv_multiple_prices = csvFuturesMultiplePricesData(multiple_price_datapath)
csv_adj_prices = csvFuturesAdjustedPricesData(adj_price_datapath)
input(
"WARNING THIS WILL ERASE ANY EXISTING ARCTIC PRICES WITH DATA FROM %s,%s ARE YOU SURE?! CTRL-C TO ABORT"
% (csv_adj_prices.datapath, csv_multiple_prices.datapath)
)
instrument_codes = csv_multiple_prices.get_list_of_instruments()
for instrument_code in instrument_codes:
init_arctic_with_csv_prices_for_code(
instrument_code,
multiple_price_datapath=multiple_price_datapath,
adj_price_datapath=adj_price_datapath,
)
def init_arctic_with_csv_prices_for_code(
instrument_code: str,
multiple_price_datapath=arg_not_supplied,
adj_price_datapath=arg_not_supplied,
):
print(instrument_code)
csv_mult_data = csvFuturesMultiplePricesData(multiple_price_datapath)
db_mult_data = diagPrices.db_futures_multiple_prices_data
mult_prices = csv_mult_data.get_multiple_prices(instrument_code)
db_mult_data.add_multiple_prices(
instrument_code, mult_prices, ignore_duplication=True
)
csv_adj_data = csvFuturesAdjustedPricesData(adj_price_datapath)
db_adj_data = diagPrices.db_futures_adjusted_prices_data
adj_prices = csv_adj_data.get_adjusted_prices(instrument_code)
db_adj_data.add_adjusted_prices(
instrument_code, adj_prices, ignore_duplication=True
)
if __name__ == "__main__":
## modify datapaths if required
init_arctic_with_csv_futures_contract_prices(
adj_price_datapath=arg_not_supplied, multiple_price_datapath=arg_not_supplied
)