Przeglądaj źródła

Make reasonable orders

Alexey Kim 20 godzin temu
rodzic
commit
e0371c2b3e
2 zmienionych plików z 3 dodań i 3 usunięć
  1. 1 1
      market.go
  2. 2 2
      util/order.go

+ 1 - 1
market.go

@@ -16,7 +16,7 @@ type Market interface {
 
 
 	CreateOrder(opts OrderOptions) error
 	CreateOrder(opts OrderOptions) error
 	UpdateOrder(orderID string, rm RiskManager) error
 	UpdateOrder(orderID string, rm RiskManager) error
-	CloseOrder(order Order, recommended *float64) (float64, error)
+	CloseOrder(order Order, desiredPrice *float64) (float64, error)
 
 
 	DeletePosition(symbol string) (float64, error)
 	DeletePosition(symbol string) (float64, error)
 
 

+ 2 - 2
util/order.go

@@ -36,14 +36,14 @@ func NewOrder(
 	opts.StopLoss = sentio.ToFixed(rm.StopLoss(opts.Symbol, bid), 2)
 	opts.StopLoss = sentio.ToFixed(rm.StopLoss(opts.Symbol, bid), 2)
 
 
 	// Prevent orders those have too small expected profit
 	// Prevent orders those have too small expected profit
-	if opts.TakeProfit < bid+TradingRange {
+	if opts.TakeProfit < bid*(1+TradingRange) {
 		err = sentio.ErrLowTakeProfit
 		err = sentio.ErrLowTakeProfit
 		return
 		return
 	}
 	}
 
 
 	// Prevent cases when order will be closed ASAP they were opened.
 	// Prevent cases when order will be closed ASAP they were opened.
 	// Also, Alpaca requires at least 0.01 gap against base_price
 	// Also, Alpaca requires at least 0.01 gap against base_price
-	if opts.StopLoss > bid-TradingRange {
+	if opts.StopLoss > bid*(1-TradingRange) {
 		err = sentio.ErrHighStoploss
 		err = sentio.ErrHighStoploss
 		return
 		return
 	}
 	}