Skip to content

Commit

Permalink
enabling minute intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
realiti4 committed Apr 21, 2021
1 parent b9803d4 commit 0994b74
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tradingfeatures/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ def get(self, *args, **kwargs):
def interval_check(self, interval):
if 'h' in interval:
interval = int(interval.split('h')[0]) * 3600
minutes = int(interval / 60)
return interval, minutes
minutes = int(interval / 60)
elif 'm' in interval:
interval = int(interval.split('m')[0]) * 60
minutes = int(interval / 60)
else:
raise Exception('Only hours supportted right now')
return interval, minutes

def symbol_check(self, symbol):
# symbol = 'btcusd' if symbol is None else symbol
Expand Down Expand Up @@ -89,6 +92,7 @@ def get_hist(self,
start = start or self.start
end = end or int(time.time())

interval_str = interval # to give it to .get() func
interval, minutes = self.interval_check(interval)

total_entries = (end - start) // interval
Expand All @@ -106,7 +110,7 @@ def get_hist(self,
if end_batch >= end:
end_batch = end
try:
df_temp = self.get(symbol=symbol, start=str(start_batch), end=str(end_batch))
df_temp = self.get(symbol=symbol, interval=interval_str, start=str(start_batch), end=str(end_batch))
if df_temp is None: # Try this fix for other apis
print(' Debug: df_temp is empty')
assert len(df) == 0, 'Debug: empty df_temp in middle of download'
Expand Down

0 comments on commit 0994b74

Please sign in to comment.