Files
obsidian-vault/05 投资交易/docker运行freqtrade时时区的统一.md
2026-06-23 00:24:32 +08:00

52 lines
1.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#交易 #量化交易 #软件配置 #freqtrade #docker
docker默认的时区为UTC但是我们所处的时区是CST相差八小时
在原生运行时不存在这个问题,本机的时间
但是因为docker的默认设置有可能会造成时间轴的错误
为了解决这个问题,需要从解决:
一是更改docker的默认时区。
二是在config中确认时区。
只有这样做才可以使本地时间和数据的时间对齐,这是交易和回测的基本要求。
更改docker时区走了很多弯路。
最后找到的办法是在`docker-compose.yml`environment中加入。
```yml
environment:
- HTTP_PROXY=http://127.0.0.1:7890
- HTTPS_PROXY=http://127.0.0.1:7890
- NO_PROXY=localhost,127.0.0.1,api.binance.com
- TZ=Asia/Shanghai
```
结果如图。
在config中增加时区示例关注timezone即可
```python
"exchange": {
"name": "binance",
"key": "",
"secret": "",
"timezone": "Asia/Shanghai" ,
"ccxt_config": {},
"ccxt_async_config": {},
"pair_whitelist": [
"BTC/USDT:USDT",
"ETH/USDT:USDT",
],
"pair_blacklist": [
"BNB/.*"
]
},
"pairlists": [
{
"method": "StaticPairList",
"number_assets": 20,
"sort_key": "quoteVolume",
"min_value": 0,
"refresh_period": 1800
}
],
```