def run_inner_or_outer_ocat(self, set_point_market: str, target_currency: str, is_inner_ocat: bool): if is_inner_ocat: # create combination of coin that is injected by validating if the exchange has that coin logging.critical("Set Point Market is: [%s]" % set_point_market.upper()) inner_ocat_list = Global.get_inner_ocat_combination( set_point_market, target_currency) logging.critical("--------Conducting Inner OCAT--------") ocat_final_result = self.otc_all_combination_by_one_coin( target_currency, inner_ocat_list) elif not is_inner_ocat: logging.critical("--------Conducting Outer OCAT--------") ocat_final_result = [] for outer_ocat_coin in list(Global.get_avail_coin_in_list()): logging.warning("Now conducting [%s]" % outer_ocat_coin.upper()) outer_ocat_list = Global.get_rfab_combination_tuples( outer_ocat_coin) ocat_result = self.otc_all_combination_by_one_coin( outer_ocat_coin, outer_ocat_list) ocat_final_result.extend(ocat_result) # save this setting for updating IYO setting in future ref self.ocat_final_result = ocat_final_result else: raise Exception("Please indicate if it is Inner OCAT or not") descending_order_result = OTCScheduler.sort_by_logest_oppty_time_to_lowest( ocat_final_result) top_ten_descend_order_result = descending_order_result[:10] for result in top_ten_descend_order_result: new_percent = (result["new"] / self.INITIATION_REWEIND_TIME) * 100 rev_percent = (result["rev"] / self.INITIATION_REWEIND_TIME) * 100 new_spread_strength = result["new_spread_ratio"] * 100 rev_spread_strength = result["rev_spread_ratio"] * 100 logging.warning( "[%s] NEW: %.2f%%, REV: %.2f%% // NEW_SPREAD_STRENGTH: %.2f%%, REV_SPREAD_STRENGTH: %.2f%%" % (result["combination"], new_percent, rev_percent, new_spread_strength, rev_spread_strength))
def _actual_run_in_loop(self): now_date = int(time.time()) publish_epoch_date_set = self.get_publish_epoch_date_set() for publish_epoch_date in publish_epoch_date_set: if (now_date >= publish_epoch_date) \ and (now_date <= publish_epoch_date + (self.interval_time_sec * 2)): start_time = publish_epoch_date - self.time_dur_to_anal end_time = publish_epoch_date logging.critical("OTC activated start_time: %d" % now_date) # loop through all possible coins and run final_result = [] for target_currency in list(Global.get_avail_coin_in_list()): logging.critical("Now conducting %s" % target_currency.upper()) result_by_one_coin = self.otc_all_mm_comb_by_one_coin( target_currency, start_time, end_time) final_result.extend(result_by_one_coin) # sort by highest to lowest oppty duration descending_order_result = self.sort_by_logest_oppty_time_to_lowest( final_result) top_twenty_descend_order_result = descending_order_result[:20] # send this final result to slack in form of str start_local_date = Global.convert_epoch_to_local_datetime( start_time) publish_local_date = Global.convert_epoch_to_local_datetime( publish_epoch_date, timezone="kr") self.send_result_nicely_to_slack( top_twenty_descend_order_result, start_local_date, publish_local_date) else: continue pass
def _actual_run_in_loop(self): start_time = int(time.time()) - self.interval_time_sec end_time = int(time.time()) for target_currency in list(Global.get_avail_coin_in_list()): self.iyo_result_to_mongo_db(target_currency, start_time, end_time)