6f846a0a3c
Consume configurable queues, format signals (including period), share NotifyService with HTTP, and drop duplicate bodies within 1h.
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package tradesignal
|
|
|
|
import "time"
|
|
|
|
type Signal struct {
|
|
SignalID string `json:"signalId"`
|
|
SourcePosID string `json:"sourcePosId"`
|
|
StrategyCode string `json:"strategyCode"`
|
|
Symbol string `json:"symbol"`
|
|
Side string `json:"side"`
|
|
Action string `json:"action"`
|
|
Quantity *float64 `json:"quantity"`
|
|
AmountMarginRatio *float64 `json:"amountMarginRatio"`
|
|
PosMarginRatio *float64 `json:"posMarginRatio"`
|
|
Price float64 `json:"price"`
|
|
Leverage int `json:"leverage"`
|
|
Period string `json:"period"`
|
|
EventTime string `json:"eventTime"`
|
|
TakeProfitPrice *float64 `json:"takeProfitPrice"`
|
|
StopLossPrice *float64 `json:"stopLossPrice"`
|
|
TakeProfitRatio *float64 `json:"takeProfitRatio"`
|
|
StopLossRatio *float64 `json:"stopLossRatio"`
|
|
PnL *float64 `json:"pnl"`
|
|
AccountBalance *float64 `json:"accountBalance"`
|
|
}
|
|
|
|
func (s *Signal) ParsedEventTime() time.Time {
|
|
if s.EventTime == "" {
|
|
return time.Now().UTC()
|
|
}
|
|
t, err := time.Parse(time.RFC3339, s.EventTime)
|
|
if err != nil {
|
|
return time.Now().UTC()
|
|
}
|
|
return t
|
|
}
|