コード例 #1
0
        public static void WriteCsv(IEnumerable <PbTick> list, string output)
        {
            if (list == null)
            {
                return;
            }

            PbTickCodec Codec = new PbTickCodec();

            // 将差分数据生成界面数据
            IEnumerable <PbTickView> _list = Codec.Data2View(Codec.Restore(list), false);

            // 保存
            using (TextWriter stream = new StreamWriter(output))
            {
                PbTickView t = new PbTickView();
                stream.WriteLine(t.ToCsvHeader());

                foreach (var l in _list)
                {
                    stream.WriteLine(l);
                }
                stream.Close();
            }
        }
コード例 #2
0
        public PbTick Double2Int(PbTickView tick)
        {
            if (tick == null)
            {
                return(null);
            }

            PbTick field = new PbTick();

            // 利用此机会设置TickSize
            if (Codec == null)
            {
                Codec = new PbTickCodec();
            }
            field.Config = Double2Int(tick.Config);

            Codec.Config = field.Config;
            Codec.UseFlat(flat);

            Codec.SetTurnover(field, tick.Turnover);
            Codec.SetAveragePrice(field, tick.AveragePrice);

            field.LastPrice = Codec.PriceToTick(tick.LastPrice);

            field.Depth1_3     = Double2Int(tick.Depth1_3);
            field.Volume       = tick.Volume;
            field.OpenInterest = tick.OpenInterest;

            field.TradingDay     = tick.TradingDay;
            field.ActionDay      = tick.ActionDay;
            field.Time_HHmm      = tick.Time_HHmm;
            field.Time_____ssf__ = tick.Time_____ssf__;
            field.Time________ff = tick.Time________ff;

            field.Bar    = Double2Int(tick.Bar);
            field.Static = Double2Int(tick.Static);
            field.Split  = Double2Int(tick.Split);


            return(field);
        }
コード例 #3
0
        public PbTickView Int2Double(PbTick tick)
        {
            if (tick == null)
            {
                return(null);
            }

            PbTickView field = new PbTickView();

            // 利用此机会设置TickSize
            if (Codec == null)
            {
                Codec = new PbTickCodec();
            }
            field.Config = Int2Double(tick.Config);

            Codec.Config = tick.Config;
            Codec.UseFlat(flat);

            field.Turnover     = Codec.GetTurnover(tick);
            field.AveragePrice = Codec.GetAveragePrice(tick);

            field.LastPrice = Codec.TickToPrice(tick.LastPrice);

            field.Depth1_3     = Int2Double(tick.Depth1_3);
            field.Volume       = tick.Volume;
            field.OpenInterest = tick.OpenInterest;

            field.TradingDay     = tick.TradingDay;
            field.ActionDay      = tick.ActionDay;
            field.Time_HHmm      = tick.Time_HHmm;
            field.Time_____ssf__ = tick.Time_____ssf__;
            field.Time________ff = tick.Time________ff;

            field.Bar    = Int2Double(tick.Bar);
            field.Static = Int2Double(tick.Static);
            field.Split  = Int2Double(tick.Split);

            return(field);
        }