rename side to kind

This commit is contained in:
2026-05-16 14:21:14 +01:00
parent d371aca767
commit 5cdccfcdb1
9 changed files with 146 additions and 142 deletions

View File

@@ -16,7 +16,7 @@ type Record interface {
Nature() Nature
BrokerCountry() int64
AssetCountry() int64
Side() Side
Kind() Kind
Price() decimal.Decimal
Quantity() decimal.Decimal
Timestamp() time.Time
@@ -83,9 +83,9 @@ func BuildReport(ctx context.Context, reader RecordReader, writer ReportWriter,
return err
}
if rec.Side().IsBuy() {
if rec.Kind().Is(KindBuy) {
buysCount++
} else {
} else if rec.Kind().Is(KindSell) {
sellsCount++
}
@@ -108,23 +108,23 @@ func BuildReport(ctx context.Context, reader RecordReader, writer ReportWriter,
// processRecord either adds buys to the queue or consumes buys from the queue when processing a
// sell record.
// Selectors are only applied for sells for performance reasons. It's much cheaper to just accumulate
// buys and only actually inspect a record once a sell happens
// Selectors are only applied on sells for performance reasons. It's much cheaper to just accumulate
// buys and only actually inspect a record once a sell happens due to potential network requests to
func processRecord(ctx context.Context, q *FillerQueue, rec Record, sel Selector, writer ReportWriter) error {
slog.Debug("Report: processing record",
slog.String("symbol", rec.Symbol()),
slog.String("side", rec.Side().String()),
slog.String("side", rec.Kind().String()),
)
switch rec.Side() {
case SideBuy:
switch rec.Kind() {
case KindBuy:
q.Push(NewFiller(rec))
case SideSell:
case KindSell:
if !sel(rec) {
slog.Debug("Report: skipping record",
slog.String("symbol", rec.Symbol()),
slog.String("side", rec.Side().String()),
slog.String("side", rec.Kind().String()),
)
return nil
}
@@ -169,7 +169,7 @@ func processRecord(ctx context.Context, q *FillerQueue, rec Record, sel Selector
}
default:
return fmt.Errorf("unknown side: %v", rec.Side())
return fmt.Errorf("unknown side: %v", rec.Kind())
}
return nil