Files
DinQuant/backend_api_python/env.example
T

359 lines
10 KiB
Plaintext
Raw Normal View History

2025-12-29 03:06:49 +08:00
# QuantDinger local configuration (copy to `.env` and edit)
# `run.py` will load `backend_api_python/.env` automatically if present.
# =========================
# Auth (local login)
# =========================
SECRET_KEY=quantdinger-secret-key-change-me
ADMIN_USER=quantdinger
ADMIN_PASSWORD=123456
2026-01-14 21:41:40 +08:00
ADMIN_EMAIL=
2025-12-29 03:06:49 +08:00
# =========================
# Demo Mode
# =========================
# Set to true to enable read-only mode for public demo.
# Blocks all POST/PUT/DELETE requests except login.
IS_DEMO_MODE=false
2025-12-29 03:06:49 +08:00
# =========================
# Network / App
# =========================
PYTHON_API_HOST=0.0.0.0
PYTHON_API_PORT=5000
PYTHON_API_DEBUG=False
2025-12-30 21:02:38 +08:00
# =========================
# Database Configuration (PostgreSQL)
2025-12-30 21:02:38 +08:00
# =========================
# 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
2025-12-30 21:02:38 +08:00
2025-12-29 03:06:49 +08:00
# =========================
# Pending orders worker (optional)
# =========================
# 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
2025-12-29 03:06:49 +08:00
# Reclaim orders stuck in status=processing after worker crashes (seconds).
PENDING_ORDER_STALE_SEC=90
# =========================
# Live trading order execution settings
# =========================
# 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 (公共邮件服务,所有用户共用)
2025-12-29 03:06:49 +08:00
# =========================
# 用户在个人中心配置自己的通知邮箱,SMTP 服务器由管理员统一配置
2025-12-29 03:06:49 +08:00
SMTP_HOST=
SMTP_PORT=587
SMTP_USER=
SMTP_PASSWORD=
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)
# =========================
# 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.
2026-01-03 20:25:58 +08:00
# For Docker deployment: set PROXY_HOST=host.docker.internal to access host's proxy
2025-12-29 03:06:49 +08:00
PROXY_PORT=
PROXY_HOST=127.0.0.1
PROXY_SCHEME=socks5h
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
# Allow frontend dev server
CORS_ORIGINS=*
# Request rate limit (per minute)
RATE_LIMIT=100
ENABLE_CACHE=False
ENABLE_REQUEST_LOG=True
ENABLE_AI_ANALYSIS=True
2025-12-30 21:02:38 +08:00
# =========================
# Agent memory & reflection (optional)
# =========================
# Toggle agent memory usage in multi-agent analysis
ENABLE_AGENT_MEMORY=true
# 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
2025-12-29 03:06:49 +08:00
# =========================
2026-01-24 03:22:14 +08:00
# LLM Provider Selection
# =========================
# Choose your LLM provider: openrouter, openai, google, deepseek, grok
LLM_PROVIDER=openrouter
# =========================
# OpenRouter (Multi-model gateway, recommended)
2025-12-29 03:06:49 +08:00
# =========================
OPENROUTER_API_KEY=
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
2026-01-24 03:22:14 +08:00
# =========================
# 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
2025-12-29 03:06:49 +08:00
# Optional: override model list shown in UI (JSON object: {"model_id":"Display Name", ...})
AI_MODELS_JSON={}
# =========================
# Data sources (Kline / pricing)
# =========================
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)
2025-12-30 17:03:22 +08:00
CCXT_DEFAULT_EXCHANGE=coinbase
2025-12-29 03:06:49 +08:00
CCXT_TIMEOUT=10000
CCXT_PROXY=
# Akshare (optional)
2025-12-29 03:06:49 +08:00
AKSHARE_TIMEOUT=30
# YFinance
YFINANCE_TIMEOUT=30
# Tiingo (optional)
TIINGO_API_KEY=
TIINGO_TIMEOUT=10
# =========================
2026-02-05 00:25:38 +08:00
# Web Search & News (optional)
2025-12-29 03:06:49 +08:00
# =========================
2026-02-05 00:25:38 +08:00
# Search provider priority: tavily > bocha > google > bing > duckduckgo
2025-12-29 03:06:49 +08:00
SEARCH_PROVIDER=google
SEARCH_MAX_RESULTS=10
2026-02-05 00:25:38 +08:00
# Google Custom Search (CSE)
2025-12-29 03:06:49 +08:00
SEARCH_GOOGLE_API_KEY=
SEARCH_GOOGLE_CX=
2026-02-05 00:25:38 +08:00
# Bing Search API
2025-12-29 03:06:49 +08:00
SEARCH_BING_API_KEY=
2026-02-05 00:25:38 +08:00
# Tavily Search API (专为AI设计,推荐!免费1000次/月)
# Get your key at: https://tavily.com/
# 支持多个 key 轮换,用逗号分隔: key1,key2,key3
TAVILY_API_KEYS=
# 博查 Bocha Search API (国内搜索优化)
2026-02-05 00:25:38 +08:00
# 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=
2025-12-29 03:06:49 +08:00
# Internal API key (optional, if you add internal-service auth later)
INTERNAL_API_KEY=
# =========================
# 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_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_COST_AI_ANALYSIS=10
BILLING_COST_STRATEGY_RUN=5
BILLING_COST_BACKTEST=3
BILLING_COST_PORTFOLIO_MONITOR=8
# Telegram customer service URL for recharge (充值跳转的Telegram链接)
2026-01-14 21:41:40 +08:00
RECHARGE_TELEGRAM_URL=https://t.me/quantdinger
# =========================
# Membership Plans (会员套餐 - Mock支付配置)
# =========================
# Price in USD
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_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
# 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