Beispiel #1
0
 private void InitDataSeriesList()
 {
     this.ltvDataSeries.BeginUpdate();
     this.ltvDataSeries.Items.Clear();
     foreach (DataSeries dataSeries in this.framework.DataManager.GetDataSeriesList(this.instrument, (string)null))
     {
         byte dataType = DataSeriesNameHelper.GetDataType(dataSeries);
         if ((int)dataType == 6)
         {
             BarType barType;
             long    barSize;
             if (DataSeriesNameHelper.TryGetBarTypeSize(dataSeries, out barType, out barSize))
             {
                 this.ltvDataSeries.Items.Add((ListViewItem) new DataSeriesViewItem(dataSeries, dataType, new BarType?(barType), new long?(barSize)));
             }
         }
         else
         {
             this.ltvDataSeries.Items.Add((ListViewItem) new DataSeriesViewItem(dataSeries, dataType, new BarType?(), new long?()));
         }
     }
     this.ltvDataSeries.EndUpdate();
 }
        public InstrumentDataWidget(string symbol)
        {
            Build();
            // dsTvw.CursorChanged += HandleCursorChanged;
            dsTvw.Selection.Changed += HandleChanged;
            dsTvw.AppendColumn("Data Series", new CellRendererText(), "text", 0);
            dsTvw.AppendColumn("Object Count", new CellRendererText(), "text", 1);
            dsTvw.AppendColumn("First DateTime", new CellRendererText(), "text", 2);
            dsTvw.AppendColumn("Last DateTime", new CellRendererText(), "text", 3);
            dsTvw.HeadersVisible = true;

            detailTvw.AppendColumn("DateTime", new CellRendererText(), "text", 0);
            detailTvw.AppendColumn("Price", new CellRendererText(), "text", 0);
            detailTvw.AppendColumn("Size", new CellRendererText(), "text", 0);
            detailTvw.HeadersVisible = true;

            mapping = new Dictionary <TreeIter, DataSeries>();
            var model = new TreeStore(typeof(string), typeof(long), typeof(string), typeof(string));

            dsTvw.Model     = model;
            detailModel     = new TreeStore(typeof(string), typeof(double), typeof(double));
            detailTvw.Model = detailModel;

            var f = Framework.Current;

            this.instrument = f.InstrumentManager.Get(symbol);
            foreach (var ds in f.DataManager.GetDataSeriesList(this.instrument, null))
            {
                byte    dataType = DataSeriesNameHelper.GetDataType(ds);
                BarType barType;
                long    barSize;
                DataSeriesNameHelper.TryGetBarTypeSize(ds, out barType, out barSize);
                var name = GetSeriesName(dataType, barType, barSize);
                var iter = model.AppendValues(name, ds.Count, ds.DateTime1.ToString(), ds.DateTime2.ToString());
                mapping.Add(iter, ds);
            }
        }
        private static void EnsureDataReady()
        {
            var f = Framework.Current;
            var i = f.InstrumentManager.Get(symbol);

            if (i == null)
            {
                i = new Instrument(InstrumentType.FX, symbol, string.Empty, CurrencyId.USD);
                f.InstrumentManager.Add(i, true);
            }

            var filename = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..", "..", "..", "Data", string.Format("{0}.csv", symbol)));

            if (File.Exists(filename))
            {
                var name = DataSeriesNameHelper.GetName(i, BarType.Time, 60);
                var bs   = new BarSeries(name);
                using (var reader = new StreamReader(filename)) {
                    var line = reader.ReadLine();
                    while (line != null)
                    {
                        var fields        = line.Split(new char[] { ',' });
                        var closeDateTime = DateTime.ParseExact(string.Format("{0} {1}", fields [0], fields [1]), "yyyy.MM.dd HH:mm", CultureInfo.InvariantCulture);
                        var openDateTime  = closeDateTime.Subtract(TimeSpan.FromMinutes(1));
                        var open          = double.Parse(fields [2]);
                        var high          = double.Parse(fields [3]);
                        var low           = double.Parse(fields [4]);
                        var close         = double.Parse(fields [5]);
                        var vol           = long.Parse(fields [6]);
                        bs.Add(new Bar(openDateTime, closeDateTime, i.Id, BarType.Time, 60, open, high, low, close, vol, 0));
                        line = reader.ReadLine();
                    }
                }
                f.DataManager.Save(bs, SaveMode.Add);
            }
        }
