2
0
Prechádzať zdrojové kódy

RiskManager

- refactoring
Alexey Kim 5 mesiacov pred
rodič
commit
823e67b0c0
2 zmenil súbory, kde vykonal 6 pridanie a 2 odobranie
  1. 1 1
      risk_manager.go
  2. 5 1
      util/order.go

+ 1 - 1
risk_manager.go

@@ -1,7 +1,7 @@
 package sentio
 
 type RiskManager interface {
-	ATR(symbol string) float64
+	EnsureVolatility(symbol string) bool
 	StopLoss(symbol string, current float64) float64
 	TakeProfit(symbol string, current float64) float64
 }

+ 5 - 1
util/order.go

@@ -30,6 +30,10 @@ func CreateOrder(
 		return errors.New("`CreateOrder`: unknown Side for the current strategy")
 	}
 
+	if !rm.EnsureVolatility(symbol) {
+		return sentio.ErrLowVolatility
+	}
+
 	bid = sentio.ToFixed(quotes[symbol].BidPrice, 2)
 	tp = sentio.ToFixed(rm.TakeProfit(symbol, bid), 2)
 	sl = sentio.ToFixed(rm.StopLoss(symbol, bid), 2)
@@ -62,7 +66,7 @@ func CreateOrder(
 		sentio.SHORT == t && stamp.Value < threshold {
 
 		// create a new order
-		if size = uint(math.Floor(account.GetCash() * .8 / bid)); size < 1 {
+		if size = uint(math.Floor(account.GetCash() * .9 / bid)); size < 1 {
 			return sentio.ErrTooSmallOrder
 		}