def spotfx_from_csv_and_investing_dot_com(datapath, ADD_TO_ARCTIC=True, ADD_TO_CSV=True, ADD_EXTRA_DATA=True): # You can adapt this for different providers by changing these parameters if ADD_EXTRA_DATA: investingDotCom_csv_fx_prices = csvFxPricesData( datapath=datapath, config=investing_dot_com_config) if ADD_TO_ARCTIC: arctic_fx_prices = arcticFxPricesData() my_csv_fx_prices_data = csvFxPricesData() list_of_ccy_codes = my_csv_fx_prices_data.get_list_of_fxcodes() for currency_code in list_of_ccy_codes: print(currency_code) fx_prices_my_csv = my_csv_fx_prices_data.get_fx_prices(currency_code) fx_prices = investingDotCom_csv_fx_prices.get_fx_prices(currency_code) if ADD_EXTRA_DATA: fx_prices_investingDotCom = investingDotCom_csv_fx_prices.get_fx_prices( currency_code) print("%d rows for my csv files, %d rows for investing.com" % (len(fx_prices_my_csv), len(fx_prices_investingDotCom))) # Merge; last_date_in_my_csv = fx_prices_my_csv.index[-1] fx_prices_investingDotCom = fx_prices_investingDotCom[ last_date_in_my_csv:] fx_prices = pd.concat( [fx_prices_my_csv, fx_prices_investingDotCom]) fx_prices = fx_prices.loc[~fx_prices.index.duplicated( keep="first")] else: fx_prices = fx_prices_my_csv print("%d rows to write for %s" % (len(fx_prices), currency_code)) if ADD_TO_CSV: my_csv_fx_prices_data.add_fx_prices(currency_code, fx_prices, ignore_duplication=True) if ADD_TO_ARCTIC: arctic_fx_prices.add_fx_prices(currency_code, fx_prices, ignore_duplication=True)
def _get_fx_data_object(self): pathname = self._resolve_path("spot_fx_data") csv_fx_prices_data = csvFxPricesData(pathname) csv_fx_prices_data.log = self.log return csv_fx_prices_data
from sysdata.arctic.arctic_spotfx_prices import arcticFxPricesData from sysdata.csv.csv_spot_fx import csvFxPricesData import pandas as pd ADD_TO_ARCTIC = True ADD_TO_CSV = True # You may need to change this! # There must be ONLY fx prices here, with filenames "GBPUSD.csv" etc INVESTING_DATA_PATH = "data.other_sources.investing_dot_com.spotfx" if __name__ == '__main__': # You can adapt this for different providers by changing these parameters investingDotCom_csv_fx_prices = csvFxPricesData( datapath=INVESTING_DATA_PATH, price_column="Price", date_column="Date", date_format="%b %d, %Y") if ADD_TO_ARCTIC: arctic_fx_prices = arcticFxPricesData() my_csv_fx_prices = csvFxPricesData() list_of_ccy_codes = investingDotCom_csv_fx_prices.get_list_of_fxcodes() for currency_code in list_of_ccy_codes: print(currency_code) fx_prices_investingDotCom = investingDotCom_csv_fx_prices.get_fx_prices( currency_code) fx_prices_my_csv = my_csv_fx_prices.get_fx_prices(currency_code)
def _get_fx_data_object(self): pathname = self._resolve_path("spot_fx_data") csv_fx_prices_data = csvFxPricesData(pathname) csv_fx_prices_data.log = self.log return csv_fx_prices_data
""" Get FX prices from arctic and write to csv WARNING WILL OVERWRITE EXISTING! """ from sysdata.arctic.arctic_spotfx_prices import arcticFxPricesData from sysdata.csv.csv_spot_fx import csvFxPricesData if __name__ == "__main__": arctic_fx_prices = arcticFxPricesData() csv_fx_prices = csvFxPricesData() list_of_ccy_codes = csv_fx_prices.get_list_of_fxcodes() for currency_code in list_of_ccy_codes: fx_prices = arctic_fx_prices.get_fx_prices(currency_code) print(fx_prices) csv_fx_prices.add_fx_prices(currency_code, fx_prices, ignore_duplication=True)
""" Get FX prices from Quandl and write to Arctic """ from sysdata.quandl.quandl_spotfx_prices import quandlFxPricesData from sysdata.arctic.arctic_spotfx_prices import arcticFxPricesData from sysdata.csv.csv_spot_fx import csvFxPricesData # could get these from stdin ADD_TO_ARCTIC = True ADD_TO_CSV = False if __name__ == '__main__': quandl_fx_prices = quandlFxPricesData() arctic_fx_prices = arcticFxPricesData() csv_fx_prices = csvFxPricesData() list_of_ccy_codes = quandl_fx_prices.get_list_of_fxcodes() for currency_code in list_of_ccy_codes: fx_prices = quandl_fx_prices.get_fx_prices(currency_code) print(fx_prices) if ADD_TO_CSV: csv_fx_prices.add_fx_prices(currency_code, fx_prices) if ADD_TO_ARCTIC: arctic_fx_prices.add_fx_prices(currency_code, fx_prices)