|
@@ -1,6 +1,9 @@
|
|
|
package util
|
|
|
|
|
|
-import "git.beejay.kim/Gshopper/sentio"
|
|
|
+import (
|
|
|
+ "git.beejay.kim/Gshopper/sentio"
|
|
|
+ "strings"
|
|
|
+)
|
|
|
|
|
|
func Symbols(strategy sentio.Strategy) []string {
|
|
|
var symbols []string
|
|
@@ -19,3 +22,20 @@ func Symbols(strategy sentio.Strategy) []string {
|
|
|
|
|
|
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)
|
|
|
+}
|