def sync_dol_bar(pair, db_name, record_name, threhold, interval='1m'): #get time of last row from db # 'features.sqlite',"x_features" pre_sql = psql.Preprocess_sql(db_name, record_name) time = str(pre_sql.get_last_n(1).date_time[0]) # get klines from last time to current time klines = get_data.get_klines_df(time, symbol=pair, interval=interval) if get_data.is_limit(klines, threhold): #convert klines to dol_bar dol_bar = get_data.form_dol_bar(klines, threhold) # get last 25 rows # combine them to nwe dol bar #calculate features #get only df2 #store to db last_twenty = pre_sql.get_last_n(25) p = proprecess.Proprecessing() p.combine_df(last_twenty, dol_bar) p.add_features() new_bars = p.get_df2() pre_sql.store_df(new_bars) print("finished") else: print("up to date")
def __init__(self, pair, db_name, record_name, threshold, interval='1m', model_path=None, columns_path=None): self.predict = get_predict.Get_predict() self.predict.load_model(model_path) self.columns = json.load(open(columns_path))['columns'] self.configs = change_config.Change_config() self.pair = pair self.interval = interval self.db_name = db_name self.record_name = record_name self.threshold = threshold self.load_long_strategy() self.load_short_strategy() #connect to sql database self.pre_sql = psql.Preprocess_sql(self.db_name, self.record_name)
def get_last_row(self, db_name, record_name, n=1): p = preprocess_sql.Preprocess_sql(db_name, record_name) return p.get_last_n(n)
import sys sys.path.append('../handle_sql') import preprocess_sql as ps pairs = ["BTCUSDT", "ETHUSDT", "IOTAUSDT"] for p in pairs: p = ps.Preprocess_sql('../pair_db/features.sqlite', p) r = p.get_last_n(2) # r['index'] = r['index']+1 # r.index = r['index'] # r.drop(columns=['index'],inplace=True) # r['tick_num']=1 print(r.head()) # p.store_df(r) # p.select_index()
import preprocess_sql as ps import sync_sql as ss p = ps.Preprocess_sql('features.sqlite',"x_features") r = p.get_last_n(2) # r['index'] = r['index']+1 # r.index = r['index'] # r.drop(columns=['index'],inplace=True) # r['tick_num']=1 print(r.head()) # p.store_df(r) # p.select_index()