Beispiel #1
0
 protected override void OnInit(IDataObject dataObject, int decimalPlaces)
 {
     if (dataObject != null)
     {
         Trade trade = (Trade)dataObject;
         this.nudPrice.Value = (Decimal)trade.Price;
         this.nudSize.Value  = (Decimal)trade.Size;
     }
     this.nudPrice.DecimalPlaces = decimalPlaces;
 }
Beispiel #2
0
 protected override void OnInit(IDataObject dataObject, int decimalPlaces)
 {
   if (dataObject != null)
   {
     Quote quote = (Quote) dataObject;
     this.nudBid.Value = (Decimal) quote.Bid;
     this.nudBidSize.Value = (Decimal) quote.BidSize;
     this.nudAsk.Value = (Decimal) quote.Ask;
     this.nudAskSize.Value = (Decimal) quote.AskSize;
   }
   this.nudBid.DecimalPlaces = decimalPlaces;
   this.nudAsk.DecimalPlaces = decimalPlaces;
 }
Beispiel #3
0
 protected override void OnInit(IDataObject dataObject, int decimalPlaces)
 {
     if (dataObject != null)
     {
         Quote quote = (Quote)dataObject;
         this.nudBid.Value     = (Decimal)quote.Bid;
         this.nudBidSize.Value = (Decimal)quote.BidSize;
         this.nudAsk.Value     = (Decimal)quote.Ask;
         this.nudAskSize.Value = (Decimal)quote.AskSize;
     }
     this.nudBid.DecimalPlaces = decimalPlaces;
     this.nudAsk.DecimalPlaces = decimalPlaces;
 }
Beispiel #4
0
 protected override void OnInit(IDataObject dataObject, int decimalPlaces)
 {
     if (dataObject != null)
     {
         Daily daily = (Daily)dataObject;
         this.nudOpen.Value    = (Decimal)((Bar)daily).Open;
         this.nudHigh.Value    = (Decimal)((Bar)daily).High;
         this.nudLow.Value     = (Decimal)((Bar)daily).Low;
         this.nudClose.Value   = (Decimal)((Bar)daily).Close;
         this.nudVolume.Value  = (Decimal)((Bar)daily).Volume;
         this.nudOpenInt.Value = (Decimal)((Bar)daily).OpenInt;
     }
     this.nudOpen.DecimalPlaces  = decimalPlaces;
     this.nudHigh.DecimalPlaces  = decimalPlaces;
     this.nudLow.DecimalPlaces   = decimalPlaces;
     this.nudClose.DecimalPlaces = decimalPlaces;
 }
