Esempio n. 1
0
        /// <summary>Archives a Exchange record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="RowVersion">The version number of this row.</param>
        /// <param name="exchangeId">The value for the ExchangeId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int exchangeId)
        {
            // Accessor for the Exchange Table.
            ServerMarketData.ExchangeDataTable exchangeTable = ServerMarketData.Exchange;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.ExchangeRow exchangeRow = exchangeTable.FindByExchangeId(exchangeId);
            if ((exchangeRow == null))
            {
                throw new Exception(string.Format("The Exchange table does not have an element identified by {0}", exchangeId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((exchangeRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < exchangeRow.GetEquityRows().Length); index = (index + 1))
            {
                ServerMarketData.EquityRow childEquityRow = exchangeRow.GetEquityRows()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            exchangeRow[exchangeTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(exchangeRow);
            exchangeRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Exchange\" set \"IsArchived\" = 1 where \"ExchangeId\"=@exchangeId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@exchangeId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, exchangeId));
            sqlCommand.ExecuteNonQuery();
        }
Esempio n. 2
0
 /// <summary>Updates a Equity record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public new static void Update(ParameterList parameters)
 {
     // Accessor for the Equity Table.
     ServerMarketData.EquityDataTable equityTable = ServerMarketData.Equity;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].Value;
     object groupPermission = parameters["groupPermission"].Value;
     object hidden = parameters["hidden"].Value;
     object name = parameters["name"].Value;
     object owner = parameters["owner"].Value;
     object ownerPermission = parameters["ownerPermission"].Value;
     object readOnly = parameters["readOnly"].Value;
     object worldPermission = parameters["worldPermission"].Value;
     object averageDailyVolume = parameters["averageDailyVolume"].Value;
     object externalCountryId = parameters["countryId"].Value;
     object minimumQuantity = parameters["minimumQuantity"].Value;
     object marketCapitalization = parameters["marketCapitalization"].Value;
     object symbol = parameters["symbol"].Value;
     object logo = parameters["logo"].Value;
     object externalVolumeCategoryId = parameters["volumeCategoryId"].Value;
     string externalEquityId = ((string)(parameters["equityId"]));
     object externalExchangeId = parameters["exchangeId"].Value;
     object issuerId = parameters["issuerId"].Value;
     object priceFactor = parameters["priceFactor"].Value;
     object quantityFactor = parameters["quantityFactor"].Value;
     object externalSettlementId = parameters["settlementId"].Value;
     object sharesOutstanding = parameters["sharesOutstanding"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     // The row versioning is largely disabled for external operations.  The value is returned to the caller in the
     // event it's needed for operations within the batch.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     object countryId = Country.FindOptionalKey(configurationId, "countryId", externalCountryId);
     object volumeCategoryId = VolumeCategory.FindOptionalKey(configurationId, "volumeCategoryId", externalVolumeCategoryId);
     int equityId = Security.FindRequiredKey(configurationId, "equityId", externalEquityId);
     object exchangeId = Exchange.FindOptionalKey(configurationId, "exchangeId", externalExchangeId);
     object settlementId = Security.FindOptionalKey(configurationId, "settlementId", externalSettlementId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerMarketData.EquityRow equityRow = equityTable.FindByEquityId(equityId);
     rowVersion = ((long)(equityRow[equityTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Equity.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, averageDailyVolume, countryId, minimumQuantity, marketCapitalization, symbol, logo, volumeCategoryId, equityId, exchangeId, issuerId, priceFactor, quantityFactor, settlementId, sharesOutstanding, typeCode);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Esempio n. 3
0
        /// <summary>
        /// Authorizes a Equity to be returned to the client.
        /// </summary>
        /// <param name="userDataRow">Identifies the current user.</param>
        /// <param name="equityDataRow">The record to be tested for authorization.</param>
        /// <returns>true if the record belongs in the user's hierarchy.</returns>
        public static bool FilterEquity(DataRow userDataRow, DataRow equityDataRow)
        {
            // This will test the record and return true if it belongs to the hierarchies this user is authorized to view.  False
            // if the record should not be included in the user's data model.
            ServerMarketData.UserRow   userRow   = (ServerMarketData.UserRow)userDataRow;
            ServerMarketData.EquityRow equityRow = (ServerMarketData.EquityRow)equityDataRow;

            foreach (ServerMarketData.SourceOrderRow sourceOrderRow in equityRow.SecurityRowBySecurityEquityEquityId.GetSourceOrderRowsBySecuritySourceOrderSecurityId())
            {
                if (Hierarchy.IsDescendant(userRow.SystemFolderRow.FolderRow.ObjectRow, sourceOrderRow.WorkingOrderRow.BlotterRow.ObjectRow))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        /// <summary>ArchiveChildrens a Equity record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">the version number of this row.</param>
        /// <param name="equityId">The value for the EquityId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal new static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int equityId)
        {
            // Accessor for the Equity Table.
            ServerMarketData.EquityDataTable equityTable = ServerMarketData.Equity;
            // This record can be used to iterate through all the children.
            ServerMarketData.EquityRow equityRow = equityTable.FindByEquityId(equityId);
            // Archive the child records.
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            equityRow[equityTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(equityRow);
            equityRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Equity\" set \"IsArchived\" = 1 where \"EquityId\"=@equityId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@equityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, equityId));
            sqlCommand.ExecuteNonQuery();
        }
Esempio n. 5
0
        /// <summary>Archives a Equity record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">The version number of this row.</param>
        /// <param name="equityId">The value for the EquityId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public new static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int equityId)
        {
            // Accessor for the Equity Table.
            ServerMarketData.EquityDataTable equityTable = ServerMarketData.Equity;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.EquityRow equityRow = equityTable.FindByEquityId(equityId);
            if ((equityRow == null))
            {
                throw new Exception(string.Format("The Equity table does not have an element identified by {0}", equityId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((equityRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Delete the base class record.  Note that optimistic concurrency is only used
            // by the top level type in the hierarchy, it is bypassed after you pass the first test.
            long baseRowVersion = equityRow.SecurityRowBySecurityEquityEquityId.RowVersion;

            Security.Archive(adoTransaction, sqlTransaction, baseRowVersion, equityId);
        }
Esempio n. 6
0
 /// <summary>Archives a Equity record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public new static void Archive(ParameterList parameters)
 {
     // Accessor for the Equity Table.
     ServerMarketData.EquityDataTable equityTable = ServerMarketData.Equity;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalEquityId = parameters["equityId"];
     // The row versioning is largely disabled for external operations.  The value is returned to the caller in the
     // event it's needed for operations within the batch.
     long rowVersion = long.MinValue;
     // Find the internal identifier using the primary key elements.
     // identifier is used to determine if a record exists with the same key.
     int equityId = Equity.FindRequiredKey(configurationId, "equityId", externalEquityId);
     // This disables the concurrency checking logic by finding the current row version and passing it to the
     // internal method.
     ServerMarketData.EquityRow equityRow = equityTable.FindByEquityId(equityId);
     rowVersion = ((long)(equityRow[equityTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Equity.Archive(adoTransaction, sqlTransaction, rowVersion, equityId);
 }
Esempio n. 7
0
        /// <summary>
        /// Generates random price movements.
        /// </summary>
        private static void MarketThread()
        {
            // Keep looping until the thread is terminated.
            while (true)
            {
                try
                {
                    // Lock the tables.
                    Debug.Assert(!ServerMarketData.AreLocksHeld);
                    ServerMarketData.EquityLock.AcquireReaderLock(Timeout.Infinite);
                    ServerMarketData.PriceLock.AcquireWriterLock(Timeout.Infinite);
                    ServerMarketData.SecurityLock.AcquireReaderLock(Timeout.Infinite);

                    // Pick a random security to move from the tax lot tables.  This insures us that the ticks we get are
                    // relative to the demo.
                    int index = Random.Next(0, ServerMarketData.Equity.Rows.Count);
                    ServerMarketData.EquityRow   equityRow   = ServerMarketData.Equity[index];
                    ServerMarketData.SecurityRow securityRow = equityRow.SecurityRowByFKSecurityEquityEquityId;

                    // Find a price that matches the equity's default settlement.  This is the price record that will be updated
                    // with the simulated market conditions.
                    ServerMarketData.PriceRow priceRow = ServerMarketData.Price.FindBySecurityIdCurrencyId(equityRow.EquityId, equityRow.SettlementId);
                    if (priceRow == null)
                    {
                        continue;
                    }

                    // Randomly change the bid, last or asked price.
                    switch (Random.Next(3))
                    {
                    case 0:

                        // The bid price is moved randomly away from the last price.
                        decimal bidChange = (decimal)(Math.Round(Random.NextDouble() * 0.25, 2));
                        priceRow.RowVersion = ServerMarketData.RowVersion.Increment();
                        priceRow.BidPrice   = priceRow.LastPrice - bidChange;
                        priceRow.BidSize    = (decimal)(Math.Round(Random.NextDouble() * 10.0, 0) * 100.0 + 100);
                        break;

                    case 1:

                        // The price is moved randomly from one to 10 tenths of a percent.
                        decimal randomPercent = (decimal)(Math.Round(Random.NextDouble() * 0.010, 3) - 0.005);
                        priceRow.RowVersion  = ServerMarketData.RowVersion.Increment();
                        priceRow.PriceChange = Math.Round(priceRow.LastPrice * randomPercent, 2);
                        priceRow.LastPrice  += priceRow.PriceChange;
                        priceRow.LastSize    = (decimal)(Math.Round(Random.NextDouble() * 10.0, 0) * 100.0 + 100);
                        break;

                    case 2:

                        // The ask price is moved randomly away from the last price.
                        decimal askChange = (decimal)(Math.Round(Random.NextDouble(), 2) * 0.25);
                        priceRow.RowVersion = ServerMarketData.RowVersion.Increment();
                        priceRow.AskPrice   = priceRow.LastPrice + askChange;
                        priceRow.AskSize    = (decimal)(Math.Round(Random.NextDouble() * 10.0, 0) * 100.0 + 100);
                        break;
                    }
                }
                catch (Exception exception)
                {
                    // Write the error and stack trace out to the debug listener
                    Debug.WriteLine(String.Format("{0}, {1}", exception.Message, exception.StackTrace));
                }
                finally
                {
                    // Release the global tables.
                    if (ServerMarketData.EquityLock.IsReaderLockHeld)
                    {
                        ServerMarketData.EquityLock.ReleaseReaderLock();
                    }
                    if (ServerMarketData.PriceLock.IsWriterLockHeld)
                    {
                        ServerMarketData.PriceLock.ReleaseWriterLock();
                    }
                    if (ServerMarketData.SecurityLock.IsReaderLockHeld)
                    {
                        ServerMarketData.SecurityLock.ReleaseReaderLock();
                    }
                    Debug.Assert(!ServerMarketData.AreLocksHeld);
                }

                // The controls how often the simulator picks another price.
                Thread.Sleep(Price.Timer);
            }
        }
Esempio n. 8
0
 /// <summary>Loads a Equity record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public new static void Load(ParameterList parameters)
 {
     // Accessor for the Equity Table.
     ServerMarketData.EquityDataTable equityTable = ServerMarketData.Equity;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].Value;
     object groupPermission = parameters["groupPermission"].Value;
     object hidden = parameters["hidden"].Value;
     string name = parameters["name"];
     object owner = parameters["owner"].Value;
     object ownerPermission = parameters["ownerPermission"].Value;
     object readOnly = parameters["readOnly"].Value;
     object worldPermission = parameters["worldPermission"].Value;
     object averageDailyVolume = parameters["averageDailyVolume"].Value;
     string externalCountryId = parameters["countryId"];
     object minimumQuantity = parameters["minimumQuantity"].Value;
     object marketCapitalization = parameters["marketCapitalization"].Value;
     object symbol = parameters["symbol"].Value;
     object logo = parameters["logo"].Value;
     object externalVolumeCategoryId = parameters["volumeCategoryId"].Value;
     string externalEquityId = parameters["equityId"];
     object externalExchangeId = parameters["exchangeId"].Value;
     object issuerId = parameters["issuerId"].Value;
     object priceFactor = parameters["priceFactor"].Value;
     object quantityFactor = parameters["quantityFactor"].Value;
     string externalSettlementId = parameters["settlementId"];
     object sharesOutstanding = parameters["sharesOutstanding"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     // The row versioning is largely disabled for external operations.  The value is returned to the caller in the
     // event it's needed for operations within the batch.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     int countryId = Country.FindRequiredKey(configurationId, "countryId", externalCountryId);
     object volumeCategoryId = VolumeCategory.FindOptionalKey(configurationId, "volumeCategoryId", externalVolumeCategoryId);
     int equityId = Security.FindKey(configurationId, "equityId", externalEquityId);
     object exchangeId = Exchange.FindOptionalKey(configurationId, "exchangeId", externalExchangeId);
     int settlementId = Security.FindRequiredKey(configurationId, "settlementId", externalSettlementId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     ServerMarketData.EquityRow equityRow = equityTable.FindByEquityId(equityId);
     // The load operation will create a record if it doesn't exist, or update an existing record.  The external
     // identifier is used to determine if a record exists with the same key.
     if ((equityRow == null))
     {
         // Populate the 'externalId' varaibles so that the external identifier can be used to find the row when an
         // external method is called with the same 'configurationId' parameter.
         int externalKeyIndex = Equity.GetExternalKeyIndex(configurationId, "equityId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalEquityId;
         object externalId0 = externalIdArray[0];
         object externalId1 = externalIdArray[1];
         object externalId2 = externalIdArray[2];
         object externalId3 = externalIdArray[3];
         object externalId4 = externalIdArray[4];
         object externalId5 = externalIdArray[5];
         object externalId6 = externalIdArray[6];
         object externalId7 = externalIdArray[7];
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Equity.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, averageDailyVolume, countryId, minimumQuantity, marketCapitalization, symbol, logo, volumeCategoryId, exchangeId, issuerId, priceFactor, quantityFactor, settlementId, sharesOutstanding, typeCode);
     }
     else
     {
         // While the optimistic concurrency checking is disabled for the external methods, the internal methods
         // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
         // will bypass the coused when the internal method is called.
         rowVersion = ((long)(equityRow[equityTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Equity.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, averageDailyVolume, countryId, minimumQuantity, marketCapitalization, symbol, logo, volumeCategoryId, equityId, exchangeId, issuerId, priceFactor, quantityFactor, settlementId, sharesOutstanding, typeCode);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Esempio n. 9
0
        /// <summary>Updates a Equity record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">The version number of the row</param>
        /// <param name="description">The value for the Description column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="externalId1">The value for the ExternalId1 column.</param>
        /// <param name="externalId2">The value for the ExternalId2 column.</param>
        /// <param name="externalId3">The value for the ExternalId3 column.</param>
        /// <param name="externalId4">The value for the ExternalId4 column.</param>
        /// <param name="externalId5">The value for the ExternalId5 column.</param>
        /// <param name="externalId6">The value for the ExternalId6 column.</param>
        /// <param name="externalId7">The value for the ExternalId7 column.</param>
        /// <param name="groupPermission">The value for the GroupPermission column.</param>
        /// <param name="hidden">The value for the Hidden column.</param>
        /// <param name="name">The value for the Name column.</param>
        /// <param name="owner">The value for the Owner column.</param>
        /// <param name="ownerPermission">The value for the OwnerPermission column.</param>
        /// <param name="readOnly">The value for the ReadOnly column.</param>
        /// <param name="worldPermission">The value for the WorldPermission column.</param>
        /// <param name="averageDailyVolume">The value for the AverageDailyVolume column.</param>
        /// <param name="countryId">The value for the CountryId column.</param>
        /// <param name="minimumQuantity">The value for the MinimumQuantity column.</param>
        /// <param name="marketCapitalization">The value for the MarketCapitalization column.</param>
        /// <param name="symbol">The value for the Symbol column.</param>
        /// <param name="logo">The value for the Logo column.</param>
        /// <param name="volumeCategoryId">The value for the VolumeCategoryId column.</param>
        /// <param name="equityId">The value for the EquityId column.</param>
        /// <param name="exchangeId">The value for the ExchangeId column.</param>
        /// <param name="issuerId">The value for the IssuerId column.</param>
        /// <param name="priceFactor">The value for the PriceFactor column.</param>
        /// <param name="quantityFactor">The value for the QuantityFactor column.</param>
        /// <param name="settlementId">The value for the SettlementId column.</param>
        /// <param name="sharesOutstanding">The value for the SharesOutstanding column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object description,
            object externalId0,
            object externalId1,
            object externalId2,
            object externalId3,
            object externalId4,
            object externalId5,
            object externalId6,
            object externalId7,
            object groupPermission,
            object hidden,
            object name,
            object owner,
            object ownerPermission,
            object readOnly,
            object worldPermission,
            object averageDailyVolume,
            object countryId,
            object minimumQuantity,
            object marketCapitalization,
            object symbol,
            object logo,
            object volumeCategoryId,
            int equityId,
            object exchangeId,
            object issuerId,
            object priceFactor,
            object quantityFactor,
            object settlementId,
            object sharesOutstanding,
            object typeCode)
        {
            // Accessor for the Equity Table.
            ServerMarketData.EquityDataTable equityTable = ServerMarketData.Equity;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.EquityRow equityRow = equityTable.FindByEquityId(equityId);
            if ((equityRow == null))
            {
                throw new Exception(string.Format("The Equity table does not have an element identified by {0}", equityId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((equityRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((exchangeId == null))
            {
                exchangeId = equityRow[equityTable.ExchangeIdColumn];
            }
            if ((issuerId == null))
            {
                issuerId = equityRow[equityTable.IssuerIdColumn];
            }
            if ((settlementId == null))
            {
                settlementId = equityRow[equityTable.SettlementIdColumn];
            }
            if ((sharesOutstanding == null))
            {
                sharesOutstanding = equityRow[equityTable.SharesOutstandingColumn];
            }
            // Insert the base members using the base class.  Note that optimistic concurrency is only used
            // by the top level type in the hierarchy, it is bypassed after you pass the first test.
            long baseRowVersion = equityRow.SecurityRowBySecurityEquityEquityId.RowVersion;

            Security.Update(adoTransaction, sqlTransaction, ref baseRowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, averageDailyVolume, countryId, minimumQuantity, marketCapitalization, priceFactor, quantityFactor, equityId, symbol, typeCode, logo, volumeCategoryId);
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            equityRow[equityTable.RowVersionColumn]        = rowVersion;
            equityRow[equityTable.ExchangeIdColumn]        = exchangeId;
            equityRow[equityTable.IssuerIdColumn]          = issuerId;
            equityRow[equityTable.SettlementIdColumn]      = settlementId;
            equityRow[equityTable.SharesOutstandingColumn] = sharesOutstanding;
            adoTransaction.DataRows.Add(equityRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Equity\" set \"RowVersion\"=@rowVersion,\"ExchangeId\"=@exchangeId,\"IssuerId\"=" +
                                                   "@issuerId,\"SettlementId\"=@settlementId,\"SharesOutstanding\"=@sharesOutstanding wh" +
                                                   "ere \"EquityId\"=@equityId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@equityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, equityId));
            sqlCommand.Parameters.Add(new SqlParameter("@exchangeId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, exchangeId));
            sqlCommand.Parameters.Add(new SqlParameter("@issuerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, issuerId));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementId));
            sqlCommand.Parameters.Add(new SqlParameter("@sharesOutstanding", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sharesOutstanding));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Esempio n. 10
0
        /// <summary>Inserts a Equity record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">The version number of the row.</param>
        /// <param name="description">The value for the Description column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="externalId1">The value for the ExternalId1 column.</param>
        /// <param name="externalId2">The value for the ExternalId2 column.</param>
        /// <param name="externalId3">The value for the ExternalId3 column.</param>
        /// <param name="externalId4">The value for the ExternalId4 column.</param>
        /// <param name="externalId5">The value for the ExternalId5 column.</param>
        /// <param name="externalId6">The value for the ExternalId6 column.</param>
        /// <param name="externalId7">The value for the ExternalId7 column.</param>
        /// <param name="groupPermission">The value for the GroupPermission column.</param>
        /// <param name="hidden">The value for the Hidden column.</param>
        /// <param name="name">The value for the Name column.</param>
        /// <param name="owner">The value for the Owner column.</param>
        /// <param name="ownerPermission">The value for the OwnerPermission column.</param>
        /// <param name="readOnly">The value for the ReadOnly column.</param>
        /// <param name="worldPermission">The value for the WorldPermission column.</param>
        /// <param name="averageDailyVolume">The value for the AverageDailyVolume column.</param>
        /// <param name="countryId">The value for the CountryId column.</param>
        /// <param name="minimumQuantity">The value for the MinimumQuantity column.</param>
        /// <param name="marketCapitalization">The value for the MarketCapitalization column.</param>
        /// <param name="symbol">The value for the Symbol column.</param>
        /// <param name="logo">The value for the Logo column.</param>
        /// <param name="volumeCategoryId">The value for the VolumeCategoryId column.</param>
        /// <param name="exchangeId">The value for the ExchangeId column.</param>
        /// <param name="issuerId">The value for the IssuerId column.</param>
        /// <param name="priceFactor">The value for the PriceFactor column.</param>
        /// <param name="quantityFactor">The value for the QuantityFactor column.</param>
        /// <param name="settlementId">The value for the SettlementId column.</param>
        /// <param name="sharesOutstanding">The value for the SharesOutstanding column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object description,
            object externalId0,
            object externalId1,
            object externalId2,
            object externalId3,
            object externalId4,
            object externalId5,
            object externalId6,
            object externalId7,
            object groupPermission,
            object hidden,
            string name,
            object owner,
            object ownerPermission,
            object readOnly,
            object worldPermission,
            object averageDailyVolume,
            int countryId,
            object minimumQuantity,
            object marketCapitalization,
            object symbol,
            object logo,
            object volumeCategoryId,
            object exchangeId,
            object issuerId,
            object priceFactor,
            object quantityFactor,
            int settlementId,
            object sharesOutstanding,
            object typeCode)
        {
            // Accessor for the Equity Table.
            ServerMarketData.EquityDataTable equityTable = ServerMarketData.Equity;
            // Apply Defaults
            if ((exchangeId == null))
            {
                exchangeId = System.DBNull.Value;
            }
            if ((issuerId == null))
            {
                issuerId = System.DBNull.Value;
            }
            if ((priceFactor == null))
            {
                priceFactor = 1.0m;
            }
            if ((quantityFactor == null))
            {
                quantityFactor = 1.0m;
            }
            if ((sharesOutstanding == null))
            {
                sharesOutstanding = System.DBNull.Value;
            }
            if ((typeCode == null))
            {
                typeCode = "Equity";
            }
            // Insert the base members using the base class.
            int equityId = Security.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, worldPermission, averageDailyVolume, countryId, minimumQuantity, marketCapitalization, ((decimal)(priceFactor)), ((decimal)(quantityFactor)), symbol, typeCode, logo, volumeCategoryId);

            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerMarketData.EquityRow equityRow = equityTable.NewEquityRow();
            equityRow[equityTable.RowVersionColumn]        = rowVersion;
            equityRow[equityTable.EquityIdColumn]          = equityId;
            equityRow[equityTable.ExchangeIdColumn]        = exchangeId;
            equityRow[equityTable.IssuerIdColumn]          = issuerId;
            equityRow[equityTable.SettlementIdColumn]      = settlementId;
            equityRow[equityTable.SharesOutstandingColumn] = sharesOutstanding;
            equityTable.AddEquityRow(equityRow);
            adoTransaction.DataRows.Add(equityRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand("insert \"Equity\" (\"rowVersion\",EquityId,ExchangeId,IssuerId,SettlementId,SharesOut" +
                                                   "standing) values (@rowVersion,@equityId,@exchangeId,@issuerId,@settlementId,@sha" +
                                                   "resOutstanding)");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@equityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, equityId));
            sqlCommand.Parameters.Add(new SqlParameter("@exchangeId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, exchangeId));
            sqlCommand.Parameters.Add(new SqlParameter("@issuerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, issuerId));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementId));
            sqlCommand.Parameters.Add(new SqlParameter("@sharesOutstanding", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sharesOutstanding));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(equityRow.EquityId);
        }
Esempio n. 11
0
        /// <summary>ArchiveChildrens a Security record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">the version number of this row.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int securityId)
        {
            // Accessor for the Security Table.
            ServerMarketData.SecurityDataTable securityTable = ServerMarketData.Security;
            // This record can be used to iterate through all the children.
            ServerMarketData.SecurityRow securityRow = securityTable.FindBySecurityId(securityId);
            // Archive the child records.
            for (int index = 0; (index < securityRow.GetAccountBaseRows().Length); index = (index + 1))
            {
                ServerMarketData.AccountBaseRow childAccountBaseRow = securityRow.GetAccountBaseRows()[index];
                AccountBase.ArchiveChildren(adoTransaction, sqlTransaction, childAccountBaseRow.RowVersion, childAccountBaseRow.AccountBaseId);
            }
            for (int index = 0; (index < securityRow.GetAllocationRowsBySecurityAllocationSecurityId().Length); index = (index + 1))
            {
                ServerMarketData.AllocationRow childAllocationRow = securityRow.GetAllocationRowsBySecurityAllocationSecurityId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < securityRow.GetAllocationRowsBySecurityAllocationSettlementId().Length); index = (index + 1))
            {
                ServerMarketData.AllocationRow childAllocationRow = securityRow.GetAllocationRowsBySecurityAllocationSettlementId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < securityRow.GetCurrencyRows().Length); index = (index + 1))
            {
                ServerMarketData.CurrencyRow childCurrencyRow = securityRow.GetCurrencyRows()[index];
                Currency.ArchiveChildren(adoTransaction, sqlTransaction, childCurrencyRow.RowVersion, childCurrencyRow.CurrencyId);
            }
            for (int index = 0; (index < securityRow.GetDebtRowsBySecurityDebtDebtId().Length); index = (index + 1))
            {
                ServerMarketData.DebtRow childDebtRow = securityRow.GetDebtRowsBySecurityDebtDebtId()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            for (int index = 0; (index < securityRow.GetDebtRowsBySecurityDebtSettlementId().Length); index = (index + 1))
            {
                ServerMarketData.DebtRow childDebtRow = securityRow.GetDebtRowsBySecurityDebtSettlementId()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            for (int index = 0; (index < securityRow.GetEquityRowsBySecurityEquityEquityId().Length); index = (index + 1))
            {
                ServerMarketData.EquityRow childEquityRow = securityRow.GetEquityRowsBySecurityEquityEquityId()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            for (int index = 0; (index < securityRow.GetEquityRowsBySecurityEquitySettlementId().Length); index = (index + 1))
            {
                ServerMarketData.EquityRow childEquityRow = securityRow.GetEquityRowsBySecurityEquitySettlementId()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            for (int index = 0; (index < securityRow.GetPositionRows().Length); index = (index + 1))
            {
                ServerMarketData.PositionRow childPositionRow = securityRow.GetPositionRows()[index];
                Position.Archive(adoTransaction, sqlTransaction, childPositionRow.RowVersion, childPositionRow.AccountId, childPositionRow.SecurityId, childPositionRow.PositionTypeCode);
            }
            for (int index = 0; (index < securityRow.GetPriceRows().Length); index = (index + 1))
            {
                ServerMarketData.PriceRow childPriceRow = securityRow.GetPriceRows()[index];
                Price.Archive(adoTransaction, sqlTransaction, childPriceRow.RowVersion, childPriceRow.SecurityId);
            }
            for (int index = 0; (index < securityRow.GetSourceOrderRowsBySecuritySourceOrderSecurityId().Length); index = (index + 1))
            {
                ServerMarketData.SourceOrderRow childSourceOrderRow = securityRow.GetSourceOrderRowsBySecuritySourceOrderSecurityId()[index];
                SourceOrder.Archive(adoTransaction, sqlTransaction, childSourceOrderRow.RowVersion, childSourceOrderRow.SourceOrderId);
            }
            for (int index = 0; (index < securityRow.GetSourceOrderRowsBySecuritySourceOrderSettlementId().Length); index = (index + 1))
            {
                ServerMarketData.SourceOrderRow childSourceOrderRow = securityRow.GetSourceOrderRowsBySecuritySourceOrderSettlementId()[index];
                SourceOrder.Archive(adoTransaction, sqlTransaction, childSourceOrderRow.RowVersion, childSourceOrderRow.SourceOrderId);
            }
            for (int index = 0; (index < securityRow.GetTaxLotRows().Length); index = (index + 1))
            {
                ServerMarketData.TaxLotRow childTaxLotRow = securityRow.GetTaxLotRows()[index];
                TaxLot.Archive(adoTransaction, sqlTransaction, childTaxLotRow.RowVersion, childTaxLotRow.TaxLotId);
            }
            for (int index = 0; (index < securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSecurityId().Length); index = (index + 1))
            {
                ServerMarketData.WorkingOrderRow childWorkingOrderRow = securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSecurityId()[index];
                WorkingOrder.Archive(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId);
            }
            for (int index = 0; (index < securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSettlementId().Length); index = (index + 1))
            {
                ServerMarketData.WorkingOrderRow childWorkingOrderRow = securityRow.GetWorkingOrderRowsBySecurityWorkingOrderSettlementId()[index];
                WorkingOrder.Archive(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            securityRow[securityTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(securityRow);
            securityRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Security\" set \"IsArchived\" = 1 where \"SecurityId\"=@securityId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.ExecuteNonQuery();
        }
Esempio n. 12
0
        /// <summary>
        /// Loads a DataSet from the XML file defined by symbolFilepath.  Iterates through each (configurationId, equityId) pair
        /// and adds the ticker symbol to the eSignal Data Manager watch list.
        /// </summary>
        private static void LoadSymbols()
        {
            try
            {
                // Lock the tables.
                // Acquire the configuration and object locks for the securityId lookup
                Debug.Assert(!ServerMarketData.IsLocked);
                ServerMarketData.SecurityLock.AcquireReaderLock(Timeout.Infinite);
                ServerMarketData.EquityLock.AcquireReaderLock(Timeout.Infinite);
                ServerMarketData.ObjectLock.AcquireReaderLock(Timeout.Infinite);
                ServerMarketData.ConfigurationLock.AcquireReaderLock(Timeout.Infinite);

                // initialize the dataset from the XMl file
                DataSet dataSetFromXML = new DataSet("SP500");
                dataSetFromXML.ReadXml(symbolFilepath, XmlReadMode.InferSchema);
                foreach (DataRow dataRow in dataSetFromXML.Tables["method"].Rows)
                {
                    // extract the configurationId and the externalEquityId from the dataset
                    object configurationId  = dataRow["configurationId"];
                    string externalEquityId = (string)dataRow["equityId"];
                    try
                    {
                        // look up the equityId
                        int equityId = (int)Security.FindOptionalKey(configurationId, "equityId", externalEquityId);

                        // get the equity row
                        ServerMarketData.EquityRow equityRow = ServerMarketData.Equity.FindByEquityId(equityId);
                        if (equityRow != null)
                        {
                            // Get the security row from the equity row
                            ServerMarketData.SecurityRow securityRow = equityRow.SecurityRowBySecurityEquityEquityId;

                            // attempt to add the symbol to the eSignal data manager
                            if (eSignal.AddRealTimeSymbol(securityRow.Symbol))
                            {
                                symbolToSecurityIdTable[securityRow.Symbol] = securityRow.SecurityId;
                            }
                            else
                            {
                                MarkThree.EventLog.Warning("Market Data Service has no data for ticker {0}", externalEquityId);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        // Write the error to the log.
                        MarkThree.EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace);
                    }
                }

                // Mark the time that the real-time updates started.
                MarkThree.EventLog.Information("Real Time Symbols Loaded");
            }
            catch (Exception exception)
            {
                eSignal = null;

                // Write the error and stack trace out to the debug listener
                MarkThree.EventLog.Warning(String.Format("{0}, {1}", exception.Message, exception.StackTrace));
            }
            finally
            {
                // Release the global tables.
                //if (ServerMarketData.PriceLock.IsWriterLockHeld) ServerMarketData.PriceLock.ReleaseWriterLock();
                if (ServerMarketData.SecurityLock.IsReaderLockHeld)
                {
                    ServerMarketData.SecurityLock.ReleaseReaderLock();
                }
                if (ServerMarketData.EquityLock.IsReaderLockHeld)
                {
                    ServerMarketData.EquityLock.ReleaseReaderLock();
                }
                if (ServerMarketData.ObjectLock.IsReaderLockHeld)
                {
                    ServerMarketData.ObjectLock.ReleaseReaderLock();
                }
                if (ServerMarketData.ConfigurationLock.IsReaderLockHeld)
                {
                    ServerMarketData.ConfigurationLock.ReleaseReaderLock();
                }
                Debug.Assert(!ServerMarketData.IsLocked);
            }
        }
Esempio n. 13
0
        public static void OnUpdateSymbolDM(object wrapper, DMUpdateSymbolArgs args)
        {
            // StockInfo object holding the new symbol data for this update
            StockInfo stockInfo = args.stockInfo;

            try
            {
                // Lock the tables.
                Debug.Assert(!ServerMarketData.IsLocked);
                ServerMarketData.EquityLock.AcquireReaderLock(Timeout.Infinite);
                ServerMarketData.PriceLock.AcquireWriterLock(Timeout.Infinite);
                ServerMarketData.SecurityLock.AcquireReaderLock(Timeout.Infinite);

                // make sure the symbol is in the hash table - and that we added it to the data manager
                if (!symbolToSecurityIdTable.ContainsKey(stockInfo.Symbol))
                {
                    throw new Exception("Received update for unknown symbol: " + stockInfo.Symbol);
                }

                // get the security id of the symbol
                int securityID = (int)symbolToSecurityIdTable[stockInfo.Symbol];

                // get the security row
                ServerMarketData.SecurityRow securityRow = ServerMarketData.Security.FindBySecurityId(securityID);
                if (securityRow == null)
                {
                    throw new Exception("Warning: Could not find security row for symbol: " + stockInfo.Symbol);
                }

                //int equityId = Security.FindRequiredKey(configurationId, "equityId", externalEquityId);
                // Only Equities are priced by this simulator.  All others are ignored.
                ServerMarketData.EquityRow equityRow = ServerMarketData.Equity.FindByEquityId(securityRow.SecurityId);
                if (equityRow != null)
                {
                    // Find a price that matches the equity's default settlement.  This is the price record that will be updated
                    // with the simulated market conditions.
                    ServerMarketData.PriceRow priceRow = ServerMarketData.Price.FindBySecurityId(securityRow.SecurityId);
                    if (priceRow == null)
                    {
                        priceRow = ServerMarketData.Price.NewPriceRow();
                        //priceRow.RowVersion = ServerMarketData.RowVersion.Increment();
                        priceRow.SecurityId = equityRow.EquityId;
                        priceRow.CurrencyId = equityRow.SettlementId;
                        priceRow.LastPrice  = 0.0M;
                        priceRow.AskPrice   = 0.0M;
                        priceRow.BidPrice   = 0.0M;
                        priceRow.Volume     = 0.0M;
                        priceRow.ClosePrice = 0.0M;
                        priceRow.VolumeWeightedAveragePrice = 0.0M;
                        priceRow.HighPrice = 0.0M;
                        priceRow.LowPrice  = 0.0M;
                        ServerMarketData.Price.AddPriceRow(priceRow);
                    }

                    // set the new values from the real time event into the price row
                    priceRow.BidSize   = stockInfo.BidSize;
                    priceRow.BidPrice  = Convert.ToDecimal(stockInfo.BidPrice);
                    priceRow.AskPrice  = Convert.ToDecimal(stockInfo.AskPrice);
                    priceRow.AskSize   = Convert.ToDecimal(stockInfo.AskSize);
                    priceRow.LastPrice = Convert.ToDecimal(stockInfo.LastPrice);
                    priceRow.LastSize  = stockInfo.TradeVolume;
                    priceRow.Volume    = Convert.ToDecimal(stockInfo.TotalVolume);
                    priceRow.VolumeWeightedAveragePrice = (Convert.ToDecimal(stockInfo.LastPrice) + Convert.ToDecimal(stockInfo.OpenPrice)) / 2;
                    priceRow.OpenPrice  = Convert.ToDecimal(stockInfo.OpenPrice);
                    priceRow.LowPrice   = Convert.ToDecimal(stockInfo.LowPrice);
                    priceRow.HighPrice  = Convert.ToDecimal(stockInfo.HighPrice);
                    priceRow.ClosePrice = Convert.ToDecimal(stockInfo.PreviousPrice);

                    // increment the RowVersion so the client notices!!!
                    priceRow.RowVersion = ServerMarketData.RowVersion.Increment();

                    // commit the changes
                    priceRow.AcceptChanges();
                }
            }
            catch (Exception exception)
            {
                String msg = String.Format("{0}, {1}", exception.Message, exception.StackTrace);

                // Write the error and stack trace out to the debug listener
                //Debug.WriteLine(msg);
                MarkThree.EventLog.Warning(msg);
            }
            finally
            {
                // Release the global tables.
                if (ServerMarketData.EquityLock.IsReaderLockHeld)
                {
                    ServerMarketData.EquityLock.ReleaseReaderLock();
                }
                if (ServerMarketData.PriceLock.IsWriterLockHeld)
                {
                    ServerMarketData.PriceLock.ReleaseWriterLock();
                }
                if (ServerMarketData.SecurityLock.IsReaderLockHeld)
                {
                    ServerMarketData.SecurityLock.ReleaseReaderLock();
                }
                Debug.Assert(!ServerMarketData.IsLocked);
            }
        }