def process_adjusted_prices_single_instrument(instrument_code, csv_adj_data_path=None, ADD_TO_ARCTIC=True, ADD_TO_CSV=False): ( arctic_multiple_prices, arctic_adjusted_prices, csv_adjusted_prices, ) = _get_data_inputs(csv_adj_data_path) multiple_prices = arctic_multiple_prices.get_multiple_prices( instrument_code) adjusted_prices = futuresAdjustedPrices.stich_multiple_prices( multiple_prices, forward_fill=True) print(adjusted_prices) if ADD_TO_ARCTIC: arctic_adjusted_prices.add_adjusted_prices(instrument_code, adjusted_prices, ignore_duplication=True) if ADD_TO_CSV: csv_adjusted_prices.add_adjusted_prices(instrument_code, adjusted_prices, ignore_duplication=True) return adjusted_prices
def _roll_adjusted_and_multiple_prices(data, instrument_code): """ Roll multiple and adjusted prices THE POSITION MUST BE ZERO IN THE PRICED CONTRACT! WE DON'T CHECK THIS HERE :param data: dataBlob :param instrument_code: str :return: """ print(landing_strip(80)) print("") print("Rolling adjusted prices!") print("") diag_prices = diagPrices(data) current_multiple_prices = diag_prices.get_multiple_prices(instrument_code) # Only required for potential rollback current_adjusted_prices = diag_prices.get_adjusted_prices(instrument_code) try: updated_multiple_prices = update_multiple_prices_on_roll(data, current_multiple_prices, instrument_code) new_adj_prices = futuresAdjustedPrices.stich_multiple_prices(updated_multiple_prices) except Exception as e: data.log.warn("%s : went wrong when rolling: No roll has happened" % e) return failure # We want user input before we do anything compare_old_and_new_prices([current_multiple_prices, updated_multiple_prices, current_adjusted_prices, new_adj_prices], ["Current multiple prices", "New multiple prices", "Current adjusted prices", "New adjusted prices"]) print("") confirm_roll = input("Confirm roll adjusted prices for %s are you sure y/n:" % instrument_code) if confirm_roll!="y": print("\nUSER DID NOT WANT TO ROLL: Setting roll status back to previous state") return failure try: # Apparently good let's try and write rolled data price_updater = updatePrices(data) price_updater.add_adjusted_prices(instrument_code, new_adj_prices, ignore_duplication=True) price_updater.add_multiple_prices(instrument_code, updated_multiple_prices, ignore_duplication=True) except Exception as e: data.log.warn("%s went wrong when rolling: Going to roll-back to original multiple/adjusted prices" % e) rollback_adjustment(data, instrument_code, current_adjusted_prices, current_multiple_prices) return failure return success
""" We create adjusted prices using multiple prices stored in arctic We then store those adjusted prices in arctic """ from sysdata.arctic.arctic_multiple_prices import arcticFuturesMultiplePricesData from sysdata.arctic.arctic_adjusted_prices import arcticFuturesAdjustedPricesData from sysdata.futures.adjusted_prices import futuresAdjustedPrices if __name__ == '__main__': arctic_multiple_prices = arcticFuturesMultiplePricesData() artic_adjusted_prices = arcticFuturesAdjustedPricesData() instrument_list = arctic_multiple_prices.get_list_of_instruments() for instrument_code in instrument_list: print(instrument_code) multiple_prices = arctic_multiple_prices.get_multiple_prices(instrument_code) adjusted_prices = futuresAdjustedPrices.stich_multiple_prices(multiple_prices) print(adjusted_prices) artic_adjusted_prices.add_adjusted_prices(instrument_code, adjusted_prices)
We create adjusted prices using multiple prices stored in arctic We then store those adjusted prices in arctic """ from sysdata.arctic.arctic_multiple_prices import arcticFuturesMultiplePricesData from sysdata.arctic.arctic_adjusted_prices import arcticFuturesAdjustedPricesData from sysdata.futures.adjusted_prices import futuresAdjustedPrices if __name__ == '__main__': arctic_multiple_prices = arcticFuturesMultiplePricesData() artic_adjusted_prices = arcticFuturesAdjustedPricesData() instrument_list = arctic_multiple_prices.get_list_of_instruments() for instrument_code in instrument_list: print(instrument_code) multiple_prices = arctic_multiple_prices.get_multiple_prices( instrument_code) adjusted_prices = futuresAdjustedPrices.stich_multiple_prices( multiple_prices, forward_fill=True) print(adjusted_prices) artic_adjusted_prices.add_adjusted_prices(instrument_code, adjusted_prices, ignore_duplication=True)