Beispiel #1
0
        }// GetWriteQuery()

        //
        //
        private void WriteValues(SignalQueryItem item, ref StringBuilder query)
        {
            query.AppendFormat("({0},{1}", item.StrategyId, item.EngineId);
            query.AppendFormat(",\'{0}\',\'{1}\'", item.UserName, item.RunType);
            // time stamp
            query.AppendFormat(",\'{0:yyyy-MM-dd HH:mm:ss}\'", item.TimeStamp);
            // data
            query.AppendFormat(",{0}", item.Side);
            query.AppendFormat(",{0},{1}", item.Qty, item.Price);
            query.AppendFormat(",\'{0}\'", item.AttributeString);
            query.Append(")");
        }
Beispiel #2
0
        }//

        //
        //
        // *************************************
        // ****         ToString()          ****
        // *************************************
        //
        //
        //
        //
        #endregion//Public Methods


        #region Private Methods
        // *************************************
        // ****        GetWriteQuery        ****
        // *************************************
        private string GetWriteQuery(DatabaseInfo dataBase)
        {
            TableInfo.UVSignalsTableInfo table = dataBase.UVSignals;
            // Start of query
            StringBuilder query = new StringBuilder();

            query.AppendFormat("INSERT INTO {0}", table.TableNameFull);

            //
            // Fields to write
            //
            // Id
            query.AppendFormat(" ({0}", table.StrategyId);
            query.AppendFormat(",{0}", table.EngineId);
            query.AppendFormat(",{0}", table.UserName);
            query.AppendFormat(",{0}", table.RunType);
            // time stamp
            query.AppendFormat(",{0}", table.TimeStamp);
            // data fields
            query.AppendFormat(",{0}", table.Side);
            query.AppendFormat(",{0}", table.Qty);
            query.AppendFormat(",{0}", table.Price);
            query.AppendFormat(",{0}", table.AttributeString);

            query.Append(")");

            //
            // Values to write
            //
            query.AppendFormat(" VALUES ");
            SignalQueryItem 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);
            }
            query.Append(";");
            return(query.ToString());
        }// GetWriteQuery()
Beispiel #3
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 engineId, DateTime timeStamp, UserInfo userInfo, string attributeString, int side = -1, int qty = 0, double price = 0)
        {
            SignalQueryItem newItem = new SignalQueryItem();

            newItem.StrategyId = strategyId;
            newItem.EngineId   = engineId;

            newItem.RunType  = userInfo.RunType.ToString().ToLower();
            newItem.UserName = userInfo.UserName;

            newItem.TimeStamp = timeStamp;

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

            newItem.AttributeString = attributeString;

            this.m_ItemsToWrite.Add(newItem);
        }//AddItemToWrite()