コード例 #1
0
        public static DataObjectViewer GetViewer(IDataSeries dataSeries)
        {
            if (dataSeries == null)
            {
                return((DataObjectViewer)null);
            }
            switch (DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).DataType)
            {
            case DataType.Trade:
                return((DataObjectViewer) new TradeViewer());

            case DataType.Quote:
                return((DataObjectViewer) new QuoteViewer());

            case DataType.Bar:
                return((DataObjectViewer) new BarViewer());

            case DataType.Daily:
                return((DataObjectViewer) new DailyViewer());

            case DataType.MarketDepth:
                return((DataObjectViewer) new MarketDepthViewer());

            default:
                return((DataObjectViewer)null);
            }
        }
コード例 #2
0
        private void ltvDataSeries_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.InitChart();
            if (this.ltvDataSeries.SelectedItems.Count == 1)
            {
                IDataSeries dataSeries = (this.ltvDataSeries.SelectedItems[0] as DataSeriesViewItem).DataSeries;
                this.dataSeriesViewer.SetDataSeries(dataSeries);
                switch (DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).DataType)
                {
                case DataType.Trade:
                    this.InitChart((ChartPanel) new TradeChartPanel(), dataSeries);
                    break;

                case DataType.Quote:
                    this.InitChart((ChartPanel) new QuoteChartPanel(), dataSeries);
                    break;

                case DataType.Bar:
                case DataType.Daily:
                    this.InitChart((ChartPanel) new BarChartPanel(), dataSeries);
                    break;
                }
            }
            else
            {
                this.dataSeriesViewer.SetDataSeries((IDataSeries)null);
            }
        }
