mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +00:00
Mechanical `gofmt -w ./internal ./cmd`. Mostly struct-field realignment that had drifted, plus a few trailing-newline fixes. No behaviour change — gofmt is semantics-preserving, and build/vet/test are green either side. Split out from the code-review fixes that follow so those stay reviewable instead of hiding inside a wall of realignment.
44 lines
1.1 KiB
Go
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)
|
|
}
|
|
}
|