better trade endpoints

This commit is contained in:
samantha42
2026-03-25 22:17:19 +01:00
parent d491b9c14c
commit ff7b41e2a8
7 changed files with 51 additions and 26 deletions

View File

@@ -41,13 +41,13 @@ type Trade struct {
}
type AddTradeRequest struct {
TickerId int `json:"ticker_id"`
Shares int `json:"shares"`
Product int `json:"product"`
Type bool `json:"type"`
Price float64 `json:"price"`
Currency string `json:"currency"`
Date time.Time `json:"date"`
TickerId int `json:"ticker_id"`
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"`
}
func (r *AddTradeRequest) Validate() error {
@@ -63,7 +63,7 @@ func (r *AddTradeRequest) Validate() error {
if r.Price <= 0 {
return errors.New("price must be a positive number")
}
if r.Currency == "" {
if r.CurrencyCode != "" {
return errors.New("currency is required")
}
if r.Date.IsZero() {