print a pretty table with correct country coder
This commit is contained in:
@@ -10,11 +10,39 @@ import (
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
type Record interface {
|
||||
Symbol() string
|
||||
BrokerCountry() int64
|
||||
AssetCountry() int64
|
||||
Side() Side
|
||||
Price() decimal.Decimal
|
||||
Quantity() decimal.Decimal
|
||||
Timestamp() time.Time
|
||||
Fees() decimal.Decimal
|
||||
Taxes() decimal.Decimal
|
||||
}
|
||||
|
||||
type RecordReader interface {
|
||||
// ReadRecord should return Records until an error is found.
|
||||
ReadRecord(context.Context) (Record, error)
|
||||
}
|
||||
|
||||
type ReportItem struct {
|
||||
Symbol string
|
||||
BrokerCountry int64
|
||||
AssetCountry int64
|
||||
BuyValue decimal.Decimal
|
||||
BuyTimestamp time.Time
|
||||
SellValue decimal.Decimal
|
||||
SellTimestamp time.Time
|
||||
Fees decimal.Decimal
|
||||
Taxes decimal.Decimal
|
||||
}
|
||||
|
||||
func (ri ReportItem) RealisedPnL() decimal.Decimal {
|
||||
return ri.SellValue.Sub(ri.BuyValue)
|
||||
}
|
||||
|
||||
type ReportWriter interface {
|
||||
// ReportWriter writes report items
|
||||
Write(context.Context, ReportItem) error
|
||||
@@ -79,6 +107,9 @@ func processRecord(ctx context.Context, q *FillerQueue, rec Record, writer Repor
|
||||
sellValue := matchedQty.Mul(rec.Price())
|
||||
|
||||
err := writer.Write(ctx, ReportItem{
|
||||
Symbol: rec.Symbol(),
|
||||
BrokerCountry: rec.BrokerCountry(),
|
||||
AssetCountry: rec.AssetCountry(),
|
||||
BuyValue: buyValue,
|
||||
BuyTimestamp: buy.Timestamp(),
|
||||
SellValue: sellValue,
|
||||
@@ -97,16 +128,3 @@ func processRecord(ctx context.Context, q *FillerQueue, rec Record, writer Repor
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type ReportItem struct {
|
||||
BuyValue decimal.Decimal
|
||||
BuyTimestamp time.Time
|
||||
SellValue decimal.Decimal
|
||||
SellTimestamp time.Time
|
||||
Fees decimal.Decimal
|
||||
Taxes decimal.Decimal
|
||||
}
|
||||
|
||||
func (ri ReportItem) RealisedPnL() decimal.Decimal {
|
||||
return ri.SellValue.Sub(ri.BuyValue)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user