feat: add trading stats to AI context and one-click deployment data clearing

- Add historical trading statistics to AI decision context with language detection
- Remove win rate from metrics, focus on profit factor, sharpe ratio, win/loss ratio
- Add option to clear trading data tables during one-click deployment
- Add sqlite to Docker runtime for container-based data clearing
This commit is contained in:
tinkle-community
2025-12-28 22:09:47 +08:00
parent d74867c220
commit b228412821
6 changed files with 281 additions and 2 deletions

View File

@@ -469,6 +469,15 @@ func (s *PositionStore) GetPositionStats(traderID string) (map[string]interface{
func (s *PositionStore) GetFullStats(traderID string) (*TraderStats, error) {
stats := &TraderStats{}
// First check how many rows exist
var count int
if err := s.db.QueryRow(`SELECT COUNT(*) FROM trader_positions WHERE trader_id = ? AND status = 'CLOSED'`, traderID).Scan(&count); err == nil {
if count == 0 {
// No closed positions, return empty stats
return stats, nil
}
}
// Query all closed positions
rows, err := s.db.Query(`
SELECT realized_pnl, fee, exit_time