public Deal(CIMTDeal cimtDeal, string serverName) { if (cimtDeal == null) { throw new ArgumentNullException(nameof(cimtDeal)); } if (string.IsNullOrWhiteSpace(serverName)) { throw new ArgumentException($"{nameof(serverName)} cannot be null or whitespace."); } DealId = cimtDeal.Deal(); UserId = cimtDeal.Login(); Volume = cimtDeal.Volume(); Action = cimtDeal.Action() <= 1 ? (DealAction)cimtDeal.Action() : DealAction.Unknown; Symbol = cimtDeal.Symbol(); Timestamp = cimtDeal.TimeMsc(); ServerName = serverName; }
public static string FormatDealAction(this CIMTDeal deal) { switch (deal.Action()) { case 0: return("Buy"); case 1: return("Sell"); default: return("Unknown"); } }
private void DealEvents_DealAddEventHandler(object control, CIMTDeal deal) { var info = new RawTradeEvent() { Id = deal.Deal(), Action = deal.Action(), Symbol = deal.Symbol(), Volume = deal.Volume(), TimeMsc = deal.TimeMsc(), Login = deal.Login(), Description = deal.Print() }; _rawTradeEvents.Enqueue(info); Console.WriteLine($"Deal event received ({_connection.Name}): {deal.Print()}"); Console.WriteLine(); }
//+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ private void OnBnClickedButtonGetdeals(object sender = null, EventArgs e = null) { CIMTDealArray deal_array = null; CIMTDeal deal = null; UInt64 login = 0; DateTime from = m_From.Value; DateTime to = m_To.Value; string stype = string.Empty; //--- user login UInt64.TryParse(m_User.Text, out login); //--- get deal array if (!m_manager.GetUserDeal(out deal_array, login, from, to)) { //--- clear list m_List.Items.Clear(); //--- MessageBox.Show("Get user deal fail", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //--- clear list m_List.Items.Clear(); //--- for all deal in array for (uint i = 0; i < deal_array.Total(); i++) { //--- get deal deal = deal_array.Next(i); //--- check error if (deal == null) { break; } //--- check action switch ((CIMTDeal.EnDealAction)deal.Action()) { case CIMTDeal.EnDealAction.DEAL_BALANCE: stype = "Balance"; break; case CIMTDeal.EnDealAction.DEAL_CREDIT: stype = "Credit"; break; case CIMTDeal.EnDealAction.DEAL_CHARGE: stype = "Charge"; break; case CIMTDeal.EnDealAction.DEAL_CORRECTION: stype = "Correction"; break; case CIMTDeal.EnDealAction.DEAL_BONUS: stype = "Bonus"; break; case CIMTDeal.EnDealAction.DEAL_COMMISSION: stype = "Commission"; break; default: //--- skip other actions continue; } //--- string stime = SMTTime.ToDateTime(deal.Time()).ToString("yyyy.MM.dd HH:mm:ss.fff"); //--- insert item string[] row = { deal.Deal().ToString(), stype, deal.Profit().ToString() }; var it = m_List.Items.Insert(0, stime); it.SubItems.AddRange(row); m_List.EnsureVisible(0); m_List.Update(); } }