-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
64 lines (52 loc) · 1.43 KB
/
Copy pathconfig.go
File metadata and controls
64 lines (52 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"fmt"
"os"
"strconv"
"sync"
"github.com/joho/godotenv"
)
var (
APIKey string
APISecret string
IsDryRun bool
InitialInvestment float64
Threshold float64
MinEthAmount float64
DiscordWebhookURL string
TargetAssets = map[string]float64{
"THB": 50.0,
"ETH": 50.0,
}
)
var ConfigMutex sync.RWMutex
func init() {
if err := godotenv.Load(); err != nil {
fmt.Println("❌ Warning: No .env file found or failed to load. Using system environment/defaults.")
}
APIKey = os.Getenv("BITKUB_API_KEY")
APISecret = os.Getenv("BITKUB_API_SECRET")
DiscordWebhookURL = os.Getenv("DISCORD_WEBHOOK_URL")
if APIKey == "" || APISecret == "" {
fmt.Println("❌ CRITICAL: BITKUB_API_KEY or SECRET is missing. Trading will fail.")
}
IsDryRun, _ = strconv.ParseBool(os.Getenv("BOT_IS_DRY_RUN"))
if val, err := strconv.ParseFloat(os.Getenv("BOT_INITIAL_INVESTMENT"), 64); err == nil {
InitialInvestment = val
}
if val, err := strconv.ParseFloat(os.Getenv("BOT_THRESHOLD"), 64); err == nil {
Threshold = val
}
if val, err := strconv.ParseFloat(os.Getenv("BOT_MIN_ETH_AMOUNT"), 64); err == nil {
MinEthAmount = val
}
fmt.Printf("✅ Config loaded. Mode: %s, Initial Inv: %.2f THB\n",
func() string {
if IsDryRun {
return "DRY_RUN"
} else {
return "PRODUCTION"
}
}(),
InitialInvestment)
}