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 new_adjusted_prices(self): new_adjusted_prices = getattr(self, "_new_adjusted_prices", None) if new_adjusted_prices is None: new_adjusted_prices = self._new_adjusted_prices = futuresAdjustedPrices.stich_multiple_prices( self.updated_multiple_prices) return new_adjusted_prices
def _roll_adjusted_and_multiple_prices(data: dataBlob, instrument_code: str): """ 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) updated_multiple_prices = update_multiple_prices_on_roll( data, current_multiple_prices, instrument_code) new_adj_prices = futuresAdjustedPrices.stich_multiple_prices( updated_multiple_prices) # 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