Ejemplo n.º 1
0
 public SimpleBSView(Pad pad, BarSeries series)
     : base(pad)
 {
     this.series = series;
     UpColor = Color.Black;
     DownColor = Color.Lime;
     ToolTipFormat = "{0} {2}\n\nH : {3:F*}\nL : {4:F*}\nO : {5:F*}\nC : {6:F*}\nV : {7}".Replace("*", this.pad.Chart.LabelDigitsCount.ToString());
 }
Ejemplo n.º 2
0
 public Strategy(Framework framework, string name)
 {
     this.framework = framework;
     this.Name = name;
     this.strategiesByInstrument = new IdArray<LinkedList<Strategy>>(1000);
     this.strategyByOrderId = new IdArray<Strategy>(1000);
     this.strategies = new LinkedList<Strategy>();
     this.status = StrategyStatus.Stopped;
     this.instruments = new InstrumentList();
     this.instrumentCountTable = new IdArray<int>(1000);
     if (framework != null)
     {
         this.portfolio = new Portfolio(framework, this.Name);
         framework.PortfolioManager.Add(this.portfolio);
     }
     this.bars = new BarSeries("", "");
     this.equity = new TimeSeries();
     this.bids = new TickSeries("");
     this.asks = new TickSeries("");
     this.stops = new List<Stop>();
     this.stopsByInstrument = new IdArray<List<Stop>>(1000);
 }
Ejemplo n.º 3
0
 public void OnNewGroupEvent(GroupEvent groupEvent)
 {
     var item = this.table[groupEvent.Group.Id];
     Tuple<Viewer, object> tuple = null;
     item.Table.TryGetValue(groupEvent.Obj.TypeId, out tuple);
     switch (groupEvent.Obj.TypeId)
     {
         case DataObjectType.Bar:
             object obj1;
             if (tuple == null)
             {
                 obj1 = new BarSeries("", "", -1);
                 int padNumber = item.PadNumber;
                 this.EnsurePadExists(padNumber, item.Format);
                 int viewerIndex = this.GetViewerIndex(groupEvent.Group, padNumber);
                 Viewer viewer = this.chart.Pads[padNumber].Insert(viewerIndex, obj1 as BarSeries);
                 this.chart.Pads[padNumber].Legend.Add(groupEvent.Group.Name, Color.Black);
                 item.Table.Add(groupEvent.Obj.TypeId, new Tuple<Viewer, object>(viewer, obj1));
             }
             else
                 obj1 = tuple.Item2 as BarSeries;
             (obj1 as BarSeries).Add(groupEvent.Obj as Bar);
             break;
         case DataObjectType.Fill:
             object obj2;
             if (tuple == null)
             {
                 obj2 = new FillSeries("");
                 int padNumber = item.PadNumber;
                 this.EnsurePadExists(padNumber, item.Format);
                 int viewerIndex = this.GetViewerIndex(groupEvent.Group, padNumber);
                 Viewer viewer = this.chart.Pads[padNumber].Insert(viewerIndex, obj2);
                 item.Table.Add(groupEvent.Obj.TypeId, new Tuple<Viewer, object>(viewer, obj2));
             }
             else
                 obj2 = tuple.Item2 as FillSeries;
             (obj2 as FillSeries).Add(groupEvent.Obj as Fill);
             break;
         case DataObjectType.TimeSeriesItem:
             object obj3;
             if (tuple == null)
             {
                 obj3 = new TimeSeries();
                 int padNumber = item.PadNumber;
                 EnsurePadExists(padNumber, item.Format);
                 int viewerIndex = this.GetViewerIndex(groupEvent.Group, padNumber);
                 Viewer viewer = this.chart.Pads[padNumber].Insert(viewerIndex, obj3);
                 foreach (var kv in groupEvent.Group.Fields)
                     viewer.Set(obj3, kv.Value.Name, kv.Value.Value);
                 if (groupEvent.Group.Fields.ContainsKey("Color"))
                     this.chart.Pads[padNumber].Legend.Add(groupEvent.Group.Name, (Color)groupEvent.Group.Fields["Color"].Value);
                 else
                     this.chart.Pads[padNumber].Legend.Add(groupEvent.Group.Name, Color.Black);
                 item.Table.Add(groupEvent.Obj.TypeId, new Tuple<Viewer, object>(viewer, obj3));
             }
             else
                 obj3 = tuple.Item2 as TimeSeries;
             (obj3 as TimeSeries).Add((groupEvent.Obj as TimeSeriesItem).DateTime, (groupEvent.Obj as TimeSeriesItem).Value);
             break;
     }
 }