fix: 删除零成交误判逻辑 + 各种稳定性修复

- 删除: Bitget GetTradeFee 零成交检查(PlaceMarketOrder 成功即成交)
- 修复: GetTradeFee 加 1s 延迟 + 查不到返回 0(用配置估算费兜底)
- 修复: HL InitExchange 在 NewTrader 中提前调用,避免 szDecimals 延迟
- 修复: close_failed 30 次重试上限,超限标记 failed 并清理
- 修复: DB 恢复时校验 Legs 完整性,跳过非法记录
- 修复: checkScaleIn/checkExit nil guard 防 panic
- 修复: config.go 参数调整(手续费、阈值等)
- 移除: scanner.go 中 MEW/USTC 等低流动性币对
- 添加: 更详细的下单日志(szStr、amountUSD、price)
- 添加: bin/ 到 .gitignore
This commit is contained in:
jackyu66git
2026-05-05 00:41:39 +08:00
parent 866f9906b7
commit d01a261828
6 changed files with 104 additions and 30 deletions
+20 -11
View File
@@ -29,6 +29,9 @@ type Config struct {
// Blacklist — stale spread observation
BlacklistDuration time.Duration // how long a coin stays blacklisted (0 = permanent)
// ExcludedCoins — coins to never trade (hard block)
ExcludedCoins []string
// Test mode (no real API keys needed)
TestMode bool
MockSlippagePct float64 // simulated slippage per order (e.g. 0.01 = 0.01%)
@@ -62,18 +65,19 @@ type Config struct {
// jsonConfig maps config.json fields (non-secret defaults checked into git).
type jsonConfig struct {
TestMode bool `json:"test_mode"`
TradeEnabled bool `json:"trade_enabled"`
ArbThreshold float64 `json:"arb_threshold"`
ScanIntervalMs int `json:"scan_interval_ms"`
TradeThreshold float64 `json:"trade_threshold"`
TradeAmountUSD float64 `json:"trade_amount_usd"`
TradeCooldownMs int `json:"trade_cooldown_ms"`
AlertCooldownSec int `json:"alert_cooldown_sec"`
MockSlippagePct float64 `json:"mock_slippage_pct"`
MaxPositions int `json:"max_positions"`
TestMode bool `json:"test_mode"`
TradeEnabled bool `json:"trade_enabled"`
ArbThreshold float64 `json:"arb_threshold"`
ScanIntervalMs int `json:"scan_interval_ms"`
TradeThreshold float64 `json:"trade_threshold"`
TradeAmountUSD float64 `json:"trade_amount_usd"`
TradeCooldownMs int `json:"trade_cooldown_ms"`
AlertCooldownSec int `json:"alert_cooldown_sec"`
MockSlippagePct float64 `json:"mock_slippage_pct"`
MaxPositions int `json:"max_positions"`
BlacklistDuration int `json:"blacklist_duration_sec"`
InitialCapital float64 `json:"initial_capital"`
InitialCapital float64 `json:"initial_capital"`
ExcludedCoins []string `json:"excluded_coins"`
// New: exchange fees
TakerFeeBitget float64 `json:"taker_fee_bitget"`
@@ -152,6 +156,8 @@ func LoadConfig() *Config {
ScaleStepPct: getFloat("SCALE_STEP_PCT", jsonCfg.ScaleStepPct),
ScaleCooldown: time.Duration(getFloat("SCALE_COOLDOWN_SEC", float64(jsonCfg.ScaleCooldownSec))) * time.Second,
ExcludedCoins: jsonCfg.ExcludedCoins,
BitgetAPIKey: getEnv("BITGET_API_KEY", ""),
BitgetAPISecret: getEnv("BITGET_API_SECRET", ""),
BitgetPassphrase: getEnv("BITGET_PASSPHRASE", ""),
@@ -257,6 +263,9 @@ func loadJSONConfig() jsonConfig {
if cfg.ScaleCooldownSec != 0 {
def.ScaleCooldownSec = cfg.ScaleCooldownSec
}
if len(cfg.ExcludedCoins) > 0 {
def.ExcludedCoins = cfg.ExcludedCoins
}
// Boolean fields: zero default is false, so use OR logic
// When JSON has true → true || false = true (override)