移除 Redis、精简配置,新增 Docker 支持

- position_closer: 去掉 Redis 依赖,平仓条件仅名义+未实现盈亏
- requirements: 移除 redis
- settings.toml: 仅保留实际使用的配置项
- 新增 Dockerfile(仅安装依赖)、docker-compose(挂载代码与配置)
- 新增 .dockerignore、.gitignore(含 nohup.log)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yhydev
2026-02-04 10:06:30 +08:00
parent 2b72dc40ae
commit 48d31cd1d0
16 changed files with 1245 additions and 31 deletions

22
docker-compose.yml Normal file
View File

@@ -0,0 +1,22 @@
# 币安永续合约定时平仓
# 用法:
# 首次:复制 .secrets.toml.example 为 .secrets.toml 并填写 API 密钥
# 运行一次: docker compose run --rm position-closer
# 后台定时: docker compose up -d (按 profile 或 command 配置循环)
services:
position-closer:
build: .
image: bn-position-closer:latest
container_name: position-closer
# 挂载项目目录,代码与配置均从宿主机读取(不写入镜像)
volumes:
- .:/app:ro
# 可选:用环境变量覆盖配置(如 CI/云环境)
environment:
- BINANCE_POSITION_DRY_RUN=${DRY_RUN:-true}
env_file:
- .env
# 默认运行一次;需每小时循环时可改为 command: ["sh", "-c", "while true; do python -m position_closer; sleep 3600; done"]
command: ["python", "-m", "position_closer"]
restart: "no"