Пример #1
0
        private ChartItemCollection CreateSingleStockCollection(ChartItemType type, IEnumerable <ChartItem> chartItems, IEnumerable <ChartItem> chartItems2, CollectionId id, IPen pen1, IPen pen2, IPen[] otherPens)
        {
            List <StockValuesItem> ssItems = new List <StockValuesItem>(chartItems.Count());

            var it = chartItems2.GetEnumerator();

            foreach (var cItem in chartItems)
            {
                it.MoveNext();
                var             sItem  = cItem as StockItem;
                StockValuesItem ssItem = new StockValuesItem()
                {
                    Date         = sItem.Date,
                    High         = sItem.High,
                    Low          = sItem.Low,
                    Open         = sItem.Open,
                    Close        = sItem.Close,
                    CloseChange  = sItem.CloseChange,
                    Values       = new List <double>(new double[] { it.Current.Value }),
                    ValueChanges = new List <double>(new double[] { it.Current.ValueChange })
                };

                ssItems.Add(ssItem);
            }
            var coll = new StockValuesItemCollection(id, ssItems, pen1, pen2, null, otherPens);


            return(coll);
        }
Пример #2
0
        public ChartItemCollection CreateCollection(ChartItemType type, IPen pen1, IPen pen2)
        {
            //if (currentStock == null)
            {
                if (type != ChartItemType.Timely && type != ChartItemType.TimelyVolumn && type != ChartItemType.TimelyAverage)
                {
                    currentStock = LoadStock(shareId);
                }
                else
                {
                    currentStock = LoadMinStock(shareId, type == ChartItemType.TimelyAverage);
                }

                if (Stock.IsNullOrEmpty(currentStock))
                {
                    return(null);
                }
            }


            CollectionId id = new CollectionId(currentStock.id, GetMarketId());

            var chartItems           = CreateChartItemFromStock(currentStock, type);
            ChartItemCollection coll = CreateChartItemCollection(type, chartItems, id, pen1, pen2);

            return(coll);
        }
Пример #3
0
        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);
        }
Пример #4
0
 private ChartItem CandleData2MultiItem(CandleData cd, CandleData?cdPre, ChartItemType type)
 {
     if (type == ChartItemType.Linear)
     {
         return(new MultipleChartItem()
         {
             Value = cd.close,
             Date = cd.DateTime,
             ValueChange = (cd.close - cdPre.Value.close) / cdPre.Value.close,
             Values = new List <double>(invalidValues),
             ValueChanges = new List <double>(invalidValues)
         });
     }
     else if (type == ChartItemType.Candle)
     {
         return(new StockValuesItem()
         {
             Date = cd.DateTime,
             High = cd.high,
             Low = cd.low,
             Open = cd.open,
             Close = cd.close,
             CloseChange = cdPre != null ? (cd.close - cdPre.Value.close) / cdPre.Value.close : 0,
             Values = new List <double>(invalidValues),
             ValueChanges = new List <double>(invalidValues)
         });
     }
     else
     {
         return(null);
     }
 }
Пример #5
0
 private ChartItem CandleData2Item(CandleData cd, CandleData?cdPre, ChartItemType type)
 {
     if (type == ChartItemType.Linear)
     {
         return(new ChartItem()
         {
             Value = cd.close,
             Date = cd.DateTime,
             ValueChange = cdPre != null ? (cd.close - cdPre.Value.close) / cdPre.Value.close : 0
         });
     }
     else if (type == ChartItemType.Candle)
     {
         return(new StockItem()
         {
             Date = cd.DateTime,
             High = cd.high,
             Low = cd.low,
             Open = cd.open,
             Close = cd.close,
             CloseChange = cdPre != null ? (cd.close - cdPre.Value.close) / cdPre.Value.close : 0
         });
     }
     else if (type == ChartItemType.Volumn || type == ChartItemType.TimelyVolumn)
     {
         return(new VolumnItem()
         {
             Date = cd.DateTime,
             Volumn = cd.amount,
             Turnover = cd.money,
             IsRaise = cd.open <= cd.close
         });
     }
     else if (type == ChartItemType.Timely)
     {
         return(new ChartItem()
         {
             Value = cd.close,
             Date = cd.DateTime,
             ValueChange = cdPre != null ? (cd.close - cdPre.Value.close) / cdPre.Value.close : 0
         });
     }
     else if (type == ChartItemType.TimelyAverage)
     {
         return(new ChartItem()
         {
             Value = cd.close,
             Date = cd.DateTime
         });
     }
     else
     {
         return(null);
     }
 }
Пример #6
0
        private List <ChartItem> CreateMultiItemListFrom(Stock s, ChartItemType type)
        {
            if (Stock.IsNullOrEmpty(s))
            {
                return(null);
            }

            List <ChartItem> items = new List <ChartItem>();

            CandleData?cdPre = null;

            foreach (var cd in s.Data)
            {
                var cItem = CandleData2MultiItem(cd, cdPre, type);
                cdPre = cd;
                items.Add(cItem);
            }

            return(items);
        }
