rename side to kind
This commit is contained in:
@@ -18,7 +18,7 @@ import (
|
||||
type Record struct {
|
||||
symbol string
|
||||
timestamp time.Time
|
||||
side internal.Side
|
||||
side internal.Kind
|
||||
quantity decimal.Decimal
|
||||
price decimal.Decimal
|
||||
fees decimal.Decimal
|
||||
@@ -44,7 +44,7 @@ func (r Record) AssetCountry() int64 {
|
||||
return int64(countries.ByName(r.Symbol()[:2]).Info().Code)
|
||||
}
|
||||
|
||||
func (r Record) Side() internal.Side {
|
||||
func (r Record) Kind() internal.Kind {
|
||||
return r.side
|
||||
}
|
||||
|
||||
@@ -81,10 +81,12 @@ func NewRecordReader(r io.Reader, f *internal.OpenFIGI) *RecordReader {
|
||||
}
|
||||
|
||||
const (
|
||||
MarketBuy = "market buy"
|
||||
MarketSell = "market sell"
|
||||
LimitBuy = "limit buy"
|
||||
LimitSell = "limit sell"
|
||||
MarketBuy = "market buy"
|
||||
MarketSell = "market sell"
|
||||
LimitBuy = "limit buy"
|
||||
LimitSell = "limit sell"
|
||||
StockSplitOpen = "Stock split open"
|
||||
StockSplitClose = "Stock split close"
|
||||
)
|
||||
|
||||
func (rr RecordReader) ReadRecord(ctx context.Context) (internal.Record, error) {
|
||||
@@ -94,13 +96,16 @@ func (rr RecordReader) ReadRecord(ctx context.Context) (internal.Record, error)
|
||||
return Record{}, fmt.Errorf("read record: %w", err)
|
||||
}
|
||||
|
||||
var side internal.Side
|
||||
var side internal.Kind
|
||||
switch strings.ToLower(raw[0]) {
|
||||
case MarketBuy, LimitBuy:
|
||||
side = internal.SideBuy
|
||||
side = internal.KindBuy
|
||||
case MarketSell, LimitSell:
|
||||
side = internal.SideSell
|
||||
case "action", "stock split open", "stock split close":
|
||||
side = internal.KindSell
|
||||
case StockSplitOpen, StockSplitClose:
|
||||
// TODO: emit a special event that triggers a readjustment of unsold stock
|
||||
continue
|
||||
case "action": // TODO: this is the header, there's probably a better way to handle this
|
||||
continue
|
||||
default:
|
||||
return Record{}, fmt.Errorf("parse record type: %s", raw[0])
|
||||
|
||||
Reference in New Issue
Block a user