Exemplo n.º 1
0
        private void ExportCsv_Click(object sender, RoutedEventArgs e)
        {
            EDataType     eDataType = (EDataType)CmbBox.SelectedItem;
            StringBuilder sb        = new StringBuilder();

            switch (eDataType)
            {
            case EDataType.Tick:
                sb.AppendLine($@"TradingDay,TickNow,LastPrice,VolumeNow,BidPrice1,AskPrice1,BidVolume1,AskVolume1,HighPrice,OpenPrice,LowPrice,Change,Volume,Turnover");
                break;

            case EDataType.Min:
                sb.AppendLine($@"TradingDate,BeginTimeStr,EndTimeStr,High,Open,Low,Close,Volume,Turnover");
                break;

            default:
                break;
            }

            foreach (var data in MainListView.SelectedItems)
            {
                switch (eDataType)
                {
                case EDataType.Tick:
                    ViewTick tick = (ViewTick)data;
                    sb.AppendLine($@"{tick.TradingDay},{tick.TickNow},{tick.LastPrice},{tick.VolumeNow},{tick.BidPrice1},{tick.AskPrice1},{tick.BidVolume1},{tick.AskVolume1},{tick.HighPrice},{tick.OpenPrice},{tick.LowPrice},{tick.Change},{tick.Volume},{tick.Turnover}");
                    break;

                case EDataType.Min:
                    ViewMin min = (ViewMin)data;
                    sb.AppendLine($@"{min.TradingDate},{min.BeginTimeStr},{min.EndTimeStr},{min.High},{min.Open},{min.Low},{min.Close},{min.Volume},{min.Turnover}");
                    break;

                default:
                    break;
                }
            }
            CsvProxy.AppendToCsv(sb.ToString(), TbxPath.Text, "data.csv");
        }
Exemplo n.º 2
0
        private void ReadTick()
        {
            string strSrc   = ConfigurationManager.AppSettings["futuretick"];
            string futureid = TbxInstrumentId.Text;
            string strFile  = System.IO.Path.Combine(strSrc, Convert.ToDateTime(DpBeginDate.Text).ToString("yyyyMMdd"));

            strFile = System.IO.Path.Combine(strFile, futureid + ".tk");
            if (futureid.ToLower() != "index")
            {
                MqTickReader mqTickReader = new MqTickReader(strFile, futureid, EnumMarket.期货, "");
                List <Tick>  ticklist     = new List <Tick>();
                if (!mqTickReader.Read(ticklist, 0, int.MaxValue))
                {
                }
                MainListView.Items.Clear();
                double preVolume = 0;
                foreach (Tick tick in ticklist)
                {
                    ViewTick viewTick = new ViewTick(tick, preVolume);
                    MainListView.Items.Add(viewTick);
                    preVolume = viewTick.Volume;
                }
            }
        }