From 484002597cc825fe638058325bb190dd284591a2 Mon Sep 17 00:00:00 2001 From: realiti4 Date: Mon, 15 Mar 2021 21:38:02 +0300 Subject: [PATCH] bug fixes --- tradingfeatures/apis/bitmex/base.py | 2 +- tradingfeatures/apis/bitmex/funding.py | 5 +++-- tradingfeatures/apis/bitmex/quote.py | 13 ++++--------- tradingfeatures/uber.py | 11 ++--------- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/tradingfeatures/apis/bitmex/base.py b/tradingfeatures/apis/bitmex/base.py index 0241a8e..ee68de2 100644 --- a/tradingfeatures/apis/bitmex/base.py +++ b/tradingfeatures/apis/bitmex/base.py @@ -34,7 +34,7 @@ def get(self, start, end, out_of_range = self.calc_start(limit, start, end, interval) if out_of_range: - return self.get_hist(start=start, end=end) + return self.get_hist(start=start, end=end, columns=columns) address = address or self.address address = self.base_address + address diff --git a/tradingfeatures/apis/bitmex/funding.py b/tradingfeatures/apis/bitmex/funding.py index 84b5e05..aa6b4b4 100644 --- a/tradingfeatures/apis/bitmex/funding.py +++ b/tradingfeatures/apis/bitmex/funding.py @@ -67,10 +67,11 @@ def get_recent(self, df): # Recent Funding df_final = df_final[['fundingRate']] return df_final - def get_hist(self, convert_funds=False, *args, **kwargs): + def get_hist(self, columns=None, convert_funds=False, *args, **kwargs): + columns = ['fundingRate', 'fundingRateDaily'] if columns is None else columns return apiBase.get_hist( self, - columns=['fundingRate', 'fundingRateDaily'], + columns=columns, interval='8h', *args, **kwargs ) diff --git a/tradingfeatures/apis/bitmex/quote.py b/tradingfeatures/apis/bitmex/quote.py index b532dd5..a9e0595 100644 --- a/tradingfeatures/apis/bitmex/quote.py +++ b/tradingfeatures/apis/bitmex/quote.py @@ -16,13 +16,6 @@ def __init__(self): self.start = 1423227200 def get(self, symbol=None, query=None, start=None, end=None, *args, **kwargs): - # start = self.start if start is None else start - # end = time.time() if end is None else end - # start, end = self.to_date(start), self.to_date(end) - # symbol = symbol or 'XBT' - - # if query is None: - # query = {'symbol': symbol, 'binSize': interval, 'count': self.limit, 'reverse': 'false', 'startTime': start} return super(bitmexQuote, self).get( query=query, @@ -31,10 +24,12 @@ def get(self, symbol=None, query=None, start=None, end=None, *args, **kwargs): *args, **kwargs ) - def get_hist(self, convert_funds=False, *args, **kwargs): + def get_hist(self, columns=None, convert_funds=False, *args, **kwargs): + columns = ['bidSize', 'bidPrice', 'askPrice', 'askSize'] if columns is None else columns + df = apiBase.get_hist( self, - columns=['bidSize', 'bidPrice', 'askPrice', 'askSize'], + columns=columns, # interval='8h', *args, **kwargs ) diff --git a/tradingfeatures/uber.py b/tradingfeatures/uber.py index 9c612c3..62d0bd6 100644 --- a/tradingfeatures/uber.py +++ b/tradingfeatures/uber.py @@ -49,7 +49,7 @@ def eval_get(self, limit=1000, **kwargs): # Fix for 0 and nan - check here again later merged = merged.replace(0, np.nan) - if df.isnull().values.any(): # Check here later + if merged.isnull().values.any(): # Check here later merged = merged.interpolate() return merged @@ -96,14 +96,7 @@ def get(self, path='', datasets=None, merge=True, trends=False, date=True, df_final[item] = df_main.loc[:, df_main.columns.str.contains(item)].mean(axis=1) if date: - df_final['date'] = pd.to_datetime(df_final.index, unit='s', utc=True) - - # Extras - # if experiment_binance: - # binance_api = self.apis_dict['binance'] - # columns = ['quote_asset_volume', 'number_of_trades', 'taker_base_asset_volume', 'taker_quote_asset_volume'] - # features = binance_api.get()[columns] - # df_final = df_final.join(features) + df_final['date'] = pd.to_datetime(df_final.index, unit='s', utc=True) if trends: df_trends = self.google_trends.update('uber_data')