def get_and_check_prices_for_frequency(data, log, contract_object, frequency="D"): broker_data = dataBroker(data) price_data = diagPrices(data) price_updater = updatePrices(data) try: old_prices = price_data.get_prices_for_contract_object(contract_object) ib_prices = broker_data.get_prices_at_frequency_for_contract_object( contract_object, frequency) if len(ib_prices) == 0: raise Exception("No IB prices found for %s nothing to check" % str(contract_object)) print("\n\n Manually checking prices for %s \n\n" % str(contract_object)) new_prices_checked = manual_price_checker( old_prices, ib_prices, column_to_check='FINAL', delta_columns=['OPEN', 'HIGH', 'LOW'], type_new_data=futuresContractPrices) result = price_updater.update_prices_for_contract( contract_object, new_prices_checked, check_for_spike=False) return result except Exception as e: log.warn( "Exception %s when getting or checking data at frequency %s for %s" % (e, frequency, str(contract_object))) return failure
def update_historical_prices_with_checks_for_instrument_and_contract(contract_object, data, log=logger("")): """ Do a daily update for futures contract prices, using IB historical data :param contract_object: futuresContract :param data: data blob :param log: logger :return: None """ ib_prices = data.ib_futures_contract_price.get_prices_for_contract_object(contract_object) if len(ib_prices)==0: log.warn("No IB prices found for %s" % str(contract_object)) return failure old_prices = data.arctic_futures_contract_price.get_prices_for_contract_object(contract_object) print("\n\n Manually checking prices for %s \n\n" % str(contract_object)) new_prices_checked = manual_price_checker(old_prices, ib_prices, column_to_check = 'FINAL', delta_columns = ['OPEN','HIGH','LOW'], type_new_data = futuresContractPrices ) rows_added = data.arctic_futures_contract_price.update_prices_for_contract(contract_object, new_prices_checked, check_for_spike=False) return success
def get_and_check_prices_for_frequency(data: dataBlob, contract_object: futuresContract, frequency="D"): broker_data = dataBroker(data) price_data = diagPrices(data) price_updater = updatePrices(data) old_prices = price_data.get_prices_for_contract_object(contract_object) broker_prices = broker_data.get_prices_at_frequency_for_contract_object( contract_object, frequency) if len(broker_prices) == 0: print("No broker prices found for %s nothing to check" % str(contract_object)) return failure print("\n\n Manually checking prices for %s \n\n" % str(contract_object)) new_prices_checked = manual_price_checker( old_prices, broker_prices, column_to_check="FINAL", delta_columns=["OPEN", "HIGH", "LOW"], type_new_data=futuresContractPrices, ) price_updater.update_prices_for_contract(contract_object, new_prices_checked, check_for_spike=False)
def update_manual_check_fx_prices_for_code(fx_code, data): new_fx_prices = data.ib_fx_prices.get_fx_prices( fx_code) # returns fxPrices object if len(new_fx_prices) == 0: data.log.warn("No FX prices found for %s" % fx_code) old_fx_prices = data.arctic_fx_prices.get_fx_prices(fx_code) ## May break manual price checking code if not equal old_fx_prices.name = new_fx_prices.name = '' print("\n\n Manually checking prices for %s \n\n" % fx_code) new_prices_checked = manual_price_checker( old_fx_prices, new_fx_prices, type_new_data=fxPrices.from_data_frame) rows_added = data.arctic_fx_prices.update_fx_prices(fx_code, new_prices_checked, check_for_spike=False) return success
def update_manual_check_fx_prices_for_code(fx_code: str, data: dataBlob): db_currency_data = dataCurrency(data) data_broker = dataBroker(data) new_fx_prices = data_broker.get_fx_prices( fx_code) # returns fxPrices object if len(new_fx_prices) == 0: data.log.warn("No FX prices found for %s" % fx_code) old_fx_prices = db_currency_data.get_fx_prices(fx_code) # Will break manual price checking code if not equal old_fx_prices.name = new_fx_prices.name = "" print("\n\n Manually checking prices for %s \n\n" % fx_code) new_prices_checked = manual_price_checker( old_fx_prices, new_fx_prices, type_new_data=fxPrices.from_data_frame) db_currency_data.update_fx_prices_and_return_rows_added( fx_code, new_prices_checked, check_for_spike=False) return success