bifitnex-trading/config.py
kroutony 2c5fb53ef3 Align cost basis start date to 2026-03-10 UTC
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 10:27:11 +00:00

84 lines
2.8 KiB
Python
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.

import os
from dotenv import load_dotenv
load_dotenv()
# Bitfinex API
BFX_API_KEY = os.getenv("BFX_API_KEY", "")
BFX_API_SECRET = os.getenv("BFX_API_SECRET", "")
BFX_BASE_URL = "https://api-pub.bitfinex.com"
BFX_AUTH_URL = "https://api.bitfinex.com"
# Slack
SLACK_WEBHOOK_URL = os.getenv("SLACK_WEBHOOK_URL", "")
# Top USDT trading pairs on Bitfinex (verified active)
# Note: some use "tXXXUST" format, others use "tXXX:UST" (5+ char base)
TOP_15_SYMBOLS = [
"tBTCUST", "tETHUST", "tSOLUST", "tXRPUST", "tADAUST",
"tDOGE:UST", "tAVAX:UST", "tDOTUST", "tLINK:UST", "tLTCUST",
"tSHIB:UST", "tATOUST", "tUNIUST", "tSUIUST", "tXLMUST",
]
# Symbol display names for readability
SYMBOL_NAMES = {
"tBTCUST": "BTC/USDT", "tETHUST": "ETH/USDT", "tSOLUST": "SOL/USDT",
"tXRPUST": "XRP/USDT", "tADAUST": "ADA/USDT", "tDOGE:UST": "DOGE/USDT",
"tAVAX:UST": "AVAX/USDT", "tDOTUST": "DOT/USDT", "tLINK:UST": "LINK/USDT",
"tLTCUST": "LTC/USDT", "tSHIB:UST": "SHIB/USDT", "tATOUST": "ATOM/USDT",
"tUNIUST": "UNI/USDT", "tSUIUST": "SUI/USDT", "tXLMUST": "XLM/USDT",
}
# Candle settings
CANDLE_TIMEFRAME = "5m"
CANDLE_LIMIT = 100
HTF_TIMEFRAME = "1h"
HTF_CANDLE_LIMIT = 50
# Trading parameters
MIN_ORDER_USDT = 5
MIN_ORDER_AMOUNT = {
"tBTCUST": 0.00004, "tETHUST": 0.0008, "tDOTUST": 0.2,
"tSUIUST": 2.0, "tSOLUST": 0.02, "tLTCUST": 0.04,
"tADAUST": 4.0, "tAVAX:UST": 0.08, "tUNIUST": 0.2,
"tLINK:UST": 0.2, "tXRPUST": 4.0, "tSHIB:UST": 141010.0,
"tDOGE:UST": 22.0, "tATOUST": 0.02, "tXLMUST": 4.0,
}
# ATR-based dynamic stop-loss
ATR_SL_MULTIPLIER = 3.0 # stop = entry - ATR × multiplier
ATR_SL_MIN_PCT = 0.03 # 下限:不低於 3%(低波動期等同現行)
ATR_SL_MAX_PCT = 0.08 # 上限:不超過 8%
STOP_LOSS_PCT = 0.08 # 安全網用上限值(防止交易所 stop 失敗時過早觸發)
TAKE_PROFIT_PCT = 0.15
# LLM SELL profit-tiered thresholds (5 層遞減)
LLM_SELL_MIN_PROFIT_PCT = 0.01 # < 1% 不賣
LLM_SELL_TIERS = [
# (獲利上限, 最低信心)
(0.02, 0.7), # 1-2% 需信心 ≥ 0.7
(0.03, 0.6), # 2-3% 需信心 ≥ 0.6
(0.05, 0.5), # 3-5% 需信心 ≥ 0.5
(None, 0.4), # ≥ 5% 需信心 ≥ 0.4
]
MAX_POSITION_PCT = 0.30 # Max 30% of portfolio per coin
MAX_TOTAL_EXPOSURE_PCT = 1.00 # No cap — use full balance
# Mode
PAPER_TRADING = os.getenv("PAPER_TRADING", "true").lower() == "true"
# Cache
CACHE_DIR = "cache/"
CANDLES_CACHE_DIR = os.path.join(CACHE_DIR, "candles/")
INDICATORS_CACHE_DIR = os.path.join(CACHE_DIR, "indicators/")
# Positions file
POSITIONS_FILE = "positions.json"
# Cost basis sync
COST_TRACKING_FILE = "cost_tracking.json"
INIT_COST_BASIS_START_MS = 1773100800000 # 2026-03-10 00:00:00 UTC
# Schedule
RUN_INTERVAL_MINUTES = 5
STATUS_REPORT_INTERVAL_MINUTES = 60