fourth version
Deploy / Test, build and deploy (push) Failing after 3m7s

This commit is contained in:
2026-06-08 07:36:52 +00:00
parent 52a935b8b4
commit b9efa98758
20 changed files with 824 additions and 91 deletions
+37
View File
@@ -1,12 +1,14 @@
package features
import (
"context"
"testing"
"time"
"github.com/shopspring/decimal"
"overnight-trading-bot/internal/domain"
"overnight-trading-bot/internal/testutil"
"overnight-trading-bot/internal/timeutil"
)
@@ -74,6 +76,41 @@ func TestAverageIntervalVolumeUsesExecutionWindowsAcrossDays(t *testing.T) {
}
}
func TestRecomputeExcludesTradeDateDailyCandle(t *testing.T) {
ctx := context.Background()
repo := testutil.NewMemoryRepository()
start := time.Date(2026, 6, 1, 0, 0, 0, 0, time.UTC)
var candles []domain.Candle
for i := 0; i < 6; i++ {
closePrice := decimal.NewFromInt(100)
if i == 5 {
closePrice = decimal.NewFromInt(100000)
}
candles = append(candles, domain.Candle{
InstrumentUID: "uid",
TradeDate: start.AddDate(0, 0, i),
Open: decimal.NewFromInt(100),
Close: closePrice,
VolumeLots: decimal.NewFromInt(1),
})
}
if err := repo.UpsertDailyCandles(ctx, candles); err != nil {
t.Fatal(err)
}
pipeline := NewPipeline(repo, PipelineConfig{
RollingShort: 2,
RollingLong: 2,
EWMALambda: 0.08,
})
got, err := pipeline.Recompute(ctx, domain.Instrument{InstrumentUID: "uid", Lot: 1}, start.AddDate(0, 0, 5), SpreadResult{})
if err != nil {
t.Fatal(err)
}
if !got.ADV20.Equal(decimal.NewFromInt(100)) {
t.Fatalf("ADV20=%s, want tradeDate candle excluded", got.ADV20)
}
}
func mustTOD(raw string) timeutil.TimeOfDay {
tod, err := timeutil.ParseTimeOfDay(raw)
if err != nil {