add tick_interval to get_ticker_history as an optional parameter
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from typing import List, Dict
|
||||
from typing import List, Dict, Optional
|
||||
|
||||
import requests
|
||||
from bittrex.bittrex import Bittrex as _Bittrex
|
||||
@@ -20,14 +20,11 @@ class Bittrex(Exchange):
|
||||
BASE_URL: str = 'https://www.bittrex.com'
|
||||
TICKER_METHOD: str = BASE_URL + '/Api/v2.0/pub/market/GetTicks'
|
||||
PAIR_DETAIL_METHOD: str = BASE_URL + '/Market/Index'
|
||||
# Ticker inveral
|
||||
TICKER_INTERVAL: str = 'fiveMin'
|
||||
# Sleep time to avoid rate limits, used in the main loop
|
||||
SLEEP_TIME: float = 25
|
||||
|
||||
@property
|
||||
def sleep_time(self) -> float:
|
||||
return self.SLEEP_TIME
|
||||
""" Sleep time to avoid rate limits, used in the main loop """
|
||||
return 25
|
||||
|
||||
def __init__(self, config: dict) -> None:
|
||||
global _API, _EXCHANGE_CONF
|
||||
@@ -86,17 +83,24 @@ class Bittrex(Exchange):
|
||||
'last': float(data['result']['Last']),
|
||||
}
|
||||
|
||||
def get_ticker_history(self, pair: str):
|
||||
url = self.TICKER_METHOD
|
||||
def get_ticker_history(self, pair: str, tick_interval: int):
|
||||
headers = {
|
||||
# TODO: Set as global setting
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36'
|
||||
}
|
||||
|
||||
if tick_interval == 1:
|
||||
interval = 'oneMin'
|
||||
elif tick_interval == 5:
|
||||
interval = 'fiveMin'
|
||||
else:
|
||||
raise ValueError('Cannot parse tick_interval: {}'.format(tick_interval))
|
||||
|
||||
params = {
|
||||
'marketName': pair.replace('_', '-'),
|
||||
'tickInterval': self.TICKER_INTERVAL,
|
||||
'tickInterval': interval,
|
||||
}
|
||||
data = requests.get(url, params=params, headers=headers).json()
|
||||
data = requests.get(self.TICKER_METHOD, params=params, headers=headers).json()
|
||||
if not data['success']:
|
||||
raise RuntimeError('{message} params=({pair})'.format(
|
||||
message=data['message'],
|
||||
|
||||
Reference in New Issue
Block a user