/// <summary> /// Creates an XML Element representing a placment in the execution document. /// </summary> /// <param name="xmlDocument">The destination XML document.</param> /// <param name="execution">A execution record.</param> public LocalExecutionElement(XmlDocument xmlDocument, ExecutionSet.ExecutionRow executionRow) : base("LocalExecution", xmlDocument) { // Broker field if (!executionRow.IsBrokerIdNull()) { AddAttribute("BrokerId", executionRow.BrokerId.ToString()); ClientMarketData.BrokerRow brokerRow = ClientMarketData.Broker.FindByBrokerId(executionRow.BrokerId); if (brokerRow != null) { AddAttribute("BrokerId", brokerRow.BrokerId.ToString()); AddAttribute("BrokerName", brokerRow.ObjectRow.Name); AddAttribute("BrokerSymbol", brokerRow.Symbol); if (!brokerRow.IsPhoneNull()) { AddAttribute("BrokerPhone", brokerRow.Phone); } } } // Add the attributes of a execution to this record. AddAttribute("ExecutionId", executionRow.ExecutionId.ToString()); AddAttribute("Quantity", executionRow.Quantity.ToString()); AddAttribute("Price", executionRow.Price.ToString()); AddAttribute("Commission", executionRow.Commission.ToString()); AddAttribute("AccruedInterest", executionRow.AccruedInterest.ToString()); AddAttribute("UserFee0", executionRow.UserFee0.ToString()); AddAttribute("UserFee1", executionRow.UserFee1.ToString()); AddAttribute("UserFee2", executionRow.UserFee2.ToString()); AddAttribute("UserFee3", executionRow.UserFee3.ToString()); AddAttribute("TradeDate", executionRow.TradeDate.ToString("s")); AddAttribute("SettlementDate", executionRow.SettlementDate.ToString("s")); }
/// <summary> /// Shows a property dialog for managing collections of traders. /// </summary> /// <param name="customer">A customer.</param> public void Show(Broker customer) { try { // Lock the tables needed for the dialog. Debug.Assert(!ClientMarketData.IsLocked); ClientMarketData.BlotterLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.BrokerLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.ObjectLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.TypeLock.AcquireReaderLock(CommonTimeout.LockWait); ClientMarketData.SourceLock.AcquireReaderLock(CommonTimeout.LockWait); // Find the customer in the data model. ClientMarketData.BrokerRow brokerRow = ClientMarketData.Broker.FindByBrokerId(customer.BrokerId); if (brokerRow == null) { throw new Exception("Some else has deleted this customer."); } // Fill in the 'General' tab with the generic information. this.textBoxName.Text = brokerRow.SourceRow.BlotterRow.ObjectRow.Name; this.labelTypeText.Text = brokerRow.SourceRow.BlotterRow.ObjectRow.TypeRow.Description; this.textBoxDescription.Text = (brokerRow.SourceRow.BlotterRow.ObjectRow.IsDescriptionNull()) ? "" : brokerRow.SourceRow.BlotterRow.ObjectRow.Description; this.pictureBox.Image = customer.Image32x32; } finally { // Release the tables. if (ClientMarketData.BlotterLock.IsReaderLockHeld) { ClientMarketData.BlotterLock.ReleaseReaderLock(); } if (ClientMarketData.BrokerLock.IsReaderLockHeld) { ClientMarketData.BrokerLock.ReleaseReaderLock(); } if (ClientMarketData.ObjectLock.IsReaderLockHeld) { ClientMarketData.ObjectLock.ReleaseReaderLock(); } if (ClientMarketData.TypeLock.IsReaderLockHeld) { ClientMarketData.TypeLock.ReleaseReaderLock(); } if (ClientMarketData.SourceLock.IsReaderLockHeld) { ClientMarketData.SourceLock.ReleaseReaderLock(); } Debug.Assert(!ClientMarketData.IsLocked); } // Display the dialog. this.ShowDialog(); }
/// <summary> /// Creates an XML Element representing a broker in a execution document. /// </summary> /// <param name="xmlDocument">The destination XML document.</param> /// <param name="brokerRow">A broker record.</param> public BrokersElement(XmlDocument xmlDocument, ClientMarketData.BrokerRow brokerRow) : base("Broker", xmlDocument) { // Add the attributes of a broker to this record. AddAttribute("BrokerId", brokerRow.BrokerId.ToString()); AddAttribute("BrokerName", brokerRow.ObjectRow.Name); AddAttribute("BrokerSymbol", brokerRow.Symbol); if (!brokerRow.IsPhoneNull()) { AddAttribute("BrokerPhone", brokerRow.Phone); } }
/// <summary> /// Initializes a Broker. /// </summary> /// <param name="configurationId">Defines which external fields are used to identify an object.</param> /// <param name="brokerId">The broker identifier.</param> /// <returns>A broker record, null if the identifier doesn't exist.</returns> protected override void Initialize(int brokerId) { // Use the specified configuration to find the internal broker identifier. ClientMarketData.BrokerRow brokerRow = ClientMarketData.Broker.FindByBrokerId(brokerId); if (brokerRow == null) { throw new Exception(String.Format("Broker {0} doesn't exist", brokerId)); } // Initialize the base class. base.Initialize(brokerId); // Initialize the record from the data model. this.symbol = brokerRow.Symbol; }
/// <summary> /// Creates a denormalized order record from a global record. /// </summary> /// <param name="globalOrder"></param> /// <returns></returns> public static OrderSet.OrderRow Create(ClientMarketData.OrderRow globalOrder) { // Create a new order record from the record factory. OrderSet.OrderRow orderRow = orderSet.Order.NewOrderRow(); // These records are global and use the global system of identifiers. orderRow.IsLocal = false; // Copy each field that has an analog in the local record set into the new record. foreach (DataColumn dataColumn in globalOrder.Table.Columns) { orderRow[dataColumn.ColumnName] = globalOrder[dataColumn]; } // AccountId cross-referenced data is filled in here. orderRow.AccountMnemonic = globalOrder.AccountRow.Mnemonic; orderRow.AccountName = globalOrder.AccountRow.ObjectRow.Name; // SecurityId cross-referenced data is filled in here. orderRow.SecuritySymbol = globalOrder.SecurityRowByFKSecurityOrderSecurityId.Symbol; orderRow.SecurityName = globalOrder.SecurityRowByFKSecurityOrderSecurityId.ObjectRow.Name; // CurrencyId cross-referenced data is filled in here. orderRow.SettlementSymbol = globalOrder.SecurityRowByFKSecurityOrderSettlementId.Symbol; orderRow.SettlementName = globalOrder.SecurityRowByFKSecurityOrderSettlementId.ObjectRow.Name; // BrokerId cross-referenced data is filled in here. if (!globalOrder.IsBrokerIdNull()) { ClientMarketData.BrokerRow brokerRow = ClientMarketData.Broker.FindByBrokerId(globalOrder.BrokerId); if (brokerRow != null) { orderRow.BrokerSymbol = brokerRow.Symbol; orderRow.BrokerName = brokerRow.ObjectRow.Name; } } // TimeInForce cross-referenced data is filled in here. orderRow.TimeInForceMnemonic = globalOrder.TimeInForceRow.Mnemonic; // TimeInForce cross-referenced data is filled in here. orderRow.OrderTypeMnemonic = globalOrder.OrderTypeRow.Mnemonic; // This is a complete record of the order, including the referenced data. return(orderRow); }
/// <summary> /// Creates an XML Element representing a placment in the execution document. /// </summary> /// <param name="xmlDocument">The destination XML document.</param> /// <param name="executionRow">A execution record.</param> public GlobalExecutionElement(XmlDocument xmlDocument, ClientMarketData.ExecutionRow executionRow) : base("GlobalExecution", xmlDocument) { // Add the attributes of a broker to this record. ClientMarketData.BrokerRow brokerRow = executionRow.BrokerRow; AddAttribute("BrokerId", brokerRow.BrokerId.ToString()); AddAttribute("BrokerName", brokerRow.ObjectRow.Name); AddAttribute("BrokerSymbol", brokerRow.Symbol); // Add the attributes of a execution to this record. AddAttribute("ExecutionId", executionRow.ExecutionId.ToString()); AddAttribute("Quantity", executionRow.Quantity.ToString()); AddAttribute("Price", executionRow.Price.ToString()); AddAttribute("Commission", executionRow.Commission.ToString()); AddAttribute("AccruedInterest", executionRow.AccruedInterest.ToString()); AddAttribute("UserFee0", executionRow.UserFee0.ToString()); AddAttribute("UserFee1", executionRow.UserFee1.ToString()); AddAttribute("UserFee2", executionRow.UserFee2.ToString()); AddAttribute("UserFee3", executionRow.UserFee3.ToString()); AddAttribute("TradeDate", executionRow.TradeDate.ToString("s")); AddAttribute("SettlementDate", executionRow.SettlementDate.ToString("s")); if (!executionRow.IsCreatedTimeNull()) { AddAttribute("CreatedTime", executionRow.CreatedTime.ToString("s")); } if (!executionRow.IsCreatedLoginIdNull()) { AddAttribute("CreatedLoginId", executionRow.CreatedLoginId.ToString()); AddAttribute("CreatedLoginName", executionRow.LoginRowByFKLoginExecutionCreatedLoginId.ObjectRow.Name); } if (!executionRow.IsModifiedTimeNull()) { AddAttribute("ModifiedTime", executionRow.ModifiedTime.ToString("s")); } if (!executionRow.IsModifiedLoginIdNull()) { AddAttribute("ModifiedLoginId", executionRow.ModifiedLoginId.ToString()); AddAttribute("ModifiedLoginName", executionRow.LoginRowByFKLoginExecutionModifiedLoginId.ObjectRow.Name); } }
public LocalExecution(ExecutionSet.ExecutionRow executionRow) { this.isLocal = true; // Initialize the members. this.rowVersion = executionRow.RowVersion; this.blockOrderId = executionRow.BlockOrderId; if (!executionRow.IsBrokerIdNull()) { this.brokerId = executionRow.BrokerId; ClientMarketData.BrokerRow brokerRow = ClientMarketData.Broker.FindByBrokerId(executionRow.BrokerId); if (brokerRow != null) { this.brokerSymbol = brokerRow.Symbol; this.brokerName = brokerRow.ObjectRow.Name; } } this.executionId = executionRow.ExecutionId; this.quantity = executionRow.Quantity; this.price = executionRow.Price; this.commission = executionRow.Commission; this.accruedInterest = executionRow.AccruedInterest; this.userFee0 = executionRow.UserFee0; this.userFee1 = executionRow.UserFee1; this.userFee2 = executionRow.UserFee2; this.userFee3 = executionRow.UserFee3; if (!executionRow.IsTradeDateNull()) { this.tradeDate = executionRow.TradeDate; } if (!executionRow.IsSettlementDateNull()) { this.settlementDate = executionRow.SettlementDate; } }
/// <summary> /// Creates an XML Element representing a placment in the order document. /// </summary> /// <param name="xmlDocument">The destination XML document.</param> /// <param name="orderRow">A order record.</param> public LocalOrderElement(XmlDocument xmlDocument, LocalOrderSet.OrderRow orderRow) : base("LocalOrder", xmlDocument) { // Add the attributes of a order to this record. AddAttribute("OrderId", orderRow.OrderId.ToString()); // Account field if (!orderRow.IsAccountIdNull()) { AddAttribute("AccountId", orderRow.AccountId.ToString()); ClientMarketData.AccountRow accountRow = ClientMarketData.Account.FindByAccountId(orderRow.AccountId); if (accountRow != null) { AddAttribute("AccountId", accountRow.AccountId.ToString()); AddAttribute("AccountName", accountRow.ObjectRow.Name); AddAttribute("AccountMnemonic", accountRow.Mnemonic); } } // Security field if (!orderRow.IsSecurityIdNull()) { AddAttribute("SecurityId", orderRow.SecurityId.ToString()); ClientMarketData.SecurityRow securityRow = ClientMarketData.Security.FindBySecurityId(orderRow.SecurityId); if (securityRow != null) { AddAttribute("SecurityId", securityRow.SecurityId.ToString()); AddAttribute("SecurityName", securityRow.ObjectRow.Name); AddAttribute("SecuritySymbol", securityRow.Symbol); } } // Broker field if (!orderRow.IsBrokerIdNull()) { AddAttribute("BrokerId", orderRow.BrokerId.ToString()); ClientMarketData.BrokerRow brokerRow = ClientMarketData.Broker.FindByBrokerId(orderRow.BrokerId); if (brokerRow != null) { AddAttribute("BrokerId", brokerRow.BrokerId.ToString()); AddAttribute("BrokerName", brokerRow.ObjectRow.Name); AddAttribute("BrokerSymbol", brokerRow.Symbol); if (!brokerRow.IsPhoneNull()) { AddAttribute("BrokerPhone", brokerRow.Phone); } } } // TransactionType field if (!orderRow.IsTransactionTypeCodeNull()) { AddAttribute("TransactionTypeCode", orderRow.TransactionTypeCode.ToString()); ClientMarketData.TransactionTypeRow transactionTypeRow = ClientMarketData.TransactionType.FindByTransactionTypeCode(orderRow.TransactionTypeCode); if (transactionTypeRow != null) { AddAttribute("TransactionTypeMnemonic", transactionTypeRow.Mnemonic); } } // TimeInForce field if (!orderRow.IsTimeInForceCodeNull()) { AddAttribute("TimeInForceCode", orderRow.TimeInForceCode.ToString()); ClientMarketData.TimeInForceRow timeInForceRow = ClientMarketData.TimeInForce.FindByTimeInForceCode(orderRow.TimeInForceCode); if (timeInForceRow != null) { AddAttribute("TimeInForceMnemonic", timeInForceRow.Mnemonic); } } // OrderType field if (!orderRow.IsOrderTypeCodeNull()) { AddAttribute("OrderTypeCode", orderRow.OrderTypeCode.ToString()); ClientMarketData.OrderTypeRow orderTypeRow = ClientMarketData.OrderType.FindByOrderTypeCode(orderRow.OrderTypeCode); if (orderTypeRow != null) { AddAttribute("OrderTypeMnemonic", orderTypeRow.Mnemonic); } } if (!orderRow.IsQuantityNull()) { AddAttribute("Quantity", orderRow.Quantity.ToString()); } if (!orderRow.IsPrice1Null()) { AddAttribute("Price1", orderRow.Price1.ToString()); } if (!orderRow.IsPrice2Null()) { AddAttribute("Price2", orderRow.Price2.ToString()); } }
/// <summary> /// Creates a broker element for the TicketDocument /// </summary> /// <param name="brokerRow">A Broker record</param> /// <returns>An element that represents a broker.</returns> public BrokersElement CreateBrokersElement(ClientMarketData.BrokerRow brokerRow) { return(new BrokersElement(this, brokerRow)); }
/// <summary> /// Creates an XML Element representing a placment in the placement document. /// </summary> /// <param name="xmlDocument">The destination XML document.</param> /// <param name="placementRow">A placement record.</param> public PlacementElement(XmlDocument xmlDocument, PlacementSet.PlacementRow placementRow) : base("Placement", xmlDocument) { // This is the primary identifier for the record. AddAttribute("PlacementId", placementRow.LocalPlacementId.ToString()); // Broker field if (!placementRow.IsBrokerIdNull()) { ClientMarketData.BrokerRow brokerRow = ClientMarketData.Broker.FindByBrokerId(placementRow.BrokerId); if (brokerRow != null) { AddAttribute("BrokerId", brokerRow.BrokerId.ToString()); AddAttribute("BrokerName", brokerRow.ObjectRow.Name); AddAttribute("BrokerSymbol", brokerRow.Symbol); } } // TimeInForce field if (!placementRow.IsTimeInForceCodeNull()) { ClientMarketData.TimeInForceRow timeInForceRow = ClientMarketData.TimeInForce.FindByTimeInForceCode(placementRow.TimeInForceCode); if (timeInForceRow != null) { AddAttribute("TimeInForceCode", placementRow.TimeInForceCode.ToString()); AddAttribute("TimeInForceMnemonic", timeInForceRow.Mnemonic); } } // OrderType field if (!placementRow.IsOrderTypeCodeNull()) { ClientMarketData.OrderTypeRow orderTypeRow = ClientMarketData.OrderType.FindByOrderTypeCode(placementRow.OrderTypeCode); if (orderTypeRow != null) { AddAttribute("OrderTypeCode", placementRow.OrderTypeCode.ToString()); AddAttribute("OrderTypeMnemonic", orderTypeRow.Mnemonic); } } // Quantity if (!placementRow.IsQuantityNull()) { AddAttribute("Quantity", placementRow.Quantity.ToString()); } // Price 1 if (!placementRow.IsPrice1Null()) { AddAttribute("Price1", placementRow.Price1.ToString()); } // Price 2 if (!placementRow.IsPrice2Null()) { AddAttribute("Price2", placementRow.Price2.ToString()); } // Created Time if (!placementRow.IsCreatedTimeNull()) { AddAttribute("CreatedTime", placementRow.CreatedTime.ToString("s")); } // Created Login if (!placementRow.IsCreatedLoginIdNull()) { ClientMarketData.LoginRow createdLoginRow = ClientMarketData.Login.FindByLoginId(placementRow.CreatedLoginId); if (createdLoginRow != null) { AddAttribute("CreatedLoginId", createdLoginRow.LoginId.ToString()); AddAttribute("CreatedLoginName", createdLoginRow.ObjectRow.Name); } } // Modified Time if (!placementRow.IsModifiedTimeNull()) { AddAttribute("ModifiedTime", placementRow.ModifiedTime.ToString("s")); } // Modified Login if (!placementRow.IsModifiedLoginIdNull()) { ClientMarketData.LoginRow modifiedLoginRow = ClientMarketData.Login.FindByLoginId(placementRow.ModifiedLoginId); if (modifiedLoginRow != null) { AddAttribute("ModifiedLoginId", modifiedLoginRow.LoginId.ToString()); AddAttribute("ModifiedLoginName", modifiedLoginRow.ObjectRow.Name); } } }
/// <summary> /// Creates a denormalized order record from a local record. /// </summary> /// <param name="localOrder">A local order record.</param> /// <returns>A order record that is independant of the global data set for all the anscillary data.</returns> public static OrderSet.OrderRow Create(LocalOrderSet.OrderRow localOrder) { // Create a new, empty order record. OrderSet.OrderRow orderRow = orderSet.Order.NewOrderRow(); // This new record is a copy of a local record and uses the local system of identifiers. orderRow.IsLocal = true; // Copy each field that has an analog in the local record set into the new record. foreach (DataColumn dataColumn in localOrder.Table.Columns) { orderRow[dataColumn.ColumnName] = localOrder[dataColumn]; } // AccountId cross-referenced data is filled in here. if (!localOrder.IsAccountIdNull()) { ClientMarketData.AccountRow accountRow = ClientMarketData.Account.FindByAccountId(orderRow.AccountId); if (accountRow != null) { orderRow.AccountMnemonic = accountRow.Mnemonic; orderRow.AccountName = accountRow.ObjectRow.Name; } } // SecurityId cross-referenced data is filled in here. if (!localOrder.IsSecurityIdNull()) { ClientMarketData.SecurityRow securityRow = ClientMarketData.Security.FindBySecurityId(orderRow.SecurityId); if (securityRow != null) { orderRow.SecuritySymbol = securityRow.Symbol; orderRow.SecurityName = securityRow.ObjectRow.Name; } } // CurrencyId cross-referenced data is filled in here. if (!localOrder.IsSettlementIdNull()) { ClientMarketData.CurrencyRow currencyRow = ClientMarketData.Currency.FindByCurrencyId(orderRow.SettlementId); if (currencyRow != null) { orderRow.SettlementSymbol = currencyRow.SecurityRow.Symbol; orderRow.SettlementName = currencyRow.SecurityRow.ObjectRow.Name; } } // BrokerId cross-referenced data is filled in here. if (!localOrder.IsBrokerIdNull()) { ClientMarketData.BrokerRow brokerRow = ClientMarketData.Broker.FindByBrokerId(orderRow.BrokerId); if (brokerRow != null) { orderRow.BrokerSymbol = brokerRow.Symbol; orderRow.BrokerName = brokerRow.ObjectRow.Name; } } // TransactionType cross-referenced data is filled in here. if (!localOrder.IsTransactionTypeCodeNull()) { ClientMarketData.TransactionTypeRow transactionTypeRow = ClientMarketData.TransactionType.FindByTransactionTypeCode(orderRow.TransactionTypeCode); if (transactionTypeRow != null) { orderRow.TransactionTypeMnemonic = transactionTypeRow.Mnemonic; } } // TimeInForce cross-referenced data is filled in here. if (!localOrder.IsTimeInForceCodeNull()) { ClientMarketData.TimeInForceRow timeInForceRow = ClientMarketData.TimeInForce.FindByTimeInForceCode(orderRow.TimeInForceCode); if (timeInForceRow != null) { orderRow.TimeInForceMnemonic = timeInForceRow.Mnemonic; } } // TimeInForce cross-referenced data is filled in here. if (!localOrder.IsOrderTypeCodeNull()) { ClientMarketData.OrderTypeRow orderTypeRow = ClientMarketData.OrderType.FindByOrderTypeCode(orderRow.OrderTypeCode); if (orderTypeRow != null) { orderRow.OrderTypeMnemonic = orderTypeRow.Mnemonic; } } // This is a complete record of the order, including the referenced data. return(orderRow); }