예제 #1
0
        }// GetWriteQuery()

        //
        //
        //
        //
        //

        //
        //
        private void WriteValues(FillsQueryItem item, ref StringBuilder query)
        {
            query.AppendFormat("({0},{1}", item.StrategyId, item.InstrumentId);
            query.AppendFormat(",\'{0}\',\'{1}\'", item.UserName, item.RunType);
            query.AppendFormat(",\'{0}\'", item.PricingEngineName);
            // time stamp
            query.AppendFormat(",\'{0:yyyy-MM-dd HH:mm:ss}\'", item.TimeStamp);
            query.AppendFormat(",{0}", item.UnixUTC);
            query.AppendFormat(",{0}", item.UnixMicroSec);
            // data
            query.AppendFormat(",{0},{1}", item.Qty, item.Price);
            query.AppendFormat(",\'{0}\'", item.AttributeString);
            query.Append(")");
        }
예제 #2
0
        //
        //
        //
        //
        #endregion//Constructors


        #region Public Methods
        // *************************************
        // ****     AddItemToWrite()        ****
        // *************************************
        /// <summary>
        /// User calls this function to add a new signal item for later writing.
        /// TODO:
        ///     1) this is written like this so in future, we can recycle signal items
        ///         without the user having access to them.
        /// </summary>
        public void AddItemToWrite(int strategyId, int instrId, DateTime localTime, UV.Lib.Application.UserInfo user, string pricingEngineName, string attributeString, int qty = 0, double price = 0)
        {
            FillsQueryItem newItem = new FillsQueryItem();

            newItem.StrategyId        = strategyId;
            newItem.InstrumentId      = instrId;
            newItem.RunType           = user.RunType.ToString().ToLower();
            newItem.UserName          = user.UserName;
            newItem.PricingEngineName = pricingEngineName;

            newItem.TimeStamp = localTime;
            double utc = QTMath.DateTimeToEpoch(localTime.ToUniversalTime());

            newItem.UnixUTC      = (int)Math.Floor(utc);
            newItem.UnixMicroSec = (int)((utc - newItem.UnixUTC) * 1000000);

            newItem.Qty   = qty;
            newItem.Price = price;

            newItem.AttributeString = attributeString;

            this.m_ItemsToWrite.Add(newItem);
        }//AddItemToWrite()
예제 #3
0
        //
        //
        // *************************************
        // ****       GetWriteQuerySuffix   ****
        // *************************************
        public override string GetWriteQuerySuffix(DatabaseInfo dataBase)
        {
            TableInfo.UVFillsTableInfo table = dataBase.UVFills;
            // Start of query
            StringBuilder query = new StringBuilder();

            //
            // Values to write
            //
            if (m_ItemsToWrite.Count == 0)
            {
                return(string.Empty);
            }
            FillsQueryItem item = this.m_ItemsToWrite[0];

            WriteValues(item, ref query);
            for (int i = 1; i < m_ItemsToWrite.Count; ++i)
            {
                query.Append(", ");
                item = this.m_ItemsToWrite[i];
                WriteValues(item, ref query);
            }
            return(query.ToString());
        }