/// <summary>
        /// 创建ClosePrice2 Update SQL语句。
        /// </summary>
        /// <param name="kLine"></param>
        /// <returns></returns>
        private string CreateClosePrice2UpdateSql(ClosePrice2Entity closePrice)
        {
            string strSql = string.Format(@"update {0}.day_kline set price_close2 = {1}
where contract = '{2}' and exchange = '{3}' and date_time = '{4:yyyy-MM-dd}';",
                                          m_alphaDBName, closePrice.ClosePrice2, closePrice.InstrumentCode, closePrice.Exchange.ToString(), closePrice.SettlementDate);

            return(strSql);
        }
예제 #2
0
        public List <ClosePrice2Entity> ParseClosePrice2()
        {
            string[] lines = File.ReadAllLines(m_filePath);

            List <ClosePrice2Entity> closePriceList = new List <ClosePrice2Entity>();

            decimal  closePrice2 = 0m;
            DateTime currTime    = DateTime.MinValue;

            for (int i = 0; i < lines.Length; i++)
            {
                string[] items = lines[i].Split(new char[] { ',' });
                if (items.Length != LogProtocol.FIELD_COUNT)
                {
                    string text = string.Format("Unsupport fields @{0} line", i);
                    throw new Exception(text);
                }

                DateTime actualTime = GetLogTime(m_cycle, items[LogProtocol.DATE_INDEX], items[LogProtocol.TIME_INDEX]);
                if (actualTime.TimeOfDay > m_logNoonTime)
                {
                    //午盘后数据忽略
                    continue;
                }

                if (IsSameDay(currTime, actualTime))
                {
                    Debug.Assert(actualTime > currTime);
                    closePrice2 = Convert.ToDecimal(items[LogProtocol.CLOSE_INDEX]);
                }
                else
                {
                    if (closePrice2 > 0)
                    {
                        ClosePrice2Entity entity = new ClosePrice2Entity()
                        {
                            SettlementDate = currTime.Date,
                            ClosePrice2    = closePrice2,
                            InstrumentCode = m_instrumentCode,
                            Exchange       = m_market
                        };
                        closePriceList.Add(entity);
                    }
                }

                currTime    = actualTime;
                closePrice2 = Convert.ToDecimal(items[LogProtocol.CLOSE_INDEX]);
            }

            if (closePrice2 > 0)
            {
                Debug.Assert(currTime > DateTime.MinValue);
                ClosePrice2Entity entity = new ClosePrice2Entity()
                {
                    SettlementDate = currTime.Date,
                    ClosePrice2    = closePrice2,
                    InstrumentCode = m_instrumentCode,
                    Exchange       = m_market
                };
                closePriceList.Add(entity);
            }

            return(closePriceList);
        }