use TTLCache for get_ticker_history
This commit is contained in:
parent
3126dcfcea
commit
8f817a3634
@ -4,6 +4,7 @@ from random import randint
|
|||||||
from typing import List, Dict, Any, Optional
|
from typing import List, Dict, Any, Optional
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
|
from cachetools import cached, TTLCache
|
||||||
|
|
||||||
from freqtrade.exchange.bittrex import Bittrex
|
from freqtrade.exchange.bittrex import Bittrex
|
||||||
from freqtrade.exchange.interface import Exchange
|
from freqtrade.exchange.interface import Exchange
|
||||||
@ -127,6 +128,7 @@ def get_ticker(pair: str) -> dict:
|
|||||||
return _API.get_ticker(pair)
|
return _API.get_ticker(pair)
|
||||||
|
|
||||||
|
|
||||||
|
@cached(TTLCache(maxsize=100, ttl=30))
|
||||||
def get_ticker_history(pair: str, tick_interval: Optional[int] = 5) -> List:
|
def get_ticker_history(pair: str, tick_interval: Optional[int] = 5) -> List:
|
||||||
return _API.get_ticker_history(pair, tick_interval)
|
return _API.get_ticker_history(pair, tick_interval)
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class Bittrex(Exchange):
|
|||||||
_API = _Bittrex(
|
_API = _Bittrex(
|
||||||
api_key=_EXCHANGE_CONF['key'],
|
api_key=_EXCHANGE_CONF['key'],
|
||||||
api_secret=_EXCHANGE_CONF['secret'],
|
api_secret=_EXCHANGE_CONF['secret'],
|
||||||
calls_per_second=5,
|
calls_per_second=3,
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -299,6 +299,7 @@ def main():
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
elif new_state == State.RUNNING:
|
elif new_state == State.RUNNING:
|
||||||
_process()
|
_process()
|
||||||
|
time.sleep(5)
|
||||||
old_state = new_state
|
old_state = new_state
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
SQLAlchemy==1.1.14
|
SQLAlchemy==1.1.14
|
||||||
python-telegram-bot==8.1.1
|
python-telegram-bot==8.1.1
|
||||||
arrow==0.10.0
|
arrow==0.10.0
|
||||||
|
cachetools==2.0.1
|
||||||
requests==2.18.4
|
requests==2.18.4
|
||||||
urllib3==1.22
|
urllib3==1.22
|
||||||
wrapt==1.10.11
|
wrapt==1.10.11
|
||||||
|
1
setup.py
1
setup.py
@ -34,6 +34,7 @@ setup(name='freqtrade',
|
|||||||
'jsonschema',
|
'jsonschema',
|
||||||
'TA-Lib',
|
'TA-Lib',
|
||||||
'tabulate',
|
'tabulate',
|
||||||
|
'cachetools',
|
||||||
],
|
],
|
||||||
dependency_links=[
|
dependency_links=[
|
||||||
"git+https://github.com/ericsomdahl/python-bittrex.git@0.2.0#egg=python-bittrex"
|
"git+https://github.com/ericsomdahl/python-bittrex.git@0.2.0#egg=python-bittrex"
|
||||||
|
Loading…
Reference in New Issue
Block a user