feat: subscribe to RabbitMQ trade signals and notify by rules

Consume configurable queues, format signals (including period), share NotifyService with HTTP, and drop duplicate bodies within 1h.
This commit is contained in:
2026-08-15 17:34:49 +08:00
parent 1f4fe2fb75
commit 6f846a0a3c
25 changed files with 3129 additions and 114 deletions
+36
View File
@@ -0,0 +1,36 @@
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
}