mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 00:52:40 +00:00
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>
This commit is contained in:
43
internal/plugin/forex_analysis_test.go
Normal file
43
internal/plugin/forex_analysis_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user