third version

This commit is contained in:
2026-06-08 07:05:01 +00:00
parent 282c841e11
commit 52a935b8b4
20 changed files with 1371 additions and 151 deletions
+34
View File
@@ -5,6 +5,12 @@ import (
"context"
"strings"
"testing"
"github.com/shopspring/decimal"
"overnight-trading-bot/internal/domain"
"overnight-trading-bot/internal/testutil"
"overnight-trading-bot/internal/tinvest"
)
func TestRunRequiresAppMode(t *testing.T) {
@@ -29,3 +35,31 @@ func TestRunBacktestModeWithoutDB(t *testing.T) {
t.Fatalf("unexpected stdout: %s", stdout.String())
}
}
func TestSeedPaperGatewayMakesSeedInstrumentsDiscoverable(t *testing.T) {
ctx := context.Background()
repo := testutil.NewMemoryRepository()
if err := repo.UpsertInstrument(ctx, domain.Instrument{
InstrumentUID: "PENDING:TRUR",
Ticker: "TRUR",
ClassCode: "TQTF",
Name: "TRUR",
Lot: 1,
MinPriceIncrement: decimal.RequireFromString("0.0001"),
Currency: "RUB",
Enabled: true,
}); err != nil {
t.Fatal(err)
}
gateway := tinvest.NewFakeGateway()
if err := seedPaperGateway(ctx, repo, gateway); err != nil {
t.Fatal(err)
}
instrument, err := gateway.GetInstrument(ctx, "TRUR", "TQTF")
if err != nil {
t.Fatal(err)
}
if !instrument.MetadataValid() || strings.HasPrefix(instrument.InstrumentUID, "PENDING:") {
t.Fatalf("instrument was not made runnable for paper: %+v", instrument)
}
}