strategy.go 544 B

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