package model import "time" type Trade struct { ID int64 `json:"id,omitempty" db:"id"` Account string `json:"account" db:"account" validate:"required"` Symbol string `json:"symbol" db:"symbol" validate:"required,symbol"` Volume float64 `json:"volume" db:"volume" validate:"required,gt=0"` OpenPrice float64 `json:"open" db:"open_price" validate:"required,gt=0"` ClosePrice float64 `json:"close" db:"close_price" validate:"required,gt=0"` Side string `json:"side" db:"side" validate:"required,oneof=buy sell"` CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at"` } // Profit рассчитывает прибыль для сделки. // Этот метод можно добавить сюда для удобства, или он может быть частью логики воркера. func (t *Trade) CalculateProfit() float64 { lot := 100000.0 profit := (t.ClosePrice - t.OpenPrice) * t.Volume * lot if t.Side == "sell" { profit = -profit } return profit }