예제 #1
0
		public CompressorTaskViewItem(CompressorTaskItem item) : base(new string[4])
		{
			this.item = item;
			this.UpdateValues();
		}
예제 #2
0
 private void UpdateTaskViewItem(CompressorTaskItem item)
 {
     this.Invoke((Action)(() => this.taskViewItems[item].UpdateValues()));
 }
예제 #3
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);
            }
        }
예제 #4
0
    private void UpdateTaskViewItem(CompressorTaskItem item)
    {
			this.Invoke((Action) (() => this.taskViewItems[item].UpdateValues()));
    }
예제 #5
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);
      }
    }
예제 #6
0
 public CompressorTaskViewItem(CompressorTaskItem item) : base(new string[4])
 {
     this.item = item;
     this.UpdateValues();
 }