1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package util
- import (
- "git.beejay.kim/Gshopper/sentio"
- "strings"
- )
- func Symbols(strategy sentio.Strategy) []string {
- var symbols []string
- if strategy == nil {
- return nil
- }
- for side, s := range strategy.PositionSymbols() {
- if sentio.BASE == side {
- continue
- }
- symbols = append(symbols, s)
- }
- return symbols
- }
- func isOrderPosition(order sentio.Order, strategy sentio.Strategy, position sentio.Side) bool {
- symbol, ok := strategy.PositionSymbols()[position]
- if !ok {
- return false
- }
- return strings.ToLower(strings.TrimSpace(symbol)) == strings.ToLower(strings.TrimSpace(order.GetSymbol()))
- }
- func IsLongOrder(order sentio.Order, strategy sentio.Strategy) bool {
- return isOrderPosition(order, strategy, sentio.LONG)
- }
- func IsShortOrder(order sentio.Order, strategy sentio.Strategy) bool {
- return isOrderPosition(order, strategy, sentio.SHORT)
- }
|