Phase 1: SQLite persistence layer
- Add modernc.org/sqlite (pure Go, no CGO) - db/ package: trades, orders, config_log tables + CRUD - Trade persistence: every closed trade saved to SQLite - Restart recovery: open positions restored from DB - Automatic migration on startup
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"exchange-monitor/db"
|
||||
"exchange-monitor/exchange"
|
||||
)
|
||||
|
||||
@@ -34,8 +35,16 @@ func main() {
|
||||
store := NewPriceStore()
|
||||
notifier := NewNotifier(cfg.TelegramBotToken, cfg.TelegramChatID)
|
||||
|
||||
// Initialize SQLite database
|
||||
database, err := db.Open("")
|
||||
if err != nil {
|
||||
log.Printf("[DB] Failed to open database: %v", err)
|
||||
} else {
|
||||
defer database.Close()
|
||||
}
|
||||
|
||||
// Initialize trader
|
||||
trader := NewTrader(cfg)
|
||||
trader := NewTrader(cfg, database)
|
||||
if trader.IsConfigured() {
|
||||
modeLabel := trader.ModeLabel()
|
||||
log.Printf("[Trader] %s mode: automated trading ENABLED (threshold >= %.2f%%, $%.0f/trade)",
|
||||
|
||||
Reference in New Issue
Block a user