|
@@ -35,7 +35,7 @@ func (strategy qqq) PositionSymbols() map[sentio.Side]string {
|
|
|
}
|
|
|
|
|
|
func (strategy qqq) MaxTradeDuration() time.Duration {
|
|
|
- return time.Duration(strategy.Interval()) * time.Minute * 5
|
|
|
+ return time.Duration(strategy.Interval()) * time.Minute * 3
|
|
|
}
|
|
|
|
|
|
func (strategy qqq) Handle(turn *sentio.Turn, market sentio.Market, rs sentio.RiskManager) error {
|
|
@@ -52,12 +52,12 @@ func (strategy qqq) Handle(turn *sentio.Turn, market sentio.Market, rs sentio.Ri
|
|
|
)
|
|
|
|
|
|
// skip too early orders or late orders
|
|
|
- if (now.Hour() == 9 && now.Minute() < 31) || now.Hour() > 15 {
|
|
|
+ if (now.Hour() == 9 && now.Minute() < 44) || now.Hour() > 15 {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// close all orders before market close
|
|
|
- if now.Hour() == 15 && now.Minute() > 50 {
|
|
|
+ if now.Hour() == 15 && now.Minute() > 45 {
|
|
|
return util.CloseAllOrders(market, strategy)
|
|
|
}
|
|
|
|
|
@@ -80,21 +80,15 @@ func (strategy qqq) Handle(turn *sentio.Turn, market sentio.Market, rs sentio.Ri
|
|
|
shouldClose := false
|
|
|
side := util.SideOf(orders[i].GetIntent())
|
|
|
|
|
|
- if orders[i].GetSymbol() == strategy.PositionSymbols()[sentio.LONG] && sentio.Action_SELL == turn.Action {
|
|
|
- shouldClose = true
|
|
|
- }
|
|
|
-
|
|
|
- if orders[i].GetSymbol() == strategy.PositionSymbols()[sentio.BASE] &&
|
|
|
- sentio.LONG == side && sentio.Action_SELL == turn.Action {
|
|
|
+ if sentio.LONG == side && sentio.Action_SELL == turn.Action {
|
|
|
shouldClose = true
|
|
|
}
|
|
|
|
|
|
- if orders[i].GetSymbol() == strategy.PositionSymbols()[sentio.SHORT] && sentio.Action_BUY == turn.Action {
|
|
|
+ if sentio.SHORT == side && sentio.Action_BUY == turn.Action {
|
|
|
shouldClose = true
|
|
|
}
|
|
|
|
|
|
- if orders[i].GetSymbol() == strategy.PositionSymbols()[sentio.BASE] &&
|
|
|
- sentio.SHORT == side && sentio.Action_BUY == turn.Action {
|
|
|
+ if orders[i].GetCreatedAt().Round(time.Minute).Add(strategy.MaxTradeDuration()).Before(now) {
|
|
|
shouldClose = true
|
|
|
}
|
|
|
|
|
@@ -107,15 +101,6 @@ func (strategy qqq) Handle(turn *sentio.Turn, market sentio.Market, rs sentio.Ri
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- if orders[i].GetCreatedAt().Round(time.Minute).Add(strategy.MaxTradeDuration()).Before(time.Now()) {
|
|
|
- if _, err = market.CloseOrder(orders[i], nil); err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- hasClosedOrders = true
|
|
|
- continue
|
|
|
- }
|
|
|
-
|
|
|
opts := sentio.OrderUpdateOptions{
|
|
|
TakeProfit: rs.TakeProfit(orders[i].GetSymbol(), quotes[orders[i].GetSymbol()].BidPrice),
|
|
|
StopLoss: rs.StopLoss(orders[i].GetSymbol(), quotes[orders[i].GetSymbol()].BidPrice),
|
|
@@ -133,7 +118,7 @@ func (strategy qqq) Handle(turn *sentio.Turn, market sentio.Market, rs sentio.Ri
|
|
|
}
|
|
|
|
|
|
// Prevent BUYs on closing market
|
|
|
- if now.Hour() == 15 && now.Minute() > 45 {
|
|
|
+ if now.Hour() == 15 && now.Minute() > 30 {
|
|
|
return nil
|
|
|
}
|
|
|
|