add Nature method to Record type
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
type Record interface {
|
type Record interface {
|
||||||
Symbol() string
|
Symbol() string
|
||||||
Nature() string
|
Nature() Nature
|
||||||
BrokerCountry() int64
|
BrokerCountry() int64
|
||||||
AssetCountry() int64
|
AssetCountry() int64
|
||||||
Side() Side
|
Side() Side
|
||||||
|
|||||||
@@ -15,20 +15,23 @@ import (
|
|||||||
|
|
||||||
type Record struct {
|
type Record struct {
|
||||||
symbol string
|
symbol string
|
||||||
|
timestamp time.Time
|
||||||
side internal.Side
|
side internal.Side
|
||||||
quantity decimal.Decimal
|
quantity decimal.Decimal
|
||||||
price decimal.Decimal
|
price decimal.Decimal
|
||||||
timestamp time.Time
|
|
||||||
fees decimal.Decimal
|
fees decimal.Decimal
|
||||||
taxes 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 {
|
func (r Record) Symbol() string {
|
||||||
return r.symbol
|
return r.symbol
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Record) Nature() string {
|
func (r Record) Timestamp() time.Time {
|
||||||
return "" // TODO: implement this
|
return r.timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Record) BrokerCountry() int64 {
|
func (r Record) BrokerCountry() int64 {
|
||||||
@@ -51,10 +54,6 @@ func (r Record) Price() decimal.Decimal {
|
|||||||
return r.price
|
return r.price
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Record) Timestamp() time.Time {
|
|
||||||
return r.timestamp
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Record) Fees() decimal.Decimal {
|
func (r Record) Fees() decimal.Decimal {
|
||||||
return r.fees
|
return r.fees
|
||||||
}
|
}
|
||||||
@@ -63,6 +62,10 @@ func (r Record) Taxes() decimal.Decimal {
|
|||||||
return r.taxes
|
return r.taxes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r Record) Nature() internal.Nature {
|
||||||
|
return r.natureGetter()
|
||||||
|
}
|
||||||
|
|
||||||
type RecordReader struct {
|
type RecordReader struct {
|
||||||
reader *csv.Reader
|
reader *csv.Reader
|
||||||
}
|
}
|
||||||
@@ -134,9 +137,9 @@ func (rr RecordReader) ReadRecord(_ context.Context) (internal.Record, error) {
|
|||||||
side: side,
|
side: side,
|
||||||
quantity: qant,
|
quantity: qant,
|
||||||
price: price,
|
price: price,
|
||||||
timestamp: ts,
|
|
||||||
fees: conversionFee,
|
fees: conversionFee,
|
||||||
taxes: stampDutyTax.Add(frenchTxTax),
|
taxes: stampDutyTax.Add(frenchTxTax),
|
||||||
|
timestamp: ts,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user