public void OnCompleted(CommType Type, bool Success, int lastIndex) { if (Completed != null) { Completed(this, new CompletedEventArgs(Type, Success, lastIndex)); } }
//Sending of new data. public void SendCommand() { commType = CommType.SENDING; if (checkPort()) { return; } singleCommand = ""; dataName = rootDataName; OnComStarted(commType); for (sentCommandIndex = 0; sentCommandIndex < commandsToSend; sentCommandIndex++) { if (CurrentMode == CommMode.MAVLINK && mavlinkWriteCommand(sentCommandIndex)) { return; } else if (CurrentMode == CommMode.CLI && serialWriteCommand(sentCommandIndex)) { return; } } //No commands to send if (MessageCounter == 0) //Have any messages been sent since the global counter was reset? { OnProgressChanged(commType, 0, "Configuration: No changes, nothing to send."); } OnCompleted(commType, true, 0); }
public void OnComStarted(CommType Type) { if (ComStarted != null) { ComStarted(this, new ComStartedEventArgs(Type)); } }
public static char ToFIX(CommType value) { switch (value) { case CommType.PerShare: return('1'); case CommType.Percent: return('2'); case CommType.Absolute: return('3'); case CommType.PctWaivedCshDisc: return('4'); case CommType.PctWaivedEnUnits: return('5'); case CommType.PerBond: return('6'); default: throw new ArgumentException(string.Format("", (object)value)); } }
private void FillGridPriority() { gridPriorities.BeginUpdate(); gridPriorities.ListGridColumns.Clear(); gridPriorities.ListGridColumns.Add(new GridColumn("", 0)); gridPriorities.ListGridRows.Clear(); for (int i = 0; i < _sendOrder.Count; i++) { CommType typeCur = _sendOrder[i]; if (typeCur == CommType.Preferred) { if (checkSendAll.Checked) { //"Preferred" is irrelevant when SendAll is checked. continue; } gridPriorities.AddRow(Lan.g(this, "Preferred Confirm Method")); continue; } if (typeCur == CommType.Text && !SmsPhones.IsIntegratedTextingEnabled()) { gridPriorities.AddRow(Lan.g(this, typeCur.ToString()) + " (" + Lan.g(this, "Not Configured") + ")"); gridPriorities.ListGridRows[gridPriorities.ListGridRows.Count - 1].ColorBackG = Color.LightGray; } else { gridPriorities.AddRow(Lan.g(this, typeCur.ToString())); } } gridPriorities.EndUpdate(); }
//Common GetData entry point void getData() { commType = CommType.RECEIVING; if (checkPort()) { return; } dataName = rootDataName; mavPixReply = ""; if (CurrentMode == CommMode.CLI) { crlfPress(); startTimer(ref waitForPrompt); } else if (CurrentMode == CommMode.MAVLINK) { OnComStarted(commType); if (getAllMavlinkParams) { OnProgressChanged(commType, 0, "Configuration: Fetching Mavlink parameters.."); } else { OnProgressChanged(commType, 0, "Configuration: Fetching " + dataName + ".."); } mavlinkNextParamFetch(); } }
private void AddToList_Click(object sender, EventArgs e) { if (DestNodeName.Text == "") { return; } int[] dat = new int[1]; SourceDataClass.clear(); SourceDataClass.InitForPack(20 + 16); dat[0] = 142; SourceDataClass.OutPutIntBit(dat, 8); dat[0] = 36; SourceDataClass.OutPutIntBit(dat, 12); BitArray a = new BitArray(16); for (int i = 0; i < 16; i++) { a[i] = CommType.GetItemChecked(i); } SourceDataClass.OutPutArrayBit(a); //加入列表 MainForm.pMainForm.comlistwin.AddCmd(DestNodeName.Text, "通信制式开关", SourceDataClass.packdata); MainForm.pMainForm.RefreshListStat(); MessageBox.Show("通信制式开关命令已加入命令列表!"); }
public Site(uint num, string name, string ip, uint port) { this.num = num; this.name = name; this.ip = ip; this.port = port; commType = CommType.Tcp; }
public void EnumFieldTest() { CommType ct = new CommType(CommType.PER_UNIT); Assert.That('1', Is.EqualTo(ct.getValue())); ExecInst ei = new ExecInst(ExecInst.STRICT_LIMIT); Assert.That("b", Is.EqualTo(ei.getValue())); AllocStatus ass = new AllocStatus(AllocStatus.REVERSED); Assert.That(7, Is.EqualTo(ass.getValue())); }
public Site(uint num, string name, ComSetting comSetting) { this.num = num; this.name = name; this.ip = ""; this.port = 12345; this.com = comSetting.com; this.baudRate = comSetting.baudRate; this.dataBits = comSetting.dataBits; this.stopBits = comSetting.stopBits; this.parity = comSetting.parity; commType = CommType.Serial; }
//Just connected, expecting "Press <Enter> 3 times for CLI." message to arrive. // or, if Mavlink is active, wait for heartbeat public void ConnectAndGetPrompt() { commType = CommType.BOOTING; if (checkPort()) { return; } comAttempts = 0; bootCounter = 0; dataName = "prompt/heartbeat"; mavPixReply = ""; startTimer(ref waitForBoot, timeout + 3000); }
//Send a single mavlink parameter public void SendParameter(string Command, float value) { commType = CommType.SINGLE; if (checkPort()) { return; } singleCommand = Command; dataName = Command; mavlinkSingleValue = value; OnComStarted(commType); mavlinkWriteCommand(-1); }
public void OnProgressChanged(CommType Type, int Progress, string Event) { if (Progress < 0) { Progress = 0; //Avoid errors from malformed data } if (Progress > 32) { Progress = 32; } if (ProgressChanged != null) { ProgressChanged(this, new ProgressEventArgs(Type, Progress, Event)); } }
//Just connected, expecting "Press <Enter> 3 times for CLI." message to arrive. //Proceed to collexting data public void ConnectAndGetAllData() { commType = CommType.RECEIVING; if (checkPort()) { return; } comAttempts = 0; bootCounter = 0; readCommandIndex = 0; dataName = DataName; mavPixReply = ""; getAllMavlinkParams = true; initMavlinkParameterReceived(0, mavlinkParameterTotal); startTimer(ref waitForBoot); }
//Send a single command public void SendCommand(string Command, bool ExpectReply) { commType = CommType.SINGLE; if (checkPort()) { return; } singleCommand = Command; dataName = Command; sentCommandIndex = 0; comAttempts = 0; OnComStarted(commType); OnProgressChanged(commType, 0, "Configuration: Sent " + dataName + "."); mavPixReply = ""; serial.WriteLine(Command); if (ExpectReply) { startTimer(ref sendingCommands); } }
public static char ToFIX(CommType value) { switch (value) { case CommType.PerShare: return '1'; case CommType.Percent: return '2'; case CommType.Absolute: return '3'; case CommType.PctWaivedCshDisc: return '4'; case CommType.PctWaivedEnUnits: return '5'; case CommType.PerBond: return '6'; default: throw new ArgumentException(string.Format("", (object) value)); } }
/// <summary> /// 加载通讯选项显示 /// </summary> /// <param name="type"></param> private void LoadCommType(CommType type) { IniSettings.Communication = type; mChangeCommFlag = true; rdbSerial.ForeColor = rdbNet.ForeColor = rdbUsb.ForeColor = Color.Black; switch (IniSettings.Communication) { case CommType.SERIAL: rdbSerial.Checked = true; rdbSerial.ForeColor = Color.Blue; break; case CommType.NET: rdbNet.Checked = true; rdbNet.ForeColor = Color.Blue; break; case CommType.USB: chkAutoConnect.Enabled = true; rdbUsb.Checked = true; rdbUsb.ForeColor = Color.Blue; break; default: break; } grbSerial.Visible = rdbSerial.Checked; grbNet.Visible = rdbNet.Checked; grbUsb.Visible = rdbUsb.Checked; mChangeCommFlag = false; if (!SystemPub.ADRcp.bConnected) { SystemPub.ADRcp.Send("AutoConnectStop"); } }
private void Load(object sender, RoutedEventArgs e) // 页面载入 { if (_Comm == null) // 没有通信接口,从ini读取配置信息 { string DefaultConnectType = _InitializationFile.Read("CONNECT", "TYPE"); if (DefaultConnectType != "") { DefaultConnectType = DefaultConnectType.Substring(0, 1); } switch (DefaultConnectType) // 获取默认连接方式 { case "S": default: _CommType = CommType.COMM_TYPE_SERIAL_PORT; tcType.SelectedIndex = 0; break; case "E": _CommType = CommType.COMM_TYPE_ETHERNET; tcType.SelectedIndex = 1; break; } } else // 存在通信接口直接读取 { tcType.SelectedIndex = (int)_CommType; } BindSPPort(); BindSPBaudRate(); BindSPParity(); BindSPDataBits(); BindSPStopBits(); BindEthProtocol(); BindEthIP(); BindEthPort(); }
/// <summary> /// 解析数据并显示在对话框中,如果shown为真,则同时在对话框的设置项中显示单独数据 /// </summary> /// <param name="ba"></param> private string ParseDataAndDisplay(BitArray ba, bool shown) { MainForm.ParseLock.WaitOne(); SourceDataClass.GetData(ba); int nodeid = SourceDataClass.GetIntValueFromBit(6); int nodetype = SourceDataClass.GetIntValueFromBit(1); int emit = SourceDataClass.GetIntValueFromBit(3); int set1 = SourceDataClass.GetIntValueFromBit(8); int set2 = SourceDataClass.GetIntValueFromBit(8); int energy = SourceDataClass.GetIntValueFromBit(3); Int16 commtype = (short)SourceDataClass.GetIntValueFromBit(16); int n = SourceDataClass.GetIntValueFromBit(28); double lang = 0; if (n >> 27 == 1)//西经 { n &= 0x7ffffff; lang = (double)n / 10000 / 60; lang = -lang; } else//北纬 { n &= 0x7ffffff; lang = (double)n / 10000 / 60; } n = SourceDataClass.GetIntValueFromBit(28); double lat = 0; if (n >> 27 == 1)//南纬 { n &= 0x7ffffff; lat = (double)n / 10000 / 60; lat = -lang; } else//北纬 { n &= 0x7ffffff; lat = (double)n / 10000 / 60; } double depth = SourceDataClass.GetIntValueFromBit(14) * 0.5; SourceDataClass.clear(); MainForm.ParseLock.ReleaseMutex(); if (shown) { NodeNameBox.Text = "节点" + nodeid; Nodetypebox.Text = nodetype == 1?"移动节点":"静态节点"; EmitSet.Value = emit; Set1Box.Text = Enum.GetName(typeof(SourceDataClass.DeviceAddr), set1); Set2Box.Text = Enum.GetName(typeof(SourceDataClass.DeviceAddr), set2); if (energy == 0) { leftenergy.Value = 5; } else if (energy == 1) { leftenergy.Value = 20; } else if (energy == 2) { leftenergy.Value = 35; } else if (energy == 3) { leftenergy.Value = 50; } else if (energy == 4) { leftenergy.Value = 65; } else if (energy == 5) { leftenergy.Value = 80; } else if (energy == 6) { leftenergy.Value = 95; } byte[] b = BitConverter.GetBytes(commtype); BitArray a = new BitArray(b); for (int i = 0; i < 16; i++) { CommType.SetItemChecked(i, false); } for (int i = 0; i < a.Count; i++) { CommType.SetItemChecked(i, a[i]); } Lat.Value = lat; Lang.Value = lang; DepthInput.Value = depth; } return("节点" + nodeid + ":" + ((nodetype == 1) ? " 移动节点" : " 静态节点") + " 换能器数" + emit.ToString() + " " + Enum.GetName(typeof(SourceDataClass.DeviceAddr), set1) + " " + Enum.GetName(typeof(SourceDataClass.DeviceAddr), set2) + " 能量 " + energy.ToString() + " 纬度 " + lat.ToString() + " 经度 " + lang.ToString() + " 深度 " + depth.ToString()); }
protected void EmitFilled(SingleOrder order, double price, int quantity, CommType commType, double commission) { EmitExecutionReport(order, price, quantity, commType, commission); }
//将信息加入下面的列表 private void AddBtn_Click(object sender, EventArgs e) { if (NodeNameBox.Text == "") { return; } try { int[] dat = new int[1]; SourceDataClass.clear(); SourceDataClass.InitForPack(115); dat[0] = int.Parse(NodeNameBox.Text.TrimStart('节', '点')); SourceDataClass.OutPutIntBit(dat, 6); dat[0] = Nodetypebox.Text == "静态节点" ? 0 : 1; SourceDataClass.OutPutIntBit(dat, 1); dat[0] = int.Parse(EmitSet.Text); SourceDataClass.OutPutIntBit(dat, 3); dat[0] = Convert.ToInt32(Enum.Parse(typeof(SourceDataClass.DeviceAddr), Set1Box.Text)); SourceDataClass.OutPutIntBit(dat, 8); dat[0] = Convert.ToInt32(Enum.Parse(typeof(SourceDataClass.DeviceAddr), Set2Box.Text)); SourceDataClass.OutPutIntBit(dat, 8); int energy = int.Parse(leftenergy.Text); if (energy < 5) { dat[0] = 0; } else if ((energy >= 5) && (energy < 20)) { dat[0] = 1; } else if ((energy >= 20) && (energy < 35)) { dat[0] = 2; } else if ((energy >= 35) && (energy < 50)) { dat[0] = 3; } else if ((energy >= 50) && (energy < 65)) { dat[0] = 4; } else if ((energy >= 65) && (energy < 80)) { dat[0] = 5; } else if ((energy >= 80) && (energy < 95)) { dat[0] = 6; } else if ((energy >= 95)) { dat[0] = 7; } SourceDataClass.OutPutIntBit(dat, 3); BitArray a = new BitArray(16); for (int i = 0; i < 16; i++) { a[i] = CommType.GetItemChecked(i); } SourceDataClass.OutPutArrayBit(a); if (Lang.Value < 0) { dat[0] = 0x8ffffff + (int)((double)Math.Abs(Lang.Value) * 60 * 10000); } else { dat[0] = (int)((double)Math.Abs(Lang.Value) * 60 * 10000); } SourceDataClass.OutPutIntBit(dat, 28); if (Lat.Value < 0) { dat[0] = 0x8ffffff + (int)((double)Math.Abs(Lat.Value) * 60 * 10000); } else { dat[0] = (int)((double)Math.Abs(Lat.Value) * 60 * 10000); } SourceDataClass.OutPutIntBit(dat, 28); dat[0] = (int)(DepthInput.Value / 0.5); SourceDataClass.OutPutIntBit(dat, 14); if (NodeInfo.ContainsKey(NodeNameBox.Text)) { NodeInfo.Remove(NodeNameBox.Text); } //加入hash表 NodeInfo.Add(NodeNameBox.Text, SourceDataClass.packdata); //替换之前的记录 string log = ParseDataAndDisplay((BitArray)NodeInfo[NodeNameBox.Text], false); if (nodeinfolist.Items.Count == 0)//第一条记录 { nodeinfolist.Items.Add(log); } for (int i = 0; i < nodeinfolist.Items.Count; i++) { if (CheckListNodeName(i, NodeNameBox.Text)) { nodeinfolist.Items[i] = log; break; } if (i == nodeinfolist.Items.Count - 1)//最后一项也比过了,说明当前列表中没有 { nodeinfolist.Items.Add(log); } } SourceDataClass.clear(); } catch (Exception ex) { SourceDataClass.clear(); MessageBox.Show(ex.Message); } }
public void EmitExecutionReport(SingleOrder order, double price, int quantity, CommType commType, double commission) { OrderRecord record = orderRecords[order]; EmitExecutionReport(record, OrdStatus.Undefined, price, quantity, "", commType, commission); }
private void EmitExecutionReport(OrderRecord record, OrdStatus ordStatus, double lastPx, int lastQty, string text, CommType commType, double commission) { ExecutionReport report = new ExecutionReport { TransactTime = Clock.Now, ClOrdID = record.Order.ClOrdID, OrigClOrdID = record.Order.ClOrdID, OrderID = record.Order.OrderID, Symbol = record.Order.Symbol, SecurityType = record.Order.SecurityType, SecurityExchange = record.Order.SecurityExchange, Currency = record.Order.Currency, CommType = commType, Commission = commission, Side = record.Order.Side, OrdType = record.Order.OrdType, TimeInForce = record.Order.TimeInForce, OrderQty = record.Order.OrderQty, Price = record.Order.Price, StopPx = record.Order.StopPx, LastPx = lastPx, LastQty = lastQty }; if (ordStatus == OrdStatus.Replaced) { report.OrdType = record.Order.ReplaceOrder.ContainsField(EFIXField.OrdType) ? record.Order.ReplaceOrder.OrdType : record.Order.OrdType; report.TimeInForce = record.Order.ReplaceOrder.ContainsField(EFIXField.TimeInForce) ? record.Order.ReplaceOrder.TimeInForce : record.Order.TimeInForce; report.OrderQty = record.Order.ReplaceOrder.ContainsField(EFIXField.OrderQty) ? record.Order.ReplaceOrder.OrderQty : record.Order.OrderQty; report.Price = record.Order.ReplaceOrder.ContainsField(EFIXField.Price) ? record.Order.ReplaceOrder.Price : record.Order.Price; report.StopPx = record.Order.ReplaceOrder.ContainsField(EFIXField.StopPx) ? record.Order.ReplaceOrder.StopPx : record.Order.StopPx; record.LeavesQty = ((int)report.OrderQty) - record.CumQty; } else { report.OrdType = record.Order.OrdType; report.TimeInForce = record.Order.TimeInForce; report.OrderQty = record.Order.OrderQty; report.Price = record.Order.Price; report.StopPx = record.Order.StopPx; } if (ordStatus == OrdStatus.Undefined) { record.AddFill(lastPx, lastQty); if (record.LeavesQty > 0) { ordStatus = OrdStatus.PartiallyFilled; } else { ordStatus = OrdStatus.Filled; } } report.AvgPx = record.AvgPx; report.CumQty = record.CumQty; report.LeavesQty = record.LeavesQty; report.ExecType = GetExecType(ordStatus); report.OrdStatus = ordStatus; report.Text = text; EmitExecutionReport(report); }
public CommissionProvider() { this.fCommType = CommType.PerShare; this.fCommission = 0.0; this.fMinCommission = 0.0; }
/// <summary> /// Creates a new message of the given type and with the given contents. /// </summary> /// <param name="cont">Contents of the message.</param> /// <param name="type">Type of the message.</param> public Message(object cont, CommType type) { Contents = cont; Type = type; }
public TransactionCost(CommType commType, double commission) { this.Set(commType, commission); }
public ComStartedEventArgs(CommType Type) { this.Type = Type; }
/// <summary> /// Converts a CommType to a string. /// </summary> /// <param name="value">A CommType value.</param> /// <returns>The FIX string representation of a CommType.</returns> public static string ConvertTo(CommType enumType) { return((string)CommTypeConverter.toTable[enumType]); }
private void EmitExecutionReport(OrderRecord record, OrdStatus ordStatus, double lastPx, int lastQty, string text, CommType commType, double commission) { ExecutionReport report = new ExecutionReport { TransactTime = Clock.Now, ClOrdID = record.Order.ClOrdID, OrigClOrdID = record.Order.ClOrdID, OrderID = record.Order.OrderID, Symbol = record.Order.Symbol, SecurityType = record.Order.SecurityType, SecurityExchange = record.Order.SecurityExchange, Currency = record.Order.Currency, CommType = commType, Commission = commission, Side = record.Order.Side, OrdType = record.Order.OrdType, TimeInForce = record.Order.TimeInForce, OrderQty = record.Order.OrderQty, Price = record.Order.Price, StopPx = record.Order.StopPx, LastPx = lastPx, LastQty = lastQty }; if (ordStatus == OrdStatus.Replaced) { report.OrdType = record.Order.ReplaceOrder.ContainsField(EFIXField.OrdType) ? record.Order.ReplaceOrder.OrdType : record.Order.OrdType; report.TimeInForce = record.Order.ReplaceOrder.ContainsField(EFIXField.TimeInForce) ? record.Order.ReplaceOrder.TimeInForce : record.Order.TimeInForce; report.OrderQty = record.Order.ReplaceOrder.ContainsField(EFIXField.OrderQty) ? record.Order.ReplaceOrder.OrderQty : record.Order.OrderQty; report.Price = record.Order.ReplaceOrder.ContainsField(EFIXField.Price) ? record.Order.ReplaceOrder.Price : record.Order.Price; report.StopPx = record.Order.ReplaceOrder.ContainsField(EFIXField.StopPx) ? record.Order.ReplaceOrder.StopPx : record.Order.StopPx; record.LeavesQty = ((int)report.OrderQty) - record.CumQty; } else { report.OrdType = record.Order.OrdType; report.TimeInForce = record.Order.TimeInForce; report.OrderQty = record.Order.OrderQty; report.Price = record.Order.Price; report.StopPx = record.Order.StopPx; } if (ordStatus == OrdStatus.Undefined) { record.AddFill(lastPx, lastQty); if (record.LeavesQty > 0) { ordStatus = OrdStatus.PartiallyFilled; } else { ordStatus = OrdStatus.Filled; } } report.AvgPx = record.AvgPx; report.CumQty = record.CumQty; report.LeavesQty = record.LeavesQty; report.ExecType = CTPZQProvider.GetExecType(ordStatus); report.OrdStatus = ordStatus; report.Text = text; EmitExecutionReport(report); }
public void EmitExecutionReport(Order order, double price, int quantity, CommType commType, double commission) { this.EmitExecutionReport(this.orderRecords[order], OrdStatus.Undefined, price, quantity, "", commType, commission); }
public static ApptReminderRule CreateApptReminderRule(long clinicNum, ApptReminderType type, TimeSpan tsPrior, bool isSendAll = true, CommType priority1 = CommType.Preferred, CommType priority2 = CommType.Text, CommType priority3 = CommType.Email, TimeSpan doNotSendWithin = default(TimeSpan), bool isAutoReplyEnabled = true) { ApptReminderRule clinicRule = ApptReminderRules.CreateDefaultReminderRule(type, clinicNum); clinicRule.TSPrior = tsPrior; clinicRule.IsSendAll = isSendAll; clinicRule.SendOrder = string.Join(",", new List <CommType>() { priority1, priority2, priority3 }.Select(x => ((int)x).ToString()).ToArray()); clinicRule.DoNotSendWithin = doNotSendWithin; if (type == ApptReminderType.PatientPortalInvite && clinicNum > 0) { clinicRule.SendOrder = "2"; //Email only clinicRule.IsSendAll = false; if (ClinicPrefs.Upsert(PrefName.PatientPortalInviteEnabled, clinicNum, "1") | ClinicPrefs.Upsert(PrefName.PatientPortalInviteUseDefaults, clinicNum, "0")) { ClinicPrefs.RefreshCache(); } } clinicRule.IsAutoReplyEnabled = isAutoReplyEnabled; ApptReminderRules.Insert(clinicRule); return(clinicRule); }
private void EmitExecutionReport(OrderRecord record, OrdStatus ordStatus, double lastPx, int lastQty, string text, CommType commType, double commission) { FreeQuant.FIX.ExecutionReport report = new FreeQuant.FIX.ExecutionReport(); report.TransactTime = Clock.Now; report.ClOrdID = ((FIXNewOrderSingle) record.Order).ClOrdID; report.OrigClOrdID = ((FIXNewOrderSingle) record.Order).ClOrdID; report.OrderID = record.Order.OrderID; report.Symbol = ((FIXNewOrderSingle) record.Order).Symbol; report.SecurityType = ((FIXNewOrderSingle) record.Order).SecurityType; report.SecurityExchange = ((FIXNewOrderSingle) record.Order).SecurityExchange; report.Currency = ((FIXNewOrderSingle) record.Order).Currency; report.CommType = commType; report.Commission = commission; report.Side = ((NewOrderSingle) record.Order).Side; if (ordStatus == OrdStatus.Replaced) { report.OrdType = record.Order.ReplaceOrder.ContainsField(40) ? record.Order.ReplaceOrder.OrdType : ((NewOrderSingle) record.Order).OrdType; report.TimeInForce = record.Order.ReplaceOrder.ContainsField(59) ? record.Order.ReplaceOrder.TimeInForce : ((NewOrderSingle) record.Order).TimeInForce; report.OrderQty = record.Order.ReplaceOrder.ContainsField(38) ? record.Order.ReplaceOrder.OrderQty : ((FIXNewOrderSingle) record.Order).OrderQty; report.Price = record.Order.ReplaceOrder.ContainsField(44) ? record.Order.ReplaceOrder.Price : ((FIXNewOrderSingle) record.Order).Price; report.StopPx = record.Order.ReplaceOrder.ContainsField(99) ? record.Order.ReplaceOrder.StopPx : ((FIXNewOrderSingle) record.Order).StopPx; record.LeavesQty = (int) report.OrderQty - record.CumQty; } else { report.OrdType = ((NewOrderSingle) record.Order).OrdType; report.TimeInForce = ((NewOrderSingle) record.Order).TimeInForce; report.OrderQty = ((FIXNewOrderSingle) record.Order).OrderQty; report.Price = ((FIXNewOrderSingle) record.Order).Price; report.StopPx = ((FIXNewOrderSingle) record.Order).StopPx; } report.LastPx = lastPx; report.LastQty = (double) lastQty; if (ordStatus == OrdStatus.Undefined) { record.AddFill(lastPx, lastQty); ordStatus = record.LeavesQty <= 0 ? OrdStatus.Filled : OrdStatus.PartiallyFilled; } report.AvgPx = record.AvgPx; report.CumQty = (double) record.CumQty; report.LeavesQty = (double) record.LeavesQty; report.ExecType = this.GetExecType(ordStatus); report.OrdStatus = ordStatus; report.Text = text; this.EmitExecutionReport(report); }
public ProgressEventArgs(CommType Type, int Progress, string Event) { this.Type = Type; this.Progress = Progress; this.Event = Event; }
public void Add(DateTime datetime, Side side, double qty, string symbol, double price, double commission, CommType commType) { Instrument instrument = InstrumentManager.Instruments[symbol]; if (instrument == null) throw new ArgumentException("ddd" + this.Name + symbol); else this.Add(new Transaction(datetime, side, qty, instrument, price, commission, commType)); }
public Transaction(DateTime dateTime, Side side, double qty, Instrument instrument, double price, double commission, CommType commType) : this(dateTime, side, qty, instrument, price) { this.transactionCost.Commission = commission; this.transactionCost.CommType = commType; }
private void EmitExecutionReport(OrderRecord record, OrdStatus ordStatus, double lastPx, int lastQty, string text, CommType commType, double commission) { SmartQuant.FIX.ExecutionReport executionReport = new SmartQuant.FIX.ExecutionReport(); executionReport.TransactTime = Clock.Now; executionReport.ClOrdID = record.Order.ClOrdID; executionReport.OrigClOrdID = record.Order.ClOrdID; executionReport.OrderID = record.Order.OrderID; executionReport.Symbol = record.Order.Symbol; executionReport.SecurityType = record.Order.SecurityType; executionReport.SecurityExchange = record.Order.SecurityExchange; executionReport.Currency = record.Order.Currency; executionReport.CommType = commType; executionReport.Commission = commission; executionReport.Side = record.Order.Side; if (ordStatus == OrdStatus.Replaced) { executionReport.OrdType = (record.Order.ReplaceOrder.ContainsField(40) ? record.Order.ReplaceOrder.OrdType : record.Order.OrdType); executionReport.TimeInForce = (record.Order.ReplaceOrder.ContainsField(59) ? record.Order.ReplaceOrder.TimeInForce : record.Order.TimeInForce); executionReport.OrderQty = (record.Order.ReplaceOrder.ContainsField(38) ? record.Order.ReplaceOrder.OrderQty : record.Order.OrderQty); executionReport.Price = (record.Order.ReplaceOrder.ContainsField(44) ? record.Order.ReplaceOrder.Price : record.Order.Price); executionReport.StopPx = (record.Order.ReplaceOrder.ContainsField(99) ? record.Order.ReplaceOrder.StopPx : record.Order.StopPx); record.LeavesQty = (int)executionReport.OrderQty - record.CumQty; } else { executionReport.OrdType = record.Order.OrdType; executionReport.TimeInForce = record.Order.TimeInForce; executionReport.OrderQty = record.Order.OrderQty; executionReport.Price = record.Order.Price; executionReport.StopPx = record.Order.StopPx; } executionReport.LastPx = lastPx; executionReport.LastQty = (double)lastQty; if (ordStatus == OrdStatus.Undefined) { record.AddFill(lastPx, lastQty); if (record.LeavesQty > 0) { ordStatus = OrdStatus.PartiallyFilled; } else { ordStatus = OrdStatus.Filled; } } executionReport.AvgPx = record.AvgPx; executionReport.CumQty = (double)record.CumQty; executionReport.LeavesQty = (double)record.LeavesQty; executionReport.ExecType = this.GetExecType(ordStatus); executionReport.OrdStatus = ordStatus; executionReport.Text = text; this.EmitExecutionReport(executionReport); }
/// <summary> /// Sets the type of the communication. /// </summary> /// <param name="type">The type.</param> public void SetCommunicationType(CommType type) { this.commType = type; switch (type) { case CommType.Udp: this.CreateUdpChannel(); break; case CommType.Web: this.CreateWebConnection(); break; default: throw new ArgumentOutOfRangeException("type"); } }
public void Add(DateTime datetime, Side side, double qty, Instrument instrument, double price, double commission, CommType commType) { this.Add(new Transaction(datetime, side, qty, instrument, price, commission, commType)); }
public void Set(CommType commType, double commission) { this.commType = commType; this.commission = commission; }
public CompletedEventArgs(CommType Type, bool Success, int LastIndex) { this.Type = Type; this.Success = Success; this.LastIndex = LastIndex; }
public Command(CommType type, string text, string help) { Text = text; Type = type; Help = help; }