freqtrade_origin/freqtrade/dataprovider.py

57 lines
1.3 KiB
Python
Raw Normal View History

2018-11-30 19:42:16 +00:00
"""
Dataprovider
Responsible to provide data to the bot
including Klines, tickers, historic data
Common Interface for bot and strategy to access data.
"""
import logging
2018-12-02 14:57:49 +00:00
from typing import List, Dict
2018-11-30 19:42:16 +00:00
2018-12-02 08:16:35 +00:00
from pandas import DataFrame
2018-11-30 19:42:16 +00:00
from freqtrade.exchange import Exchange
logger = logging.getLogger(__name__)
class DataProvider(object):
2018-12-02 08:16:35 +00:00
def __init__(self, config: dict, exchange: Exchange) -> None:
self._config = config
self._exchange = exchange
2018-11-30 19:42:16 +00:00
2018-12-02 14:57:49 +00:00
def refresh(self, pairlist: List[str]) -> None:
2018-11-30 19:42:16 +00:00
"""
Refresh data, called with each cycle
"""
2018-12-02 14:57:49 +00:00
self._exchange.refresh_tickers(pairlist, self._config['ticker_interval'])
2018-11-30 19:42:16 +00:00
2018-12-02 14:57:49 +00:00
def ohlcv(self, pair: str) -> List[str]:
2018-11-30 19:42:16 +00:00
"""
2018-12-02 08:16:35 +00:00
get ohlcv data for the given pair as DataFrame
2018-11-30 19:42:16 +00:00
"""
2018-12-02 08:16:35 +00:00
# TODO: Should not be stored in exchange but in this class
return self._exchange.klines.get(pair)
2018-11-30 19:42:16 +00:00
2018-12-02 08:16:35 +00:00
def historic_ohlcv(self, pair: str) -> DataFrame:
2018-11-30 19:42:16 +00:00
"""
get historic ohlcv data stored for backtesting
"""
pass
2018-12-02 08:16:35 +00:00
def ticker(self, pair: str):
"""
Return last ticker data
"""
2018-11-30 19:42:16 +00:00
pass
2018-12-02 08:16:35 +00:00
def orderbook(self, pair: str, max: int):
"""
return latest orderbook data
"""
2018-11-30 19:42:16 +00:00
pass
2018-12-02 08:16:35 +00:00
def balance(self, pair):
2018-11-30 19:42:16 +00:00
# TODO: maybe use wallet directly??
pass