예제 #1
0
        private static void ConvertCSV(string csvFile)
        {
            string[] sData = LoadCSV(csvFile);
            if (sData == null)
            {
                return;
            }

            bool             bConvert = false;
            SeriesSymbolData cMSeries = null, cDSeries = null;

            if (logger.IsInfoEnabled)
            {
                logger.Info("[Convert] 開始轉換 CSV 期貨檔案資訊...");
            }

            string[] sItems    = sData[0].Split(',');
            string   sSymbolId = null;

            bConvert = cTargetSymbols.TryGetValue(Path.GetFileNameWithoutExtension(csvFile), out sSymbolId);

            if (bConvert)
            {
                int iLength = sData.Length;
                cMSeries = CreateSeries(sSymbolId, EResolution.Minute);
                cMSeries.SetRange(iLength);
                cMSeries.AdjustSize(iLength, true);

                for (int i = iLength - 1; i >= 0; i--)
                {
                    sItems = sData[i].Split(',');
                    DateTime cTime   = DateTime.Parse(sItems[0]);
                    double   dOpen   = double.Parse(sItems[1]);
                    double   dHigh   = double.Parse(sItems[2]);
                    double   dLow    = double.Parse(sItems[3]);
                    double   dClose  = double.Parse(sItems[4]);
                    double   dVolume = double.Parse(sItems[5]);
                    cMSeries.AddSeries(cTime, dOpen, dHigh, dLow, dClose, dVolume, false);
                }

                cDSeries = CreateSeries(sSymbolId, EResolution.Day);
                cMSeries.Merge(cDSeries);

                FileAdapter cAdapter = new FileAdapter(Settings.GlobalSettings.Settings.DataPath, true);
                cAdapter.Write(cMSeries);
                cAdapter.Write(cDSeries);

                cMSeries.Dispose();
                cDSeries.Dispose();
            }
        }
예제 #2
0
 /// <summary>
 ///   加入商品歷史資料
 /// </summary>
 /// <param name="time">時間</param>
 /// <param name="open">開盤價</param>
 /// <param name="high">最高價</param>
 /// <param name="low">最低價</param>
 /// <param name="close">收盤價</param>
 /// <param name="volume">成交量</param>
 protected void AddSeries(DateTime time, double open, double high, double low, double close, double volume)
 {
     __cSeries.AddSeries(time, open, high, low, close, volume, false);
 }