2
0

strategy.go 526 B

12345678910111213141516171819202122232425262728293031
  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. Handle(market Market, proba float64) ([]StrategyOrder, error)
  9. }
  10. type StrategyOrder struct {
  11. Symbol string `yaml:"symbol"`
  12. Action OrderAction `yaml:"action"`
  13. Ratio float64 `yaml:"ratio"`
  14. }
  15. func CompareStrategyOrders(a, b StrategyOrder) int {
  16. if a.Action == b.Action {
  17. return cmp.Compare(b.Ratio, a.Ratio)
  18. }
  19. if OrderSell == a.Action {
  20. return -1
  21. }
  22. return 1
  23. }