package model import ( "errors" "time" ) type Position struct { CompanyID int Symbol string CurrencyCode string CurrencyID int Weight float64 CostBasis float64 Shares int } type TradeProduct int const ( StockTrade TradeProduct = iota // 0 OptionCallTrade // 1 OptionPutTrade // 2 CurrencyTrade // 3 BondTrade ) type TradeType bool const ( Buy TradeType = true Sell TradeType = false ) type AddTradeRequest struct { Symbol string `json:"symbol"` Shares int `json:"shares"` Product int `json:"product"` Type bool `json:"type"` Price float64 `json:"price"` CurrencyCode string `json:"currency_code"` Date time.Time `json:"date"` } type Trade struct { Symbol string CurrencyCode string Shares int Product TradeProduct Type TradeType Price float64 Date time.Time } func (r *AddTradeRequest) Validate() error { if r.Symbol == "" { return errors.New("empty SYmbol string") } if r.Shares <= 0 { return errors.New("shares must be a positive integer") } if r.Product < 0 || r.Product > 3 { return errors.New("product must be between 0 and 3") } if r.Price <= 0 { return errors.New("price must be a positive number") } if r.CurrencyCode == "" { return errors.New("currency is required") } if r.Date.IsZero() { return errors.New("date is required") } if r.Date.After(time.Now()) { return errors.New("date cannot be in the future") } return nil } // for now trades and none stock position will not be supported. type Portifolio struct { Positions []Position Trades []Trade }