private bool DoCheckAndEndOrder(ref VirtualOrder order, TickInfo currentTick) { bool doEndOrder = false; if (currentTick == null) { return(false); } if (order != null) { if (order.Direction > 0) //long { if (currentTick.Close / 100 - order.Price <= -5) //停損 { EndOrder(order.Direction, -1); order = null; doEndOrder = true; return(doEndOrder); } if (currentTick.Close / 100 - order.Price >= 10) //停利 { EndOrder(order.Direction, 1); order = null; doEndOrder = true; return(doEndOrder); } } if (order.Direction < 0) //short { if (order.Price - currentTick.Close / 100 <= -5) //停損 { EndOrder(order.Direction, -1); order = null; doEndOrder = true; return(doEndOrder); } if (order.Price - currentTick.Close / 100 >= 10) //停利 { EndOrder(order.Direction, 1); order = null; doEndOrder = true; return(doEndOrder); } } } else { doEndOrder = false; } return(doEndOrder); }
private void ClearOrder(ref VirtualOrder currentOrder) { int longOrShort = currentOrder.Direction; if (longOrShort > 0) { _apexApi.SendFutureOrder(this._apexSymbol, FutureBuyOrSell.Sell, false, FutureTradeCondition.ROD, FuturePriceType.Limit, (_currentTick.Close / 100) - 100, 10); PostMsg(string.Format("已經到達收盤時間, 多 單 全數出場")); } else { _apexApi.SendFutureOrder(this._apexSymbol, FutureBuyOrSell.Buy, false, FutureTradeCondition.ROD, FuturePriceType.Limit, (_currentTick.Close / 100) + 100, 10); PostMsg(string.Format("已經到達收盤時間, 空 單 全數出場")); } currentOrder = null; }
private void AddOrder(int longOrShort, bool isReverse, StrategyVolHotShot volShot) { if (longOrShort > 0) { if (_currentTick != null) { string orderId = _apexApi.SendFutureOrder(this._apexSymbol, FutureBuyOrSell.Buy, false, FutureTradeCondition.ROD, FuturePriceType.Limit, (_currentTick.Close / 100) + 100, 10); this._currentOrder = new VirtualOrder { OrderId = orderId, Direction = 1, Price = _currentTick.Close / 100 }; if (isReverse) { PostMsg(string.Format("作 一筆 [ 反轉 ] 多 單 {0}, 價位 {1} 15:[ {2}, {3}, {4}] | 10:[ {5}, {6}, {7}] | 5:[ {8}, {9}, {10}] | 3:[ {11}, {12}, {13}] 30:[ {14}, {15}, {16}]", DateTime.Now.ToString("HH:mm:ss"), (_currentTick.Close / 100) + 1, volShot.TradeCountIn15Sec, volShot.TotalVolIn15Sec, volShot.TickGapIn15Sec, volShot.TradeCountIn10Sec, volShot.TotalVolIn10Sec, volShot.TickGapIn10Sec, volShot.TradeCountIn5Sec, volShot.TotalVolIn5Sec, volShot.TickGapIn5Sec, volShot.TradeCountIn3Sec, volShot.TotalVolIn3Sec, volShot.TickGapIn3Sec, volShot.TradeCountIn30Sec, volShot.TotalVolIn30Sec, volShot.TickGapIn30Sec)); } else { PostMsg(string.Format("作 一筆 多 單 {0}, 價位 {1} 15:[ {2}, {3}, {4}] | 10:[ {5}, {6}, {7}] | 5:[ {8}, {9}, {10}] | 3:[ {11}, {12}, {13}] 30:[ {14}, {15}, {16}]", DateTime.Now.ToString("HH:mm:ss"), (_currentTick.Close / 100) + 1, volShot.TradeCountIn15Sec, volShot.TotalVolIn15Sec, volShot.TickGapIn15Sec, volShot.TradeCountIn10Sec, volShot.TotalVolIn10Sec, volShot.TickGapIn10Sec, volShot.TradeCountIn5Sec, volShot.TotalVolIn5Sec, volShot.TickGapIn5Sec, volShot.TradeCountIn3Sec, volShot.TotalVolIn3Sec, volShot.TickGapIn3Sec, volShot.TradeCountIn30Sec, volShot.TotalVolIn30Sec, volShot.TickGapIn30Sec)); } } } else { if (_currentTick != null) { string orderId = _apexApi.SendFutureOrder(this._apexSymbol, FutureBuyOrSell.Sell, false, FutureTradeCondition.ROD, FuturePriceType.Limit, (_currentTick.Close / 100) - 100, 10); this._currentOrder = new VirtualOrder { OrderId = orderId, Direction = -1, Price = _currentTick.Close / 100 }; if (isReverse) { PostMsg(string.Format("作 一筆 [ 反轉 ] 空 單 {0}, 價位 {1} 15:[ {2}, {3}, {4}] | 10:[ {5}, {6}, {7}] | 5:[ {8}, {9}, {10}] | 3:[ {11}, {12}, {13}] 30:[ {14}, {15}, {16}]", DateTime.Now.ToString("HH:mm:ss"), (_currentTick.Close / 100) - 1, volShot.TradeCountIn15Sec, volShot.TotalVolIn15Sec, volShot.TickGapIn15Sec, volShot.TradeCountIn10Sec, volShot.TotalVolIn10Sec, volShot.TickGapIn10Sec, volShot.TradeCountIn5Sec, volShot.TotalVolIn5Sec, volShot.TickGapIn5Sec, volShot.TradeCountIn3Sec, volShot.TotalVolIn3Sec, volShot.TickGapIn3Sec, volShot.TradeCountIn30Sec, volShot.TotalVolIn30Sec, volShot.TickGapIn30Sec)); } else { PostMsg(string.Format("作 一筆 空 單 {0}, 價位 {1} 15:[ {2}, {3}, {4}] | 10:[ {5}, {6}, {7}] | 5:[ {8}, {9}, {10}] | 3:[ {11}, {12}, {13}] 30:[ {14}, {15}, {16}]", DateTime.Now.ToString("HH:mm:ss"), (_currentTick.Close / 100) - 1, volShot.TradeCountIn15Sec, volShot.TotalVolIn15Sec, volShot.TickGapIn15Sec, volShot.TradeCountIn10Sec, volShot.TotalVolIn10Sec, volShot.TickGapIn10Sec, volShot.TradeCountIn5Sec, volShot.TotalVolIn5Sec, volShot.TickGapIn5Sec, volShot.TradeCountIn3Sec, volShot.TotalVolIn3Sec, volShot.TickGapIn3Sec, volShot.TradeCountIn30Sec, volShot.TotalVolIn30Sec, volShot.TickGapIn30Sec)); } } } }