Пример #7
0
        public ChartItemCollection CreateEmptyTimeCollection(ChartItemType type, IPen pen1, IPen pen2, out StockTradeDetails std)
        {
            std = null;

            Stock s = null;

            if (type == ChartItemType.Timely)
            {
                s   = LoadStock(shareId);
                std = LoadDetailDatas();
                if (Stock.IsNullOrEmpty(s))
                {
                    return(null);
                }
            }

            CollectionId        id   = new CollectionId(shareId, GetMarketId());
            ChartItemCollection coll = null;

            switch (type)
            {
            case ChartItemType.Timely:
                var tColl = new SymmetricChartItemCollection(id, null, pen1, null, SymmetricCommonSettings.CNSettings2);
                tColl.StartValue = s.Items.Last().close;
                coll             = tColl;
                break;

            case ChartItemType.TimelyAverage:
                coll = new SymmetricChartItemCollection(id, null, pen1, null, SymmetricCommonSettings.CNSettings2);
                break;

            case ChartItemType.TimelyVolumn:
                coll = new SymmetricVolumnItemCollection(id, null, pen1, pen2, SymmetricCommonSettings.CNSettings2);
                break;

            default:
                break;
            }

            return(coll);
        }
Пример #8
0
        public ChartItem FromTradeDetailData(TradeDetailData tdd, ChartItemType type)
        {
            ChartItem item = null;

            switch (type)
            {
            case ChartItemType.Linear:
                item = new ChartItem()
                {
                    Value = tdd.current,
                    Date  = tdd.DateTime
                };
                break;

            case ChartItemType.Candle:
                item = new StockItem()
                {
                    Close = tdd.current,
                    Date  = tdd.DateTime,
                    High  = tdd.current,
                    Low   = tdd.current,
                    Open  = tdd.current
                };
                break;

            case ChartItemType.Volumn:
                item = new VolumnItem()
                {
                    Volumn   = tdd.volume,
                    Turnover = tdd.amount,
                    Date     = tdd.DateTime,
                };
                break;

            default:
                break;
            }

            return(item);
        }
Пример #9
0
        private List <ChartItem> CreateChartItemFromStock(Stock s, ChartItemType type)
        {
            if (Stock.IsNullOrEmpty(s))
            {
                return(null);
            }

            List <ChartItem> items = new List <ChartItem>();

            CandleData?cdPre = null;

            if (type == ChartItemType.Timely)
            {
                cdPre = s.Data[0];
            }

            int iCount = 30;
            int i      = iCount;

            foreach (var cd in s.Data)
            {
                var cItem = CandleData2Item(cd, cdPre, type);
                if (type != ChartItemType.Timely)
                {
                    cdPre = cd;
                }
                items.Add(cItem);

                i--;
                if (i == 0)
                {
                    cItem.ExtraData = new ExtraData();
                    //cItem.ExtraData.Add(ExtraDataNames.XRName, new ExitRight() { Dividen = cItem.ValueChange});
                    i = iCount;
                }
            }
            //Duplicate(items);
            return(items);
        }
Пример #10
0
        private ChartItemCollection CreateSingleStockCollection(ChartItemType type, IEnumerable<ChartItem> chartItems, IEnumerable<ChartItem> chartItems2, CollectionId id, IPen pen1, IPen pen2, IPen[] otherPens)
        {
            List<StockValuesItem> ssItems = new List<StockValuesItem>(chartItems.Count());

            var it = chartItems2.GetEnumerator();
            
            foreach (var cItem in chartItems)
            {
                it.MoveNext();
                var sItem = cItem as StockItem;
                StockValuesItem ssItem = new StockValuesItem()
                {
                    Date = sItem.Date,
                    High = sItem.High,
                    Low = sItem.Low,
                    Open = sItem.Open,
                    Close = sItem.Close,
                    CloseChange = sItem.CloseChange,
                    Values = new List<double>(new double[] { it.Current.Value }),
                    ValueChanges = new List<double>(new double[] { it.Current.ValueChange })
                };

                ssItems.Add(ssItem);
            }
            var coll = new StockValuesItemCollection(id, ssItems, pen1, pen2, null, otherPens);
            
                
            return coll;
        }
Пример #11
0
 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;
 }
Пример #12
0
 private ChartItemCollection CreateCollection(string id, IEnumerable<ChartItem> chartItems, IEnumerable<ChartItem> chartItems2, ChartItemType type, IPen pen1, IPen pen2, IPen[] otherPens)
 {
     CollectionId cId = new CollectionId(id);
     ChartItemCollection coll = CreateSingleStockCollection(type, chartItems, chartItems2, cId, pen1, pen2, otherPens);
     return coll;
 }
Пример #13
0
 private ChartItemCollection CreateCollection(string id, IEnumerable<ChartItem> chartItems, ChartItemType type, IPen pen1, IPen pen2)
 {
     CollectionId cId = new CollectionId(id);
     ChartItemCollection coll = CreateChartItemCollection(type, chartItems, cId, pen1, pen2);
     return coll;
 }
Пример #14
0
        private ChartItemCollection CreateCollection(string id, IEnumerable <ChartItem> chartItems, IEnumerable <ChartItem> chartItems2, ChartItemType type, IPen pen1, IPen pen2, IPen[] otherPens)
        {
            CollectionId        cId  = new CollectionId(id);
            ChartItemCollection coll = CreateSingleStockCollection(type, chartItems, chartItems2, cId, pen1, pen2, otherPens);

            return(coll);
        }
Пример #15
0
        private ChartItemCollection CreateCollection(string id, IEnumerable <ChartItem> chartItems, ChartItemType type, IPen pen1, IPen pen2)
        {
            CollectionId        cId  = new CollectionId(id);
            ChartItemCollection coll = CreateChartItemCollection(type, chartItems, cId, pen1, pen2);

            return(coll);
        }
Пример #16
0
 public ChartFunction(string name, ChartItemType itemType, ChartItemClassName className)
 {
     this.Name      = name;
     this.ItemType  = itemType;
     this.ClassName = className;
 }