Files
gogobee/internal/plugin/forex_analysis_test.go
prosolis 1b423b1b16 Add CAD currency, forex cross-pair support, and adventure timer fixes
Forex: add CAD to tracked currencies, add cross-pair syntax (EUR/USD,
EUR|JPY, etc.) for both !fx rate and !fx report with full historical
analysis computed from stored USD-base rates.

Adventure: fix midnight reset silently failing due to SQLite busy
contention with the reminder fire loop — propagate errors so the job
isn't marked complete on failure, add retry with backoff, and add
startup catch-up for missed resets and expired death timers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 23:38:06 -07:00

44 lines
1.1 KiB
Go

package plugin
import (
"math/rand/v2"
"testing"
)
func BenchmarkComputeSignalFromRates(b *testing.B) {
// Simulate 260 trading days of rates around 150 (JPY-like)
rates := make([]float64, 261)
for i := range rates {
rates[i] = 145 + rand.Float64()*10
}
currentRate := rates[len(rates)-1]
b.ResetTimer()
for b.Loop() {
fxComputeSignalFromRates(rates, currentRate)
}
}
func BenchmarkComputeSignalFromRates_CrossPairSize(b *testing.B) {
// Simulate cross-pair: 260 days of EUR/JPY-like rates
baseRates := make([]float64, 260)
quoteRates := make([]float64, 260)
for i := range baseRates {
baseRates[i] = 0.90 + rand.Float64()*0.10 // EUR/USD ~0.90-1.00
quoteRates[i] = 145 + rand.Float64()*10 // JPY/USD ~145-155
}
// Compute cross-rates (simulating the join)
crossRates := make([]float64, len(baseRates)+1)
for i := range baseRates {
crossRates[i] = quoteRates[i] / baseRates[i]
}
crossRates[len(baseRates)] = quoteRates[len(quoteRates)-1] / baseRates[len(baseRates)-1]
currentRate := crossRates[len(crossRates)-1]
b.ResetTimer()
for b.Loop() {
fxComputeSignalFromRates(crossRates, currentRate)
}
}