def create_cut_table(self): self.first_date = CandleTable.get_first_date(self.candle_table_name) self.last_date = CandleTable.get_last_date(self.candle_table_name) self.cut_trend_table_name = self.get_trend_table_name() if DBManager.exists_table(self.cut_trend_table_name): DBManager.drop_table(self.cut_trend_table_name) tt = TrendTable(self.cut_trend_table_name) tt.save() candles = CandleTable.get_candle_array(self.candle_table_name) for c in candles: date = c.date hits = TrendTable.get_most_recent_hits(self.trend_table_name, date) trend = Trend(dbm, self.cut_trend_table_name, date, hits) trend.save() ##cursor = TrendTable.get_section(self.trend_table_name, self.first_date, self.last_date) ##trend_tuples = cursor.fetchall() ##for t in trend_tuples: ##date = t[0] ##hits = t[1] ##trend = Trend(dbm, self.cut_trend_table_name, date, hits) ##trend.save() ##dbm.save_and_close() return tt
def update_all(): for tn in table_names.complete_tables: last_date_updated = CandleTable.get_last_date(tn) target_curr = CandleTable.get_target_currency(tn) period = CandleTable.get_period(tn) CandleFetcher.fetch_candles_after_date(target_curr, last_date_updated, period)
def update_tables(tns): for tn in tns: last_date_updated = CandleTable.get_last_date(tn) target_curr = CandleTable.get_target_currency(tn) period = CandleTable.get_period(tn) CandleFetcher.fetch_candles_after_date( target_curr, (last_date_updated - 10 * int(period)), period)
def update_tables_imperative(tns): ##CandleFetcher.update_tables(tns) ##perform normal update of any legit candles(replacing fake ones) for i, tn in enumerate(tns): sec_now = time.time() last_candle_date = CandleTable.get_last_date(tn) target_curr = CandleTable.get_target_currency(tn) period = int(CandleTable.get_period(tn)) curr_pair = "USDT_" + target_curr last_candle_date += period while (last_candle_date < sec_now): ##(top_bid, bottom_ask) = OrderMaker.get_spread(curr_pair) ##if curr_avail[target_curr]: ##means it is true, means it is available to be sold ##close = bottom_ask ##else: ##close = top_bid close = OrderMaker.get_last_trade_rate(curr_pair, last_candle_date) c = Candle(tn, last_candle_date, 0, 0, 0, close, 0, 0, 0) c.save() last_candle_date += period dbm = DBManager.get_instance() dbm.save_and_close()
def grab_new_signals(self): period = float(CandleTable.get_period(table_names.short_term_tables[0])) last_time = CandleTable.get_last_date(table_names.short_term_tables[0]) cur_time = time.time() if(cur_time-last_time) > (period+1): print("***********************************SIGNALS*********************************************") self.signaler.update(self.order_updater.sym_infos) new_signals_array = self.signaler.new_signals_array self.handle_new_currency_signals(new_signals_array) sym_infos = self.order_updater.sym_infos for key, value in sym_infos.items(): print("last operation was: " , value.is_owned) return Task.CONTINUE