2
0

strategy.go 607 B

123456789101112131415161718192021222324252627282930313233343536
  1. package sentio
  2. import (
  3. "cmp"
  4. "time"
  5. )
  6. type Strategy interface {
  7. Name() string
  8. Model() string
  9. MarketId() string
  10. PositionSymbols() map[Side]string
  11. Interval() uint8
  12. Cooldown(periods uint8) time.Duration
  13. Handle(market Market, ts time.Time, proba float64) ([]StrategyOrder, error)
  14. }
  15. type StrategyOrder struct {
  16. Symbol string `yaml:"symbol"`
  17. Action OrderAction `yaml:"action"`
  18. Size float64 `yaml:"size"`
  19. }
  20. func CompareStrategyOrders(a, b StrategyOrder) int {
  21. if a.Action == b.Action {
  22. return cmp.Compare(b.Size, a.Size)
  23. }
  24. if OrderSell == a.Action {
  25. return -1
  26. }
  27. return 1
  28. }