Initial commit
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
TelegramBotToken string
|
||||
TelegramChatID string
|
||||
AlertCooldownSec int // seconds between alerts for same coin
|
||||
ArbThreshold float64 // minimum net profit % to trigger alert
|
||||
ScanIntervalMs int // how often scanner runs (milliseconds)
|
||||
|
||||
// Automated trading
|
||||
TradeEnabled bool
|
||||
TradeThreshold float64 // minimum profit % to execute trade (>0.15%)
|
||||
TradeAmountUSD float64 // amount per trade in USDT
|
||||
TradeCooldownMs int // ms between trades of same coin
|
||||
|
||||
// Test mode (no real API keys needed)
|
||||
TestMode bool
|
||||
MockSlippagePct float64 // simulated slippage per order (e.g. 0.01 = 0.01%)
|
||||
|
||||
// Bitget API
|
||||
BitgetAPIKey string
|
||||
BitgetAPISecret string
|
||||
BitgetPassphrase string
|
||||
|
||||
// HyperLiquid API
|
||||
HLPrivateKey string // ed25519 private key hex
|
||||
HLAddress string // wallet address
|
||||
}
|
||||
|
||||
func LoadConfig() *Config {
|
||||
getEnv := func(key, def string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return def
|
||||
}
|
||||
getFloat := func(key string, def float64) float64 {
|
||||
v := os.Getenv(key)
|
||||
if v == "" {
|
||||
return def
|
||||
}
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
return def
|
||||
}
|
||||
return f
|
||||
}
|
||||
getBool := func(key string, def bool) bool {
|
||||
v := os.Getenv(key)
|
||||
if v == "" {
|
||||
return def
|
||||
}
|
||||
return v == "1" || v == "true" || v == "yes"
|
||||
}
|
||||
|
||||
return &Config{
|
||||
TelegramBotToken: getEnv("TELEGRAM_BOT_TOKEN", ""),
|
||||
TelegramChatID: getEnv("TELEGRAM_CHAT_ID", ""),
|
||||
AlertCooldownSec: 300,
|
||||
ArbThreshold: 0.03,
|
||||
ScanIntervalMs: 500,
|
||||
|
||||
TradeEnabled: getBool("TRADE_ENABLED", false),
|
||||
TradeThreshold: getFloat("TRADE_THRESHOLD", 0.15),
|
||||
TradeAmountUSD: getFloat("TRADE_AMOUNT_USD", 10),
|
||||
TradeCooldownMs: 30000,
|
||||
|
||||
TestMode: getBool("TEST_MODE", false),
|
||||
MockSlippagePct: getFloat("MOCK_SLIPPAGE_PCT", 0.005),
|
||||
|
||||
BitgetAPIKey: getEnv("BITGET_API_KEY", ""),
|
||||
BitgetAPISecret: getEnv("BITGET_API_SECRET", ""),
|
||||
BitgetPassphrase: getEnv("BITGET_PASSPHRASE", ""),
|
||||
|
||||
HLPrivateKey: getEnv("HL_PRIVATE_KEY", ""),
|
||||
HLAddress: getEnv("HL_ADDRESS", ""),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user