private void OnTick(TickQuoteCn aReport) { //logger.Info("Ontick:" + aReport.time); // cmds execute by tick; if (aReport.abbrname != "if") { return; } List <int> cmdExecuted = new List <int>(); foreach (KeyValuePair <int, string> pair in cmds) { if (pair.Key < aReport.time) { cmdExecuted.Add(pair.Key); redisClient.PublishMessage(channelName, pair.Value); } } foreach (int cmdrm in cmdExecuted) { cmds.Remove(cmdrm); } }
private void OnTick(TickQuoteCn aReport) { if (!activation) { return; } //logger.Info(orderinfo.userkey + " OnTicks..." + orderinfo.abbrName + "..." + aReport.abbrname); if (String.Compare(orderinfo.abbrName, aReport.abbrname) != 0) { // not bolone to this order return; } if (tracking.orderState == OrderState.WaitingFilled) { checkNonFilledLife(); } if (tracking.orderState == OrderState.Filled) { updateTracking(aReport); protector.check(aReport); daytrade.check(aReport); profitTake.check(aReport); hardstop.check(aReport); } }
private void updateTracking(TickQuoteCn aTick) { if (tracking.orderState == OrderState.Filled) { if (orderinfo.position > 0) { tracking.currentProfit = aTick.trade - tracking.entryPz; } else if (orderinfo.position < 0) { tracking.currentProfit = tracking.entryPz - aTick.trade; } tracking.currentProfitPercent = (tracking.currentProfit / tracking.entryPz); tracking.maxrunup = Math.Max(tracking.maxrunup, tracking.currentProfit); tracking.maxdrawdown = Math.Max(tracking.maxdrawdown, tracking.maxrunup - tracking.currentProfit); tracking.saveOnRedis(); } }
public void check(TickQuoteCn aTick) { if (!isEnable) { return; } if (!hasLogged) { logger.Info("OrderId : " + order.getOrderID() + " : profitTake check enabled"); hasLogged = true; } if (order.getState() == OrderState.Filled) { if (order.getOrderTracking().currentProfitPercent > 0.01 * percentTake) { order.closingOrder("ProfitTake"); } } }
public void check(TickQuoteCn aTick) { if (!isEnable) { return; } if (!hasLogged) { logger.Info("OrderId : " + order.getOrderID() + " : daytrade check enabled"); hasLogged = true; } if (order.getState() == OrderState.Filled) { if (Convert.ToInt32(aTick.time) > daytradeHHMMSS) { order.closingOrder("Daytrade"); } } }
public void check(TickQuoteCn aTick) { if (!isEnable) { return; } if (!hasLogged) { logger.Info("OrderId : " + order.getOrderID() + " : hardstop check enabled"); hasLogged = true; } if (order.getState() == OrderState.Filled) { double currentProfit = order.getOrderTracking().currentProfitPercent; if (currentProfit < (-1 * stoppercent)) { order.closingOrder("HardStop"); } } }
public void check(TickQuoteCn aTick) { if (!isEnable) { return; } if (!hasLogged) { logger.Info("OrderId : " + order.getOrderID() + " : protector check enabled"); hasLogged = true; } double runupPercent = order.getOrderTracking().maxrunup / order.getOrderTracking().entryPz; double drawdownPercent = (order.getOrderTracking().maxrunup - order.getOrderTracking().currentProfit) / order.getOrderTracking().maxrunup; if (runupPercent > runupTriggerPercent) { if (drawdownPercent > drawdownExitPercent) { order.closingOrder("ProfitProtect"); } } }