add Nature method to Record type

This commit is contained in:
2025-11-24 12:18:38 +00:00
parent 23614d51db
commit 6b5552b559
2 changed files with 12 additions and 9 deletions

View File

@@ -12,7 +12,7 @@ import (
type Record interface {
Symbol() string
Nature() string
Nature() Nature
BrokerCountry() int64
AssetCountry() int64
Side() Side

View File

@@ -15,20 +15,23 @@ import (
type Record struct {
symbol string
timestamp time.Time
side internal.Side
quantity decimal.Decimal
price decimal.Decimal
timestamp time.Time
fees decimal.Decimal
taxes decimal.Decimal
// natureGetter allows us to defer the operation of figuring out the nature to only when/if needed.
natureGetter func() internal.Nature
}
func (r Record) Symbol() string {
return r.symbol
}
func (r Record) Nature() string {
return "" // TODO: implement this
func (r Record) Timestamp() time.Time {
return r.timestamp
}
func (r Record) BrokerCountry() int64 {
@@ -51,10 +54,6 @@ func (r Record) Price() decimal.Decimal {
return r.price
}
func (r Record) Timestamp() time.Time {
return r.timestamp
}
func (r Record) Fees() decimal.Decimal {
return r.fees
}
@@ -63,6 +62,10 @@ func (r Record) Taxes() decimal.Decimal {
return r.taxes
}
func (r Record) Nature() internal.Nature {
return r.natureGetter()
}
type RecordReader struct {
reader *csv.Reader
}
@@ -134,9 +137,9 @@ func (rr RecordReader) ReadRecord(_ context.Context) (internal.Record, error) {
side: side,
quantity: qant,
price: price,
timestamp: ts,
fees: conversionFee,
taxes: stampDutyTax.Add(frenchTxTax),
timestamp: ts,
}, nil
}
}