strategy.go 875 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package util
  2. import (
  3. "git.beejay.kim/Gshopper/sentio"
  4. "strings"
  5. )
  6. func Symbols(strategy sentio.Strategy) []string {
  7. var symbols []string
  8. if strategy == nil {
  9. return nil
  10. }
  11. for side, s := range strategy.PositionSymbols() {
  12. if sentio.BASE == side {
  13. continue
  14. }
  15. symbols = append(symbols, s)
  16. }
  17. return symbols
  18. }
  19. func isOrderPosition(order sentio.Order, strategy sentio.Strategy, position sentio.Side) bool {
  20. symbol, ok := strategy.PositionSymbols()[position]
  21. if !ok {
  22. return false
  23. }
  24. return strings.ToLower(strings.TrimSpace(symbol)) == strings.ToLower(strings.TrimSpace(order.GetSymbol()))
  25. }
  26. func IsLongOrder(order sentio.Order, strategy sentio.Strategy) bool {
  27. return isOrderPosition(order, strategy, sentio.LONG)
  28. }
  29. func IsShortOrder(order sentio.Order, strategy sentio.Strategy) bool {
  30. return isOrderPosition(order, strategy, sentio.SHORT)
  31. }