Beispiel #5
0
        private void AddObject()
        {
            DataObjectEditor editor = this.viewer.GetEditor();

            if (editor != null)
            {
                editor.Init((IDataObject)null, this.priceFormat);
                if (editor.ShowDialog((IWin32Window)this) == DialogResult.OK)
                {
                    IDataObject dataObject = editor.GetDataObject();
                    this.dataSeries.Add(dataObject.DateTime, dataObject);
                    this.viewer.ResetLastItem();
                    this.listView.VirtualListSize = this.dataSeries.Count;
                }
                editor.Dispose();
            }
            else
            {
                int num = (int)MessageBox.Show((IWin32Window)this, "Operation is not supported for this type of objects", "Add New", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Beispiel #6
0
 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;
 }
Beispiel #7
0
    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;
    }
Beispiel #8
0
        public void Init(IDataObject dataObject, string priceFormat)
        {
            int decimalPlaces = 2;

            try
            {
                decimalPlaces = int.Parse(priceFormat[1].ToString());
            }
            catch
            {
            }
            if (dataObject == null)
            {
                this.dtpDateTime.Value = DateTime.Now;
                this.Text = string.Format("New {0}", (object)this.ObjectName);
            }
            else
            {
                this.dtpDateTime.Value   = dataObject.DateTime;
                this.dtpDateTime.Enabled = false;
                this.Text = string.Format("Edit {0}", (object)this.ObjectName);
            }
            this.OnInit(dataObject, decimalPlaces);
        }
Beispiel #9
0
        private void PerformTask(CompressorTaskItem item)
        {
            this.SetCurrentTaskTitle(item.Title);
            this.SetCurrentProgress(0);
            item.Status = CompressorTaskStatus.Processing;
            this.UpdateTaskViewItem(item);
            try
            {
                string str;
                if (item.Task.BarTypeSize.BarType == BarType.Time && item.Task.BarTypeSize.BarSize == 86400)
                {
                    str = string.Format("{0}{1}{2}", (object)((FIXInstrument)item.Task.Instrument).Symbol, '.', "Daily");
                }
                else
                {
                    str = string.Format("{0}{1}{2}{1}{3}{1}{4}", (object)((FIXInstrument)item.Task.Instrument).Symbol, '.', "Bar", item.Task.BarTypeSize.BarType, item.Task.BarTypeSize.BarSize);
                }
                IDataSeries barSeries = DataManager.Server.GetDataSeries(str);
                if (barSeries == null)
                {
                    barSeries = DataManager.Server.AddDataSeries(str);
                }
                else
                {
                    switch (item.Task.ExistentDataSeries)
                    {
                    case ExistentDataSeries.Overwrite:
                        barSeries.Clear();
                        break;

                    case ExistentDataSeries.Skip:
                        item.Status  = CompressorTaskStatus.Done;
                        item.Message = "Bar series already exists - task aborted.";
                        return;
                    }
                }
                int           compressedBars = 0;
                BarCompressor compressor     = BarCompressor.GetCompressor(item.Task.BarTypeSize, item.Task.DataSource);
                compressor.NewCompressedBar += (EventHandler <CompressedBarEventArgs>)((sender, args) =>
                {
                    barSeries.Update(args.Bar.DateTime, args.Bar);
                    ++compressedBars;
                });
                int count = item.Task.InputSeries.Count;
                int num1  = 0;
                for (int index = 0; index < count; ++index)
                {
                    IDataObject     idataObject = (IDataObject)item.Task.InputSeries[index];
                    BarDataItemList items       = new BarDataItemList();
                    switch (item.Task.DataSource.Input)
                    {
                    case DataSourceInput.Trade:
                        Trade trade = (Trade)idataObject;
                        items.Add(new BarDataItem(trade.Price, (long)trade.Size));
                        break;

                    case DataSourceInput.Bid:
                        Quote quote1 = (Quote)idataObject;
                        items.Add(new BarDataItem(quote1.Bid, (long)quote1.BidSize));
                        break;

                    case DataSourceInput.Ask:
                        Quote quote2 = (Quote)idataObject;
                        items.Add(new BarDataItem(quote2.Ask, (long)quote2.AskSize));
                        break;

                    case DataSourceInput.BidAsk:
                        Quote quote3 = (Quote)idataObject;
                        items.Add(new BarDataItem(quote3.Bid, (long)quote3.BidSize));
                        items.Add(new BarDataItem(quote3.Ask, (long)quote3.AskSize));
                        break;

                    case DataSourceInput.Middle:
                        Quote quote4 = (Quote)idataObject;
                        items.Add(new BarDataItem((quote4.Bid + quote4.Ask) / 2.0, (long)((quote4.BidSize + quote4.AskSize) / 2)));
                        break;

                    case DataSourceInput.Spread:
                        Quote quote5 = (Quote)idataObject;
                        items.Add(new BarDataItem(quote5.Ask - quote5.Bid));
                        break;

                    case DataSourceInput.Bar:
                        Bar bar = (Bar)idataObject;
                        items.Add(new BarDataItem(bar.Open, bar.Volume, bar.OpenInt));
                        items.Add(new BarDataItem(bar.High));
                        items.Add(new BarDataItem(bar.Low));
                        items.Add(new BarDataItem(bar.Close));
                        break;
                    }
                    compressor.Add(new CompressorDataItem(idataObject.DateTime, items));
                    int num2 = (index + 1) * 100 / count;
                    if (num2 > num1)
                    {
                        num1 = num2;
                        this.SetCurrentProgress(num2);
                    }
                    if (this.doStop)
                    {
                        break;
                    }
                }
                compressor.Flush();
                barSeries.Flush();
                if (this.doStop)
                {
                    item.Status  = CompressorTaskStatus.Done;
                    item.Result  = CompressorTaskResult.Error;
                    item.Message = "Aborted by user.";
                }
                else
                {
                    item.Status  = CompressorTaskStatus.Done;
                    item.Result  = CompressorTaskResult.Success;
                    item.Message = string.Format("Compressed: {0} - > {1}", (object)count.ToString("n0"), (object)compressedBars.ToString("n0"));
                }
            }
            catch (Exception ex)
            {
                item.Status  = CompressorTaskStatus.Done;
                item.Result  = CompressorTaskResult.Error;
                item.Message = ex.Message;
            }
            finally
            {
                this.UpdateTaskViewItem(item);
            }
        }
Beispiel #10
0
    protected override void OnInit(IDataObject dataObject, int decimalPlaces)
    {
      if (dataObject != null)
      {
        Daily daily = (Daily) dataObject;
        this.nudOpen.Value = (Decimal) ((Bar) daily).Open;
        this.nudHigh.Value = (Decimal) ((Bar) daily).High;
        this.nudLow.Value = (Decimal) ((Bar) daily).Low;
        this.nudClose.Value = (Decimal) ((Bar) daily).Close;
				this.nudVolume.Value = (Decimal)((Bar)daily).Volume;
        this.nudOpenInt.Value = (Decimal) ((Bar) daily).OpenInt;
      }
      this.nudOpen.DecimalPlaces = decimalPlaces;
      this.nudHigh.DecimalPlaces = decimalPlaces;
      this.nudLow.DecimalPlaces = decimalPlaces;
      this.nudClose.DecimalPlaces = decimalPlaces;
    }
Beispiel #11
0
 protected override void OnInit(IDataObject dataObject, int decimalPlaces)
 {
   if (dataObject != null)
   {
     Trade trade = (Trade) dataObject;
     this.nudPrice.Value = (Decimal) trade.Price;
     this.nudSize.Value = (Decimal) trade.Size;
   }
   this.nudPrice.DecimalPlaces = decimalPlaces;
 }
Beispiel #12
0
 protected virtual void OnInit(IDataObject dataObject, int decimalPlaces)
 {
     throw new NotImplementedException();
 }
Beispiel #13
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);
            }
        }