refactor deployment config and exchange integrations
Simplify runtime configuration and remove legacy database and settings surface so new installs are easier to operate. Refresh deployment assets, docs, and order execution behavior to keep the packaged app aligned with the current backend. Made-with: Cursor
This commit is contained in:
+87
-245
@@ -1,8 +1,13 @@
|
||||
# QuantDinger local configuration (copy to `.env` and edit)
|
||||
# `run.py` will load `backend_api_python/.env` automatically if present.
|
||||
#
|
||||
# This file is organized as:
|
||||
# 1) first-time deployment settings at the top
|
||||
# 2) advanced / rarely changed settings at the bottom
|
||||
# For Docker image source / ports, use the project-root `.env`.
|
||||
|
||||
# =========================
|
||||
# Auth (local login)
|
||||
# Auth (required)
|
||||
# =========================
|
||||
SECRET_KEY=quantdinger-secret-key-change-me
|
||||
ADMIN_USER=quantdinger
|
||||
@@ -10,67 +15,43 @@ ADMIN_PASSWORD=123456
|
||||
ADMIN_EMAIL=
|
||||
|
||||
# =========================
|
||||
# Demo Mode
|
||||
# Core app
|
||||
# =========================
|
||||
# Set to true to enable read-only mode for public demo.
|
||||
# Blocks all POST/PUT/DELETE requests except login.
|
||||
IS_DEMO_MODE=false
|
||||
|
||||
# =========================
|
||||
# Network / App
|
||||
# =========================
|
||||
PYTHON_API_HOST=0.0.0.0
|
||||
PYTHON_API_PORT=5000
|
||||
PYTHON_API_DEBUG=False
|
||||
|
||||
# =========================
|
||||
# Database Configuration (PostgreSQL)
|
||||
# =========================
|
||||
# PostgreSQL connection URL (required for multi-user mode)
|
||||
# Format: postgresql://user:password@host:port/dbname
|
||||
# Docker: uses this default, no changes needed
|
||||
# Local: change 'postgres' to 'localhost' and update password
|
||||
DATABASE_URL=postgresql://quantdinger:quantdinger123@postgres:5432/quantdinger
|
||||
FRONTEND_URL=http://localhost:8888
|
||||
ENABLE_REGISTRATION=true
|
||||
|
||||
# =========================
|
||||
# Pending orders worker (optional)
|
||||
# AI / LLM (choose one provider)
|
||||
# =========================
|
||||
LLM_PROVIDER=openrouter
|
||||
|
||||
OPENROUTER_API_KEY=
|
||||
OPENROUTER_MODEL=openai/gpt-4o
|
||||
|
||||
OPENAI_API_KEY=
|
||||
OPENAI_MODEL=gpt-4o
|
||||
|
||||
GOOGLE_API_KEY=
|
||||
GOOGLE_MODEL=gemini-1.5-flash
|
||||
|
||||
DEEPSEEK_API_KEY=
|
||||
DEEPSEEK_MODEL=deepseek-chat
|
||||
|
||||
GROK_API_KEY=
|
||||
GROK_MODEL=grok-beta
|
||||
|
||||
# =========================
|
||||
# Common background jobs
|
||||
# =========================
|
||||
# Paper mode default: disabled. If enabled, it will consume `pending_orders` and dispatch signals via webhook.
|
||||
# Poll and dispatch orders from `pending_orders` (live/signal).
|
||||
# Local mode default is enabled in code, but you can override here.
|
||||
ENABLE_PENDING_ORDER_WORKER=true
|
||||
|
||||
# =========================
|
||||
# Portfolio monitor (optional)
|
||||
# =========================
|
||||
# Background service that runs scheduled AI analysis on manual positions
|
||||
# and sends notifications (email/telegram/browser).
|
||||
# Default: enabled. Set to false to disable.
|
||||
ENABLE_PORTFOLIO_MONITOR=true
|
||||
|
||||
# Reclaim orders stuck in status=processing after worker crashes (seconds).
|
||||
PENDING_ORDER_STALE_SEC=90
|
||||
DISABLE_RESTORE_RUNNING_STRATEGIES=false
|
||||
|
||||
# =========================
|
||||
# Live trading order execution settings
|
||||
# Email / SMTP (optional)
|
||||
# =========================
|
||||
# Order execution mode:
|
||||
# - "market": Market order only (immediate execution, recommended for stability)
|
||||
# - "maker": Limit order first, then market order for remaining (lower fees, may not fill)
|
||||
ORDER_MODE=market
|
||||
|
||||
# How long to wait for limit order to fill before switching to market order (seconds)
|
||||
MAKER_WAIT_SEC=10
|
||||
|
||||
# Price offset for limit orders in basis points (1 bps = 0.01%)
|
||||
# Buy orders: price = market_price * (1 - offset)
|
||||
# Sell orders: price = market_price * (1 + offset)
|
||||
MAKER_OFFSET_BPS=2
|
||||
|
||||
# =========================
|
||||
# Email / SMTP (公共邮件服务,所有用户共用)
|
||||
# =========================
|
||||
# 用户在个人中心配置自己的通知邮箱,SMTP 服务器由管理员统一配置
|
||||
SMTP_HOST=
|
||||
SMTP_PORT=587
|
||||
SMTP_USER=
|
||||
@@ -79,283 +60,144 @@ SMTP_FROM=
|
||||
SMTP_USE_TLS=true
|
||||
SMTP_USE_SSL=false
|
||||
|
||||
# Phone / SMS (optional; Twilio REST, required if you enable phone channel)
|
||||
TWILIO_ACCOUNT_SID=
|
||||
TWILIO_AUTH_TOKEN=
|
||||
TWILIO_FROM_NUMBER=
|
||||
|
||||
# Restore strategies with status='running' on backend startup.
|
||||
# Set to true to disable auto-restore.
|
||||
DISABLE_RESTORE_RUNNING_STRATEGIES=false
|
||||
|
||||
# =========================
|
||||
# Strategy execution loop (tick interval)
|
||||
# Proxy (optional)
|
||||
# =========================
|
||||
# Default tick interval for strategy monitoring loop (seconds).
|
||||
# The strategy thread will fetch current price and evaluate triggers once per tick.
|
||||
STRATEGY_TICK_INTERVAL_SEC=10
|
||||
|
||||
# In-memory price cache TTL (seconds). Normally doesn't matter when tick interval is >= TTL.
|
||||
PRICE_CACHE_TTL_SEC=10
|
||||
|
||||
# =========================
|
||||
# Outbound Proxy (optional, recommended if your network blocks data providers)
|
||||
# =========================
|
||||
# If you use a local proxy (common ports: 7890/7891/10808), set PROXY_PORT only.
|
||||
# Default scheme is socks5h and host is 127.0.0.1.
|
||||
# For Docker deployment: set PROXY_HOST=host.docker.internal to access host's proxy
|
||||
PROXY_PORT=
|
||||
PROXY_HOST=127.0.0.1
|
||||
PROXY_SCHEME=socks5h
|
||||
# Most users only need PROXY_URL.
|
||||
# Example local:
|
||||
# PROXY_URL=socks5h://127.0.0.1:10808
|
||||
#
|
||||
# Example Docker:
|
||||
# PROXY_URL=socks5h://host.docker.internal:10808
|
||||
PROXY_URL=
|
||||
|
||||
# You can also set standard variables directly (advanced):
|
||||
# ALL_PROXY=socks5h://127.0.0.1:10808
|
||||
# HTTP_PROXY=socks5h://127.0.0.1:10808
|
||||
# HTTPS_PROXY=socks5h://127.0.0.1:10808
|
||||
# =========================
|
||||
# Captcha / OAuth (optional)
|
||||
# =========================
|
||||
TURNSTILE_SITE_KEY=
|
||||
TURNSTILE_SECRET_KEY=
|
||||
|
||||
# Allow frontend dev server
|
||||
CORS_ORIGINS=*
|
||||
GOOGLE_CLIENT_ID=
|
||||
GOOGLE_CLIENT_SECRET=
|
||||
GOOGLE_REDIRECT_URI=http://localhost:5000/api/auth/oauth/google/callback
|
||||
|
||||
# Request rate limit (per minute)
|
||||
GITHUB_CLIENT_ID=
|
||||
GITHUB_CLIENT_SECRET=
|
||||
GITHUB_REDIRECT_URI=http://localhost:5000/api/auth/oauth/github/callback
|
||||
|
||||
# =========================
|
||||
# Billing / payments (optional)
|
||||
# =========================
|
||||
BILLING_ENABLED=False
|
||||
USDT_PAY_ENABLED=False
|
||||
|
||||
# =========================
|
||||
# Advanced / rarely changed
|
||||
# =========================
|
||||
# The settings below are optional. Most users can leave them unchanged.
|
||||
|
||||
# Network / App tuning
|
||||
PYTHON_API_HOST=0.0.0.0
|
||||
PYTHON_API_PORT=5000
|
||||
PYTHON_API_DEBUG=False
|
||||
RATE_LIMIT=100
|
||||
|
||||
ENABLE_CACHE=False
|
||||
ENABLE_REQUEST_LOG=True
|
||||
ENABLE_AI_ANALYSIS=True
|
||||
|
||||
# =========================
|
||||
# Agent memory & reflection (optional)
|
||||
# =========================
|
||||
# Toggle agent memory usage in multi-agent analysis
|
||||
ENABLE_AGENT_MEMORY=true
|
||||
# Strategy / execution tuning
|
||||
PENDING_ORDER_STALE_SEC=90
|
||||
ORDER_MODE=market
|
||||
MAKER_WAIT_SEC=10
|
||||
MAKER_OFFSET_BPS=2
|
||||
STRATEGY_TICK_INTERVAL_SEC=10
|
||||
PRICE_CACHE_TTL_SEC=10
|
||||
K_LINE_HISTORY_GET_NUMBER=500
|
||||
|
||||
# Memory retrieval settings
|
||||
AGENT_MEMORY_ENABLE_VECTOR=true
|
||||
AGENT_MEMORY_EMBEDDING_DIM=256
|
||||
AGENT_MEMORY_TOP_K=5
|
||||
AGENT_MEMORY_CANDIDATE_LIMIT=500
|
||||
AGENT_MEMORY_HALF_LIFE_DAYS=30
|
||||
AGENT_MEMORY_W_SIM=0.75
|
||||
AGENT_MEMORY_W_RECENCY=0.20
|
||||
AGENT_MEMORY_W_RETURNS=0.05
|
||||
|
||||
# Automated verification loop (replaces cron)
|
||||
ENABLE_REFLECTION_WORKER=false
|
||||
REFLECTION_WORKER_INTERVAL_SEC=86400
|
||||
|
||||
# =========================
|
||||
# LLM Provider Selection
|
||||
# =========================
|
||||
# Choose your LLM provider: openrouter, openai, google, deepseek, grok
|
||||
LLM_PROVIDER=openrouter
|
||||
|
||||
# =========================
|
||||
# OpenRouter (Multi-model gateway, recommended)
|
||||
# =========================
|
||||
OPENROUTER_API_KEY=
|
||||
# LLM advanced tuning
|
||||
OPENROUTER_API_URL=https://openrouter.ai/api/v1/chat/completions
|
||||
OPENROUTER_MODEL=openai/gpt-4o
|
||||
OPENROUTER_TEMPERATURE=0.7
|
||||
OPENROUTER_MAX_TOKENS=4000
|
||||
OPENROUTER_TIMEOUT=300
|
||||
OPENROUTER_CONNECT_TIMEOUT=30
|
||||
|
||||
# =========================
|
||||
# OpenAI Direct
|
||||
# =========================
|
||||
OPENAI_API_KEY=
|
||||
OPENAI_BASE_URL=https://api.openai.com/v1
|
||||
OPENAI_MODEL=gpt-4o
|
||||
|
||||
# =========================
|
||||
# Google Gemini
|
||||
# =========================
|
||||
GOOGLE_API_KEY=
|
||||
GOOGLE_MODEL=gemini-1.5-flash
|
||||
|
||||
# =========================
|
||||
# DeepSeek
|
||||
# =========================
|
||||
DEEPSEEK_API_KEY=
|
||||
DEEPSEEK_BASE_URL=https://api.deepseek.com/v1
|
||||
DEEPSEEK_MODEL=deepseek-chat
|
||||
|
||||
# =========================
|
||||
# xAI Grok
|
||||
# =========================
|
||||
GROK_API_KEY=
|
||||
GROK_BASE_URL=https://api.x.ai/v1
|
||||
GROK_MODEL=grok-beta
|
||||
|
||||
# Optional: override model list shown in UI (JSON object: {"model_id":"Display Name", ...})
|
||||
AI_MODELS_JSON={}
|
||||
|
||||
# =========================
|
||||
# Data sources (Kline / pricing)
|
||||
# =========================
|
||||
# Data sources
|
||||
DATA_SOURCE_TIMEOUT=30
|
||||
DATA_SOURCE_RETRY=3
|
||||
DATA_SOURCE_RETRY_BACKOFF=0.5
|
||||
|
||||
# Finnhub (US stocks / forex helpers depending on implementation)
|
||||
FINNHUB_API_KEY=
|
||||
FINNHUB_TIMEOUT=10
|
||||
FINNHUB_RATE_LIMIT=60
|
||||
|
||||
# CCXT (crypto via Binance by default)
|
||||
CCXT_DEFAULT_EXCHANGE=coinbase
|
||||
CCXT_TIMEOUT=10000
|
||||
CCXT_PROXY=
|
||||
|
||||
# Akshare (optional)
|
||||
AKSHARE_TIMEOUT=30
|
||||
|
||||
# YFinance
|
||||
YFINANCE_TIMEOUT=30
|
||||
|
||||
# Tiingo (optional)
|
||||
TIINGO_API_KEY=
|
||||
TIINGO_TIMEOUT=10
|
||||
|
||||
# =========================
|
||||
# Web Search & News (optional)
|
||||
# =========================
|
||||
# Search provider priority: tavily > bocha > google > bing > duckduckgo
|
||||
# AI search / news providers
|
||||
SEARCH_PROVIDER=google
|
||||
SEARCH_MAX_RESULTS=10
|
||||
|
||||
# Google Custom Search (CSE)
|
||||
SEARCH_GOOGLE_API_KEY=
|
||||
SEARCH_GOOGLE_CX=
|
||||
|
||||
# Bing Search API
|
||||
SEARCH_BING_API_KEY=
|
||||
|
||||
# Tavily Search API (专为AI设计,推荐!免费1000次/月)
|
||||
# Get your key at: https://tavily.com/
|
||||
# 支持多个 key 轮换,用逗号分隔: key1,key2,key3
|
||||
TAVILY_API_KEYS=
|
||||
|
||||
# 博查 Bocha Search API (国内搜索优化)
|
||||
# Get your key at: https://bochaai.com/
|
||||
# 支持多个 key 轮换,用逗号分隔: key1,key2,key3
|
||||
BOCHA_API_KEYS=
|
||||
|
||||
# SerpAPI (Google/Bing 结果抓取,免费100次/月)
|
||||
# Get your key at: https://serpapi.com/
|
||||
# 支持多个 key 轮换,用逗号分隔: key1,key2,key3
|
||||
SERPAPI_KEYS=
|
||||
|
||||
# Internal API key (optional, if you add internal-service auth later)
|
||||
INTERNAL_API_KEY=
|
||||
# SMS / phone notifications
|
||||
TWILIO_ACCOUNT_SID=
|
||||
TWILIO_AUTH_TOKEN=
|
||||
TWILIO_FROM_NUMBER=
|
||||
|
||||
# =========================
|
||||
# Registration & Security (注册与安全)
|
||||
# =========================
|
||||
# Enable user registration (允许用户注册)
|
||||
ENABLE_REGISTRATION=true
|
||||
|
||||
# Cloudflare Turnstile (人机验证)
|
||||
# Get your keys at: https://dash.cloudflare.com/?to=/:account/turnstile
|
||||
TURNSTILE_SITE_KEY=
|
||||
TURNSTILE_SECRET_KEY=
|
||||
|
||||
# Frontend URL (for OAuth redirects)
|
||||
FRONTEND_URL=http://localhost:8080
|
||||
|
||||
# Google OAuth
|
||||
# Get your credentials at: https://console.cloud.google.com/apis/credentials
|
||||
GOOGLE_CLIENT_ID=
|
||||
GOOGLE_CLIENT_SECRET=
|
||||
GOOGLE_REDIRECT_URI=http://localhost:5000/api/auth/oauth/google/callback
|
||||
|
||||
# GitHub OAuth
|
||||
# Get your credentials at: https://github.com/settings/developers
|
||||
GITHUB_CLIENT_ID=
|
||||
GITHUB_CLIENT_SECRET=
|
||||
GITHUB_REDIRECT_URI=http://localhost:5000/api/auth/oauth/github/callback
|
||||
|
||||
# Security: IP rate limit (防爆破 - IP维度)
|
||||
# Block IP after N failed attempts within M minutes for X minutes
|
||||
# Security / verification tuning
|
||||
SECURITY_IP_MAX_ATTEMPTS=10
|
||||
SECURITY_IP_WINDOW_MINUTES=5
|
||||
SECURITY_IP_BLOCK_MINUTES=15
|
||||
|
||||
# Security: Account rate limit (防爆破 - 账户维度)
|
||||
SECURITY_ACCOUNT_MAX_ATTEMPTS=5
|
||||
SECURITY_ACCOUNT_WINDOW_MINUTES=60
|
||||
SECURITY_ACCOUNT_BLOCK_MINUTES=30
|
||||
|
||||
# Verification code settings (验证码设置)
|
||||
VERIFICATION_CODE_EXPIRE_MINUTES=10
|
||||
VERIFICATION_CODE_RATE_LIMIT=60
|
||||
VERIFICATION_CODE_IP_HOURLY_LIMIT=10
|
||||
VERIFICATION_CODE_MAX_ATTEMPTS=5
|
||||
VERIFICATION_CODE_LOCK_MINUTES=30
|
||||
|
||||
# =========================
|
||||
# Billing & Credits (积分计费系统)
|
||||
# =========================
|
||||
# Enable billing system (启用计费系统)
|
||||
BILLING_ENABLED=False
|
||||
|
||||
# Legacy: VIP users bypass ALL paid feature credit costs (NOT recommended)
|
||||
# 建议关闭:VIP 仅用于“VIP免费指标”,其它功能仍扣积分
|
||||
BILLING_VIP_BYPASS=False
|
||||
|
||||
# Credits consumed per feature (各功能消耗积分数)
|
||||
# Billing / credits
|
||||
BILLING_COST_AI_ANALYSIS=10
|
||||
BILLING_COST_STRATEGY_RUN=5
|
||||
BILLING_COST_BACKTEST=3
|
||||
BILLING_COST_PORTFOLIO_MONITOR=8
|
||||
BILLING_COST_POLYMARKET_DEEP_ANALYSIS=15
|
||||
|
||||
# Telegram customer service URL for recharge (充值跳转的Telegram链接)
|
||||
RECHARGE_TELEGRAM_URL=https://t.me/quantdinger
|
||||
CREDITS_REGISTER_BONUS=100
|
||||
CREDITS_REFERRAL_BONUS=50
|
||||
|
||||
# =========================
|
||||
# Membership Plans (会员套餐 - Mock支付配置)
|
||||
# =========================
|
||||
# Price in USD
|
||||
# Membership plans
|
||||
MEMBERSHIP_MONTHLY_PRICE_USD=19.9
|
||||
MEMBERSHIP_YEARLY_PRICE_USD=199
|
||||
MEMBERSHIP_LIFETIME_PRICE_USD=499
|
||||
|
||||
# Credits bonus
|
||||
MEMBERSHIP_MONTHLY_CREDITS=500
|
||||
MEMBERSHIP_YEARLY_CREDITS=8000
|
||||
|
||||
# Lifetime: monthly credits granted every 30 days
|
||||
MEMBERSHIP_LIFETIME_MONTHLY_CREDITS=800
|
||||
|
||||
# =========================
|
||||
# USDT Pay (Plan B: per-order unique address)
|
||||
# =========================
|
||||
USDT_PAY_ENABLED=False
|
||||
# USDT payment
|
||||
USDT_PAY_CHAIN=TRC20
|
||||
|
||||
# TRC20 (TRON) watch-only xpub (derive deposit addresses from index 0..N)
|
||||
USDT_TRC20_XPUB=
|
||||
|
||||
# USDT TRC20 contract on TRON (default)
|
||||
USDT_TRC20_CONTRACT=TXLAQ63Xg1NAzckPwKHvzw7CSEmLMEqcdj
|
||||
|
||||
# TronGrid API
|
||||
TRONGRID_BASE_URL=https://api.trongrid.io
|
||||
TRONGRID_API_KEY=
|
||||
|
||||
# Order confirmation delay and expiration
|
||||
USDT_PAY_CONFIRM_SECONDS=30
|
||||
USDT_PAY_EXPIRE_MINUTES=30
|
||||
# Background worker poll interval (seconds) for checking pending USDT orders
|
||||
USDT_WORKER_POLL_INTERVAL=30
|
||||
|
||||
# New user registration bonus credits (新用户注册赠送积分)
|
||||
CREDITS_REGISTER_BONUS=100
|
||||
|
||||
# Referral bonus credits (邀请用户赠送积分,邀请人获得)
|
||||
CREDITS_REFERRAL_BONUS=50
|
||||
|
||||
# History K-Line ticket get number (策略中默认获取历史K线数量)
|
||||
K_LINE_HISTORY_GET_NUMBER=500
|
||||
|
||||
Reference in New Issue
Block a user