コード例 #3
0
        private void ctxDataSeries_ExportCSV_Click(object sender, EventArgs e)
        {
            List <IDataSeries> list = new List <IDataSeries>();

            foreach (DataSeriesViewItem dataSeriesViewItem in this.ltvDataSeries.SelectedItems)
            {
                DataType dataType = DataSeriesHelper.GetDataSeriesInfo(dataSeriesViewItem.DataSeries.Name).DataType;
                switch (dataType)
                {
                case DataType.Unknown:
                case DataType.MarketDepth:
                    int num = (int)MessageBox.Show((IWin32Window)this, string.Format("Cannot export {0} series to CSV format.", (object)dataType), "Export To CSV", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    continue;

                default:
                    list.Add(dataSeriesViewItem.DataSeries);
                    continue;
                }
            }
            if (list.Count <= 0)
            {
                return;
            }
            DataSeriesExportForm seriesExportForm = new DataSeriesExportForm();

            seriesExportForm.Init(list.ToArray());
            int num1 = (int)seriesExportForm.ShowDialog((IWin32Window)this);

            seriesExportForm.Dispose();
        }
コード例 #4
0
ファイル: QuickChartForm.cs プロジェクト: zhuzhenping/FreeOQ
        protected override void OnInit()
        {
            this.instrument = this.Key as Instrument;
            DataSeriesList dataSeries = this.instrument.GetDataSeries();

            this.template = Global.ChartManager.Templates["Default Template"];
            this.Text     = "Chart [" + ((FIXInstrument)this.instrument).Symbol + "]";
            this.instrumentListSource.AddInstrument(this.instrument);
            this.instrumentListSource.SelectedInstrument = this.instrument;
            IEnumerator enumerator = dataSeries.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    IDataSeries idataSeries = (IDataSeries)enumerator.Current;
                    string      key         = DataSeriesHelper.SeriesNameToString(idataSeries.Name);
                    if (key.StartsWith("Bar") || key == "Daily")
                    {
                        this.seriesNames.Add(key, idataSeries.Name);
                        this.instrumentListSource.AddSeries(this.instrument, new BarSeries(key));
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            this.instrumentListSource.Refresh();
        }
コード例 #5
0
ファイル: BarEditor.cs プロジェクト: zhuzhenping/FreeOQ
 public void InitBarSettings(string seriesName)
 {
     if (!DataSeriesHelper.TryGetBarTypeSize(seriesName, out this.barType, out this.barSize))
     {
         throw new Exception("Cannot edit unknown bar.");
     }
 }
コード例 #6
0
 public ExportTaskViewItem(ExportTask task) : base(new string[4])
 {
     this.Task             = task;
     this.SubItems[0].Text = string.Format("{0} {1}", (object)DataSeriesHelper.GetDataSeriesInfo(task.DataSeries.Name).Symbol, (object)DataSeriesHelper.SeriesNameToString(task.DataSeries.Name));
     this.SubItems[1].Text = task.OutputFileName;
     this.UpdateState();
 }
コード例 #7
0
        public void RefreshName()
        {
            string name = ((TimeSeries)this.series).Name;

            this.name = "";
            if (name.StartsWith(((FIXInstrument)this.instrument).Symbol))
            {
                string str1 = name.Remove(0, ((FIXInstrument)this.instrument).Symbol.Length);
                if (str1.StartsWith(" ("))
                {
                    string str2 = str1.Remove(0, 2);
                    if (str2.EndsWith(")"))
                    {
                        string[] strArray = str2.Substring(0, str2.Length - 1).Split(new char[1]
                        {
                            ' '
                        });
                        if (strArray.Length == 2 && Enum.IsDefined(typeof(BarType), (object)strArray[0]))
                        {
                            BarType barType = (BarType)Enum.Parse(typeof(BarType), strArray[0]);
                            long    result;
                            if (long.TryParse(strArray[1], out result))
                            {
                                this.name = DataSeriesHelper.BarTypeSizeToString(barType, result);
                            }
                        }
                    }
                }
            }
            if (!(this.name == ""))
            {
                return;
            }
            this.name = ((TimeSeries)this.series).Name;
        }
コード例 #8
0
 private void Compress()
 {
     if (this.ltvDataSeries.CheckedItems.Count == 0)
     {
         int num1 = (int)MessageBox.Show((IWin32Window)this, "No instruments selected.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else
     {
         List <CompressorTask> list = new List <CompressorTask>();
         foreach (DataSeriesViewItem dataSeriesViewItem in this.ltvDataSeries.CheckedItems)
         {
             list.Add(new CompressorTask()
             {
                 InputSeries        = dataSeriesViewItem.DataSeries,
                 Instrument         = InstrumentManager.Instruments[DataSeriesHelper.GetDataSeriesInfo(dataSeriesViewItem.DataSeries.Name).Symbol],
                 DataSource         = (DataSource)this.cbxDataSources.SelectedItem,
                 BarTypeSize        = (BarTypeSize)this.cbxOutputBars.SelectedItem,
                 ExistentDataSeries = (ExistentDataSeries)this.cbxExistentDataSeries.SelectedItem
             });
         }
         CompressorForm compressorForm = new CompressorForm();
         compressorForm.Init(list.ToArray());
         int num2 = (int)compressorForm.ShowDialog((IWin32Window)this);
         compressorForm.Dispose();
     }
 }
コード例 #9
0
        private void InitDataSources()
        {
            SortedList <BarDataSource, bool> sortedList = new SortedList <BarDataSource, bool>((IComparer <BarDataSource>) new BarDataSourceComparer());
            bool flag1 = false;
            bool flag2 = false;

            foreach (IDataSeries idataSeries in this.seriesList)
            {
                switch (DataSeriesHelper.GetDataSeriesInfo(idataSeries.Name).DataType)
                {
                case DataType.Trade:
                    flag1 = true;
                    break;

                case DataType.Quote:
                    flag2 = true;
                    break;

                case DataType.Bar:
                    BarType barType;
                    long    barSize;
                    if (DataSeriesHelper.TryGetBarTypeSize(idataSeries.Name, out barType, out barSize) && (barType != BarType.Time || barSize != 86400L))
                    {
                        sortedList[new BarDataSource(barType, barSize)] = true;
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            this.cbxDataSources.BeginUpdate();
            this.cbxDataSources.Items.Clear();
            if (flag1)
            {
                this.cbxDataSources.Items.Add((object)new DataSource(DataSourceInput.Trade));
            }
            if (flag2)
            {
                this.cbxDataSources.Items.Add((object)new DataSource(DataSourceInput.Bid));
                this.cbxDataSources.Items.Add((object)new DataSource(DataSourceInput.Ask));
                this.cbxDataSources.Items.Add((object)new DataSource(DataSourceInput.BidAsk));
                this.cbxDataSources.Items.Add((object)new DataSource(DataSourceInput.Middle));
                this.cbxDataSources.Items.Add((object)new DataSource(DataSourceInput.Spread));
            }
            foreach (object obj in (IEnumerable <BarDataSource>)sortedList.Keys)
            {
                this.cbxDataSources.Items.Add(obj);
            }
            if (this.cbxDataSources.Items.Count > 0)
            {
                this.cbxDataSources.SelectedIndex = 0;
            }
            this.cbxDataSources.EndUpdate();
        }
コード例 #10
0
        protected override void OnInit()
        {
            BarSeries barSeries = new BarSeries(DataSeriesHelper.SeriesNameToString(this.dataSeries.Name));

            foreach (Bar bar in (IEnumerable)this.dataSeries)
            {
                barSeries.Add(bar);
            }
            this.chart.ApplyDefaultTemplate();
            this.chart.SetMainSeries((DoubleSeries)barSeries, true);
        }
コード例 #11
0
 public override string ToString()
 {
     if (this.barSize <= 0)
     {
         return(string.Empty);
     }
     else
     {
         return(DataSeriesHelper.BarTypeSizeToString(this.barType, this.barSize));
     }
 }
コード例 #12
0
ファイル: BarTypeSize.cs プロジェクト: zhuzhenping/FreeOQ
 public override string ToString()
 {
     if (this.BarSize == 86400)
     {
         return("Daily");
     }
     else
     {
         return(string.Format("Bar {0}", DataSeriesHelper.BarTypeSizeToString(this.BarType, this.BarSize)));
     }
 }
コード例 #13
0
        private void UpdateDataSeries()
        {
            this.ltvDataSeries.BeginUpdate();
            this.ltvDataSeries.Items.Clear();
            if (this.cbxDataSources.SelectedItem != null)
            {
                DataSource dataSource = (DataSource)this.cbxDataSources.SelectedItem;
                foreach (IDataSeries dataSeries in this.seriesList)
                {
                    DataType dataType = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).DataType;
                    bool     flag     = false;
                    switch (dataSource.Input)
                    {
                    case DataSourceInput.Trade:
                        flag = dataType == DataType.Trade;
                        break;

                    case DataSourceInput.Bid:
                    case DataSourceInput.Ask:
                    case DataSourceInput.BidAsk:
                    case DataSourceInput.Middle:
                    case DataSourceInput.Spread:
                        flag = dataType == DataType.Quote;
                        break;

                    case DataSourceInput.Bar:
                        BarType barType;
                        long    barSize;
                        if (dataType == DataType.Bar && DataSeriesHelper.TryGetBarTypeSize(dataSeries.Name, out barType, out barSize))
                        {
                            BarDataSource barDataSource = (BarDataSource)dataSource;
                            flag = barDataSource.BarType == barType && barDataSource.BarSize == barSize;
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (flag)
                    {
                        this.ltvDataSeries.Items.Add((ListViewItem) new DataSeriesViewItem(dataSeries));
                    }
                }
            }
            this.ltvDataSeries.EndUpdate();
            if (!this.autoCheck)
            {
                return;
            }
            this.SetAllDataSeriesChecked(true);
        }
コード例 #14
0
        public void Init(IDataSeries[] seriesList)
        {
            this.ltvExportTasks.BeginUpdate();
            this.ltvExportTasks.Items.Clear();
            foreach (IDataSeries dataSeries in seriesList)
            {
                string str = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).Symbol;
                foreach (char oldChar in Path.GetInvalidFileNameChars())
                {
                    str = str.Replace(oldChar, '_');
                }
                string             outputFileName     = string.Format("{0}.{1}.csv", (object)str, (object)DataSeriesHelper.SeriesNameToString(dataSeries.Name));
                ExportTask         exportTask         = new ExportTask(dataSeries, outputFileName);
                ExportTaskViewItem exportTaskViewItem = new ExportTaskViewItem(exportTask);
                this.taskItems.Add(exportTask, exportTaskViewItem);
                this.ltvExportTasks.Items.Add((ListViewItem)exportTaskViewItem);
            }
            this.ltvExportTasks.EndUpdate();
            this.lblCurrentProgress.Text = "";
            this.pgbTotal.Maximum        = seriesList.Length;
            List <DateTime> list = new List <DateTime>();

            foreach (IDataSeries idataSeries in seriesList)
            {
                if (idataSeries.Count > 0)
                {
                    list.Add(idataSeries.FirstDateTime);
                    list.Add(idataSeries.LastDateTime);
                }
            }
            if (list.Count == 0)
            {
                this.dtpRangeBegin.Value = DateTime.Today;
                this.dtpRangeEnd.Value   = DateTime.Today;
            }
            else
            {
                this.dtpRangeBegin.Value = Enumerable.Min <DateTime>((IEnumerable <DateTime>)list).Date;
                this.dtpRangeEnd.Value   = Enumerable.Max <DateTime>((IEnumerable <DateTime>)list).Date;
            }
            this.OnExportRangeChanged();
        }
コード例 #15
0
 public void Update()
 {
     if (this.dataSeries.Count == this.objectsCount)
     {
         return;
     }
     this.objectsCount     = this.dataSeries.Count;
     this.SubItems[0].Text = DataSeriesHelper.SeriesNameToString(this.dataSeries.Name);
     this.SubItems[1].Text = this.dataSeries.Count.ToString("n0");
     if (this.dataSeries.Count > 0)
     {
         this.SubItems[2].Text = this.dataSeries.FirstDateTime.ToString();
         this.SubItems[3].Text = this.dataSeries.LastDateTime.ToString();
     }
     else
     {
         this.SubItems[2].Text = "-";
         this.SubItems[3].Text = "-";
     }
 }
コード例 #16
0
ファイル: BarEditor.cs プロジェクト: zhuzhenping/FreeOQ
 protected override void OnInit(IDataObject dataObject, int decimalPlaces)
 {
     if (dataObject != null)
     {
         Bar bar = (Bar)dataObject;
         this.dtpDateTime.Value   = bar.BeginTime;
         this.dtpEnd.Value        = bar.EndTime;
         this.nudOpen.Value       = (Decimal)bar.Open;
         this.nudHigh.Value       = (Decimal)bar.High;
         this.nudLow.Value        = (Decimal)bar.Low;
         this.nudClose.Value      = (Decimal)bar.Close;
         this.nudVolume.Value     = (Decimal)bar.Volume;
         this.nudOpenInt.Value    = (Decimal)bar.OpenInt;
         this.dtpDateTime.Enabled = false;
         this.dtpEnd.Enabled      = false;
     }
     else
     {
         DateTime now = DateTime.Now;
         this.dtpDateTime.Value   = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
         this.dtpDateTime.Enabled = true;
         if (this.barType == BarType.Time)
         {
             this.dtpEnd.Value   = this.dtpDateTime.Value.AddSeconds((double)this.barSize);
             this.dtpEnd.Enabled = false;
         }
         else
         {
             this.dtpEnd.Value   = this.dtpDateTime.Value;
             this.dtpEnd.Enabled = true;
         }
     }
     this.tbxBarType.Text        = DataSeriesHelper.BarTypeSizeToString(this.barType, this.barSize);
     this.nudOpen.DecimalPlaces  = decimalPlaces;
     this.nudHigh.DecimalPlaces  = decimalPlaces;
     this.nudLow.DecimalPlaces   = decimalPlaces;
     this.nudClose.DecimalPlaces = decimalPlaces;
 }
コード例 #17
0
        private void ctxDataSeries_CompressBars_Click(object sender, EventArgs e)
        {
            IDataSeries dataSeries = (this.ltvDataSeries.SelectedItems[0] as DataSeriesViewItem).DataSeries;
            DataType    dataType   = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).DataType;

            switch (dataType)
            {
            case DataType.Trade:
            case DataType.Quote:
            case DataType.Bar:
                CompressBarsForm compressBarsForm = new CompressBarsForm();
                compressBarsForm.Init(new IDataSeries[1]
                {
                    dataSeries
                }, 1 != 0);
                int num1 = (int)compressBarsForm.ShowDialog((IWin32Window)this);
                compressBarsForm.Dispose();
                break;

            default:
                int num2 = (int)MessageBox.Show((IWin32Window)this, string.Format("Cannot compress bars from {0} series.", (object)dataType), "Compress Bars", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                break;
            }
        }
コード例 #18
0
        private void DoExport(ExportSettings settings, ExportTask task)
        {
            try
            {
                IDataSeries dataSeries = task.DataSeries;
                FileInfo    fileInfo   = new FileInfo(string.Format("{0}\\{1}", (object)settings.Directory.FullName, (object)task.OutputFileName));
                DataType    dataType   = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).DataType;
                task.State = ExportTaskState.Exporting;
                this.UpdateTaskState(task);
                this.SetLabelText(this.lblCurrentProgress, string.Format("{0} {1} -> {2}", (object)DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).Symbol, (object)DataSeriesHelper.SeriesNameToString(dataSeries.Name), (object)fileInfo.FullName));
                this.SetProgressValue(this.pgbCurrent, 0);
                Thread.Sleep(0);
                DataExporter dataExporter;
                switch (dataType)
                {
                case DataType.Trade:
                    dataExporter = (DataExporter) new TradeExporter();
                    break;

                case DataType.Quote:
                    dataExporter = (DataExporter) new QuoteExporter();
                    break;

                case DataType.Bar:
                    dataExporter = (DataExporter) new BarExporter();
                    break;

                case DataType.Daily:
                    dataExporter = (DataExporter) new DailyExporter();
                    break;

                default:
                    throw new NotSupportedException(string.Format("Insupported data type - {0}", (object)dataType));
                }
                StreamWriter streamWriter = new StreamWriter(fileInfo.FullName);
                streamWriter.WriteLine(this.ToString(dataExporter.GetHeader()));
                int num1 = 0;
                int num2 = 0;
                for (int index = 0; index < dataSeries.Count; ++index)
                {
                    IDataObject idataObject = dataSeries[index] as IDataObject;
                    if (!this.pendingCancel)
                    {
                        DateTime dateTime = idataObject.DateTime;
                        if (!(dateTime < settings.RangeBegin) && !(dateTime > settings.RangeEnd))
                        {
                            streamWriter.WriteLine(this.ToString(dataExporter.DataObjectToString(idataObject)));
                        }
                        ++num1;
                        int num3 = (int)((long)num1 * 100L / (long)dataSeries.Count);
                        if (num3 > num2)
                        {
                            num2 = num3;
                            this.SetProgressValue(this.pgbCurrent, num2);
                        }
                        Thread.Sleep(0);
                    }
                    else
                    {
                        break;
                    }
                }
                streamWriter.Close();
                if (this.pendingCancel)
                {
                    task.State = ExportTaskState.Error;
                    task.Text  = "Aborted";
                }
                else
                {
                    task.State = ExportTaskState.Done;
                    task.Text  = "Completed";
                }
                this.UpdateTaskState(task);
            }
            catch (Exception ex)
            {
                task.State = ExportTaskState.Error;
                task.Text  = ((object)ex).ToString();
                this.UpdateTaskState(task);
            }
        }
コード例 #19
0
 public override string ToString()
 {
     return(DataSeriesHelper.BarTypeSizeToString(BarType.Time, this.BarSize));
 }
コード例 #20
0
 public override string ToString()
 {
     return(string.Format("Bar {0}", DataSeriesHelper.BarTypeSizeToString(this.BarType, this.BarSize)));
 }
コード例 #21
0
 public BarSeriesMenuItem(BarType barType, long barSize)
 {
     this.barType = barType;
     this.barSize = barSize;
     this.Text    = DataSeriesHelper.BarTypeSizeToString(barType, barSize);
 }
コード例 #22
0
 public DataSeriesViewItem(IDataSeries dataSeries) : base(new string[1])
 {
     this.DataSeries       = dataSeries;
     this.SubItems[0].Text = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name).Symbol;
     this.ImageIndex       = 0;
 }
コード例 #23
0
        private void Init()
        {
            this.seriesLists.Clear();
            IEnumerator enumerator1 = DataManager.Server.GetDataSeries().GetEnumerator();

            try
            {
                while (enumerator1.MoveNext())
                {
                    IDataSeries    dataSeries     = (IDataSeries)enumerator1.Current;
                    DataSeriesInfo dataSeriesInfo = DataSeriesHelper.GetDataSeriesInfo(dataSeries.Name);
                    Instrument     instrument     = InstrumentManager.Instruments[dataSeriesInfo.Symbol];
                    if (instrument != null)
                    {
                        DataTypeItem dataTypeItem = (DataTypeItem)null;
                        switch (dataSeriesInfo.DataType)
                        {
                        case DataType.Trade:
                        case DataType.Quote:
                        case DataType.Daily:
                        case DataType.MarketDepth:
                            dataTypeItem = new DataTypeItem(dataSeriesInfo.DataType);
                            break;

                        case DataType.Bar:
                            dataTypeItem = (DataTypeItem) new BarDataTypeItem(dataSeriesInfo.BarType, dataSeriesInfo.BarSize);
                            break;
                        }
                        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));
                        }
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator1 as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            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 enumerator2 = this.ltvDataSeries.Items.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            ListViewItem listViewItem = (ListViewItem)enumerator2.Current;
                            if (hashSet.Contains(listViewItem.Text))
                            {
                                listViewItem.Selected = true;
                            }
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable = enumerator2 as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
            }
        }