Selectively convert quote to base volume in volumepairlist

This commit is contained in:
Matthias 2022-01-06 14:12:00 +01:00
parent a0f9c1bf7b
commit 326e3d1f8e
3 changed files with 12 additions and 5 deletions

View File

@ -67,6 +67,8 @@ class Exchange:
"ohlcv_params": {}, "ohlcv_params": {},
"ohlcv_candle_limit": 500, "ohlcv_candle_limit": 500,
"ohlcv_partial_candle": True, "ohlcv_partial_candle": True,
# Check https://github.com/ccxt/ccxt/issues/10767 for removal of ohlcv_volume_currency
"ohlcv_volume_currency": "base", # "base" or "quote"
"trades_pagination": "time", # Possible are "time" or "id" "trades_pagination": "time", # Possible are "time" or "id"
"trades_pagination_arg": "since", "trades_pagination_arg": "since",
"l2_limit_range": None, "l2_limit_range": None,

View File

@ -19,6 +19,7 @@ class Ftx(Exchange):
_ft_has: Dict = { _ft_has: Dict = {
"stoploss_on_exchange": True, "stoploss_on_exchange": True,
"ohlcv_candle_limit": 1500, "ohlcv_candle_limit": 1500,
"ohlcv_volume_currency": "quote",
} }
def market_is_tradable(self, market: Dict[str, Any]) -> bool: def market_is_tradable(self, market: Dict[str, Any]) -> bool:

View File

@ -184,12 +184,16 @@ class VolumePairList(IPairList):
] if (p['symbol'], self._lookback_timeframe) in candles else None ] if (p['symbol'], self._lookback_timeframe) in candles else None
# in case of candle data calculate typical price and quoteVolume for candle # in case of candle data calculate typical price and quoteVolume for candle
if pair_candles is not None and not pair_candles.empty: if pair_candles is not None and not pair_candles.empty:
pair_candles['typical_price'] = (pair_candles['high'] + pair_candles['low'] if self._exchange._ft_has["ohlcv_volume_currency"] == "base":
+ pair_candles['close']) / 3 pair_candles['typical_price'] = (pair_candles['high'] + pair_candles['low']
pair_candles['quoteVolume'] = ( + pair_candles['close']) / 3
pair_candles['volume'] * pair_candles['typical_price']
)
pair_candles['quoteVolume'] = (
pair_candles['volume'] * pair_candles['typical_price']
)
else:
# Exchange ohlcv data is in quote volume already.
pair_candles['quoteVolume'] = pair_candles['volume']
# ensure that a rolling sum over the lookback_period is built # ensure that a rolling sum over the lookback_period is built
# if pair_candles contains more candles than lookback_period # if pair_candles contains more candles than lookback_period
quoteVolume = (pair_candles['quoteVolume'] quoteVolume = (pair_candles['quoteVolume']