internal void SetSellConclusion(string time, double price, int residue) { var key = price.ToString("F2"); if (SellOrder.TryGetValue(key, out uint number)) { if (Residue[number] - residue > 0) { Residue[number] = Residue[number] - residue; return; } if (SellOrder.Remove(key) && Residue.Remove(number)) { if (verify) { statement.Enqueue(new Conclusion { Time = ConvertDateTime(time), Division = string.Concat(sell, conclusion), Price = price.ToString("F2"), OrderNumber = number.ToString("N0") }); } Quantity -= 1; SetConclusion(price); } } }
internal bool SendClearingOrder(string time, uint number) { if (SellOrder.ContainsValue(number) && SellOrder.Remove(SellOrder.First(o => o.Value == number).Key) && Residue.Remove(number)) { if (verify) { statement.Enqueue(new Conclusion { Time = ConvertDateTime(time), Division = string.Concat(sell, cancel), Price = string.Empty, OrderNumber = number.ToString("N0") }); } return(true); } if (BuyOrder.ContainsValue(number) && BuyOrder.Remove(BuyOrder.First(o => o.Value == number).Key) && Residue.Remove(number)) { if (verify) { statement.Enqueue(new Conclusion { Time = ConvertDateTime(time), Division = string.Concat(buy, cancel), Price = string.Empty, OrderNumber = number.ToString("N0") }); } return(true); } return(false); }
internal bool SendCorrectionOrder(string time, string price, uint number, int residue) { if (SellOrder.ContainsValue(number) && SellOrder.Remove(SellOrder.First(o => o.Value == number).Key) && Residue.Remove(number)) { SellOrder[price] = Count; Residue[Count++] = residue; if (verify) { statement.Enqueue(new Conclusion { Time = ConvertDateTime(time), Division = string.Concat(sell, correction), Price = price, OrderNumber = SellOrder[price].ToString("N0") }); } return(true); } if (BuyOrder.ContainsValue(number) && BuyOrder.Remove(BuyOrder.First(o => o.Value == number).Key) && Residue.Remove(number)) { BuyOrder[price] = Count; Residue[Count++] = residue; if (verify) { statement.Enqueue(new Conclusion { Time = ConvertDateTime(time), Division = string.Concat(buy, correction), Price = price, OrderNumber = BuyOrder[price].ToString("N0") }); } return(true); } return(false); }
void OnReceiveChejanData(object sender, _DKHOpenAPIEvents_OnReceiveChejanDataEvent e) { var sb = new StringBuilder(256); var index = int.Parse(e.sGubun); foreach (int fid in catalogReal[index]) { sb.Append(API.GetChejanData(fid)).Append(';'); } var param = sb.ToString().Split(';'); switch (index) { case 0: if (param[3].Equals(Code)) { switch (param[5]) { case "체결": if (param[14].Equals("1") ? SellOrder.Remove(param[1]) : BuyOrder.Remove(param[1])) { OnReceiveBalance = false; } break; case "접수": if (int.Parse(param[11]) == 0) { OnReceiveBalance = request.QueueCount == 0; } break; case "확인": if (param[12].Substring(3).Equals("취소") || param[12].Substring(3).Equals("정정")) { OnReceiveBalance = request.QueueCount == 0; } break; } SendState?.Invoke(this, new State(OnReceiveBalance, SellOrder.Count, Quantity, BuyOrder.Count, ScreenNumber)); } return; case 1: return; case 4: if (param[1].Equals(Code)) { Quantity = param[9].Equals("1") ? -int.Parse(param[4]) : int.Parse(param[4]); AvgPurchase = param[5]; OnReceiveBalance = request.QueueCount == 0; SendState?.Invoke(this, new State(OnReceiveBalance, SellOrder.Count, Quantity, BuyOrder.Count, ScreenNumber)); } return; } }