Files
asepharyana 8c184ccae1 feat: add Citations and WatchlistChat components, integrate with API
- Implemented Citations component to display citation data.
- Created WatchlistDrawer and ChatSidebar components for managing watchlists and AI chat functionality.
- Integrated API calls for watchlist management and chat interactions.
- Updated index.tsx to include new components in the main application layout.
- Added API client in lib/api.ts for structured API interactions.
- Developed Alerts, Dashboard, Portfolio, Routines, Screener, and Report pages with relevant data fetching and UI components.
- Introduced styles in tokens.css for consistent theming across the application.
- Configured TypeScript and Vite for project setup and development.
2026-09-15 12:36:48 +07:00

43 lines
1.1 KiB
Go

package store
import (
"testing"
"time"
)
// ResolveDue: BUY older than 30d resolves against stored closes.
func TestResolveDue(t *testing.T) {
db, err := Open(t.TempDir() + "/acc.db")
if err != nil {
t.Fatal(err)
}
defer db.Close()
old := time.Now().AddDate(0, 0, -40).Format("2006-01-02")
if _, err := db.Exec(`INSERT INTO agent_accuracy(agent,ticker,prediction,predict_date)
VALUES('synthesizer','BBCA','BUY',?)`, old); err != nil {
t.Fatal(err)
}
// Rising closes: first bar 9000 -> last 9950 (+10.5%) => BUY hits.
payload := `[{"date":"` + old + `","close":9000,"volume":1},{"date":"` +
time.Now().Format("2006-01-02") + `","close":9950,"volume":1}]`
if err := db.SaveSnapshot("BBCA", time.Now().Format("2006-01-02"), "daily", payload); err != nil {
t.Fatal(err)
}
n, err := db.ResolveDue()
if err != nil {
t.Fatal(err)
}
if n != 1 {
t.Fatalf("resolved = %d, want 1", n)
}
stats, _ := db.AccuracyStats()
if len(stats) != 1 || stats[0]["hits"] != 1 {
t.Fatalf("stats = %v, want 1 hit", stats)
}
// Second run: nothing due.
n, _ = db.ResolveDue()
if n != 0 {
t.Fatalf("resolved = %d, want 0", n)
}
}