freqtrade关于获取k线数量,以及显示时间的问题
关于获取K的数据
配置了16个symbol,按照需求,最多需要300根K就可以做到macd的指标的计算就非常精准了;为了加快速度,不需要1500个K,这样严重浪费运行的时间;
按照配置,去寻找,直接把exchange 下在limit =300就写死好了。反正就玩个BN的平台。
就修改这一个地方; candle_limit = 300
@retrier_asyncasync def _async_get_candle_history(self,pair: str,timeframe: str,candle_type: CandleType,since_ms: int | None = None,) -> OHLCVResponse:"""Asynchronously get candle history data using fetch_ohlcv:param candle_type: '', mark, index, premiumIndex, or funding_ratereturns tuple: (pair, timeframe, ohlcv_list)"""try:# Fetch OHLCV asynchronouslys = "(" + dt_from_ts(since_ms).isoformat() + ") " if since_ms is not None else ""logger.debug("Fetching pair %s, %s, interval %s, since %s %s...",pair,candle_type,timeframe,since_ms,s,)params = deepcopy(self._ft_has.get("ohlcv_params", {}))# candle_limit = self.ohlcv_candle_limit(# timeframe, candle_type=candle_type, since_ms=since_ms# )candle_limit = 300if candle_type and candle_type != CandleType.SPOT:params.update({"price": candle_type.value})if candle_type != CandleType.FUNDING_RATE:data = await self._api_async.fetch_ohlcv(pair, timeframe=timeframe, since=since_ms, limit=candle_limit, params=params)else:# Funding ratedata = await self._fetch_funding_rate_history(pair=pair,timeframe=timeframe,limit=candle_limit,since_ms=since_ms,)# Some exchanges sort OHLCV in ASC order and others in DESC.# Ex: Bittrex returns the list of OHLCV in ASC order (oldest first, newest last)# while GDAX returns the list of OHLCV in DESC order (newest first, oldest last)# Only sort if necessary to save computing timetry:if data and data[0][0] > data[-1][0]:data = sorted(data, key=lambda x: x[0])except IndexError:logger.exception("Error loading %s. Result was %s.", pair, data)return pair, timeframe, candle_type, [], self._ohlcv_partial_candlelogger.debug("Done fetching pair %s, %s interval %s...", pair, candle_type, timeframe)return pair, timeframe, candle_type, data, self._ohlcv_partial_candleexcept ccxt.NotSupported as e:raise OperationalException(f"Exchange {self._api.name} does not support fetching historical "f"candle (OHLCV) data. Message: {e}") from eexcept ccxt.DDoSProtection as e:raise DDosProtection(e) from eexcept (ccxt.OperationFailed, ccxt.ExchangeError) as e:raise TemporaryError(f"Could not fetch historical candle (OHLCV) data "f"for {pair}, {timeframe}, {candle_type} due to {e.__class__.__name__}. "f"Message: {e}") from eexcept ccxt.BaseError as e:raise OperationalException(f"Could not fetch historical candle (OHLCV) data for "f"{pair}, {timeframe}, {candle_type}. Message: {e}") from e
关于时间戳转化问题
计算出来的指标要和东八区的时间进行对应,这样看起来就不会变扭了。直接进行源码搜索;
按照相应的地方进行修改和上传了。
最后就是UI界面和监控
设置一下东八区,以及MACD的指标搞起来;
这个界面在UI的最最右上角。
可以看到组合后的信号和zigzag很像,但肯定比这个有未来函数的zigzag强多了。还有很多其他信号也可以把状态码给弄出来。先把信号对齐了再搞把。
关于telegram的配置
观察一段dry-run时间,后门把这个功能补齐,就可以实现用telegram发信号,来平仓以及监控这个平台;