Beispiel #4
0
        private void NewDataSeries(byte dataType, BarType?barType, long?barSize)
        {
            string name = (int)dataType == 6 ? DataSeriesNameHelper.GetName(this.instrument, barType.Value, barSize.Value) : DataSeriesNameHelper.GetName(this.instrument, dataType);

            if (this.framework.DataServer.GetDataSeries(name) == null)
            {
                this.framework.DataServer.AddDataSeries(name);
                this.InitDataSeriesList();
                this.InitDataSeriesViewer();
            }
            else
            {
                int num = (int)MessageBox.Show((IWin32Window)this, "The series already exists.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Beispiel #5
0
        private void Init()
        {
            this.seriesLists.Clear();
            foreach (Instrument instrument in this.framework.InstrumentManager.Instruments)
            {
                foreach (DataSeries dataSeries in this.framework.DataManager.GetDataSeriesList(instrument, (string)null))
                {
                    byte         dataType     = DataSeriesNameHelper.GetDataType(dataSeries);
                    DataTypeItem dataTypeItem = (DataTypeItem)null;
                    if ((int)dataType == 6)
                    {
                        BarType barType;
                        long    barSize;
                        if (DataSeriesNameHelper.TryGetBarTypeSize(dataSeries, out barType, out barSize))
                        {
                            dataTypeItem = new DataTypeItem(dataType, new BarType?(barType), new long?(barSize));
                        }
                    }
                    else
                    {
                        dataTypeItem = new DataTypeItem(dataType, new BarType?(), new long?());
                    }
                    if (dataTypeItem != null)
                    {
                        List <InstrumentDataSeries> list;
                        if (!this.seriesLists.TryGetValue(dataTypeItem, out list))
                        {
                            list = new List <InstrumentDataSeries>();
                            this.seriesLists.Add(dataTypeItem, list);
                        }
                        list.Add(new InstrumentDataSeries(instrument, dataSeries, dataTypeItem));
                    }
                }
            }
            string           str     = this.trvDataTypes.SelectedNode == null ? (string)null : this.trvDataTypes.SelectedNode.Text;
            HashSet <string> hashSet = new HashSet <string>();

            foreach (ListViewItem listViewItem in this.ltvDataSeries.SelectedItems)
            {
                hashSet.Add(listViewItem.Text);
            }
            this.trvDataTypes.BeginUpdate();
            this.trvDataTypes.Nodes.Clear();
            foreach (DataTypeItem dataTypeItem in (IEnumerable <DataTypeItem>) this.seriesLists.Keys)
            {
                this.trvDataTypes.Nodes.Add((TreeNode) new DataTypeNode(dataTypeItem));
            }
            this.trvDataTypes.EndUpdate();
            this.UpdateDataSeriesList((DataTypeItem)null);
            if (str == null)
            {
                return;
            }
            foreach (TreeNode treeNode in this.trvDataTypes.Nodes)
            {
                if (treeNode.Text == str)
                {
                    this.trvDataTypes.SelectedNode = treeNode;
                    if (hashSet.Count <= 0)
                    {
                        break;
                    }
                    IEnumerator enumerator = this.ltvDataSeries.Items.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            ListViewItem listViewItem = (ListViewItem)enumerator.Current;
                            if (hashSet.Contains(listViewItem.Text))
                            {
                                listViewItem.Selected = true;
                            }
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable = enumerator as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
            }
        }