private ChartItemCollection CreateChartItemCollection(ChartItemType type, IEnumerable <ChartItem> chartItems, CollectionId id, IPen pen1, IPen pen2) { ChartItemCollection coll = null; if (type == ChartItemType.Linear) { coll = new ChartItemCollection(id, chartItems, pen1, null, true); } else if (type == ChartItemType.Candle) { coll = new StockItemCollection(id, chartItems.OfType <StockItem>(), pen1, pen2, null); } else if (type == ChartItemType.Volumn) { coll = new VolumnItemCollection(id, chartItems.OfType <VolumnItem>(), pen1, pen2); } else if (type == ChartItemType.Time) { coll = new SymmetricChartItemCollection(id, chartItems, pen1, null, SymmetricCommonSettings.CNSettings2); } else if (type == ChartItemType.TimeVolumn) { coll = new SymmetricVolumnItemCollection(id, chartItems != null ? chartItems.OfType <VolumnItem>() : null, pen1, pen2, SymmetricCommonSettings.CNSettings2); } return(coll); }
public void CreateCandle() { string id = "000001"; //Load chart items StockVolumnList svList = loader.GetStockItems(id); //Create collection id CollectionId collId = new CollectionId(id); //Create pens IPen raisePen = DrawingObjectFactory.CreatePen(Brushes.Red, 1); IPen fallPen = DrawingObjectFactory.CreatePen(Brushes.Green, 1); //Create stock item collection StockItemCollection stockColl = new StockItemCollection(collId, svList.Prices, raisePen, fallPen, null); //Set main collection priceControl.SetMainCollection(stockColl); //Create volumn item collection VolumnItemCollection volumnColl = new VolumnItemCollection(collId, svList.Volumns, raisePen, fallPen); //Set main collection volumnControl.SetMainCollection(volumnColl); //Connect two controls priceControl.AddConnection(volumnControl); }
private ChartItemCollection CreateChartItemCollection(ChartItemType type, IEnumerable<ChartItem> chartItems, CollectionId id, IPen pen1, IPen pen2) { ChartItemCollection coll = null; if (type == ChartItemType.Linear) { coll = new ChartItemCollection(id, chartItems, pen1, null, true); } else if (type == ChartItemType.Candle) { coll = new StockItemCollection(id, chartItems.OfType<StockItem>(), pen1, pen2, null); } else if (type == ChartItemType.Volumn) { coll = new VolumnItemCollection(id, chartItems.OfType<VolumnItem>(), pen1, pen2); } else if (type == ChartItemType.Time) { coll = new SymmetricChartItemCollection(id, chartItems, pen1, null, SymmetricCommonSettings.CNSettings2); } else if (type == ChartItemType.TimeVolumn) { coll = new SymmetricVolumnItemCollection(id, chartItems != null ? chartItems.OfType<VolumnItem>() : null, pen1, pen2, SymmetricCommonSettings.CNSettings2); } return coll; }
private void CreateCandleViewInSignleStockItemCollection(Stock stock, string marketId) { if (stock != null) { var multItemList = new List <StockValuesItem>(); var volList = new List <VolumnItem>(); CandleData cdPre = stock.Items.FirstOrDefault(); foreach (var cd in stock.Items) { multItemList.Add(new StockValuesItem() { Value = cd.close, Date = cd.DateTime, High = cd.high, Low = cd.low, Open = cd.open, CloseChange = (cd.close - cdPre.close) / cdPre.close, Values = new List <double>(mvCount) }); volList.Add(new VolumnItem() { Date = cd.DateTime, IsRaise = cd.open <= cd.close, Volumn = cd.amount, Turnover = cd.money }); cdPre = cd; } for (int i = mvStart; i < mvStart + mvCount; i++) { var maPeriod = mvUnits[i]; var maN = stock.MA(maPeriod); if (!maN.Any()) { continue; } int iInvalidCount = maPeriod - 1; for (int j = 0; j < iInvalidCount; j++) { var mItem = multItemList[j]; mItem.Values.Add(ChartItemCollection.valueNA); } List <ChartItem> mv60Items = new List <ChartItem>(maN.Count); for (int j = 0; j < maN.Count; j++) { var mItem = multItemList[j + iInvalidCount]; mItem.Values.Add(maN[j]); } } CollectionId id = new CollectionId(stock.id, marketId); List <IPen> pens = new List <IPen>(mvBrushs.Skip(mvStart).Take(mvCount).Select(mvBrush => DrawingObjectFactory.CreatePen(mvBrush, 1))); StockValuesItemCollection multipleColl = new StockValuesItemCollection(id, multItemList, raisePen, fallPen, null, pens.ToArray(), false); price.SetMainCollection(multipleColl); VolumnItemCollection volColl = new VolumnItemCollection(id, volList, raisePen, fallPen, isDynamic); //volColl.VolumnItemStyle = VolumnItemStyle.Linear; volumn.SetMainCollection(volColl); } else { price.SetMainCollection(null); volumn.SetMainCollection(null); } price.YScaleDock = YScaleDock.Right; volumn.YScaleDock = YScaleDock.Right; price.AddConnection(volumn); price.ForceDraw(); }
private void CreateCandleView(Stock stock, string marketId) { if (stock != null) { var closeList = new List <StockItem>(); var volList = new List <VolumnItem>(); CandleData cdPre = stock.Items.FirstOrDefault(); foreach (var cd in stock.Items) { closeList.Add(new StockItem() { Value = cd.close, Date = cd.DateTime, High = cd.high, Low = cd.low, Open = cd.open, CloseChange = (cd.close - cdPre.close) / cdPre.close }); cdPre = cd; volList.Add(new VolumnItem() { Date = cd.DateTime, IsRaise = cd.open <= cd.close, Volumn = cd.amount, Turnover = cd.money }); } CollectionId id = new CollectionId(stock.id, marketId); StockItemCollection coll = new StockItemCollection(id, closeList, raisePen, fallPen, null, isDynamic); //coll.ItemStyle = StockItemStyle.Linear; price.SetMainCollection(coll); for (int i = mvStart; i < mvStart + mvCount; i++) { var maPeriod = mvUnits[i]; var ma60 = stock.MA(maPeriod); List <ChartItem> mv60Items = new List <ChartItem>(ma60.Count); for (int j = 0; j < ma60.Count; j++) { mv60Items.Add(new ChartItem() { Value = ma60[j], Date = stock.Data[j + maPeriod - 1].DateTime }); } id = new CollectionId(stock.id, marketId); ChartItemCollection collMa60 = new ChartItemCollection(id, mv60Items, DrawingObjectFactory.CreatePen(mvBrushs[i], 1), null, true); price.AddAssistCollection(collMa60); } id = new CollectionId(stock.id, marketId); VolumnItemCollection volColl = new VolumnItemCollection(id, volList, raisePen, fallPen, isDynamic); //volColl.VolumnItemStyle = VolumnItemStyle.Linear; volumn.SetMainCollection(volColl); } else { price.SetMainCollection(null); volumn.SetMainCollection(null); } price.YScaleDock = YScaleDock.Left; volumn.YScaleDock = YScaleDock.Left; price.AddConnection(volumn); price.ForceDraw(); }
private void CreateCandleView2(IEnumerable <Stock> stocks, string marketId) { ChartItemCollection main = null; foreach (var stock in stocks) { var closeList = new List <StockItem>(); var volList = new List <VolumnItem>(); CandleData cdPre = stock.Items.FirstOrDefault(); foreach (var cd in stock.Items) { closeList.Add(new StockItem() { Value = cd.close, Date = cd.DateTime, High = cd.high, Low = cd.low, Open = cd.open, ValueChange = (cd.close - cdPre.close) / cdPre.close }); cdPre = cd; if (main == null) { volList.Add(new VolumnItem() { Date = cd.DateTime, IsRaise = cd.open <= cd.close, Volumn = cd.amount, Turnover = cd.money }); } } IPen pen; if (main == null) { pen = raisePen; } else { pen = fallPen; } CollectionId id = new CollectionId(stock.id, marketId); if (main == null) { StockItemCollection coll = new StockItemCollection(id, closeList, pen, pen, null, isDynamic); coll.ItemStyle = StockItemStyle.Candle; main = coll; price.SetMainCollection(coll); VolumnItemCollection volColl = new VolumnItemCollection(id, volList, pen, pen, isDynamic); volumn.SetMainCollection(volColl); } else { ChartItemCollection coll = new ChartItemCollection(id, closeList, pen, null, true, isDynamic); price.AddAssistCollection(coll, true); } } price.YScaleDock = YScaleDock.InnerLeft; volumn.YScaleDock = YScaleDock.InnerLeft; price.AddConnection(volumn); price.ForceDraw(); }