コード例 #1
0
ファイル: libs.cs プロジェクト: oghenez/trade-software
        public static void GetRangeY(CurveItem curve, int fromId, int toId, ref ValueRange range)
        {
            if (curve.GetType() == typeof(JapaneseCandleStickItem))
            {
                GetRangeY((curve as JapaneseCandleStickItem), fromId, toId, ref range);
                return;
            }

            if (curve.GetType() == typeof(LineItem))
            {
                GetRangeY((curve as LineItem), fromId, toId, ref range);
                return;
            }

            if (curve.GetType() == typeof(BarItem))
            {
                GetRangeY((curve as BarItem), fromId, toId, ref range);
                return;
            }

            if (curve.GetType() == typeof(StickItem))
            {
                GetRangeY((curve as StickItem), fromId, toId, ref range);
                return;
            }
        }
コード例 #2
0
        private void UpdatePrice(int noOfUpdate, CurveItem curve)
        {
            this.ShowMessage("Update " + noOfUpdate.ToString());
            IPointListEdit list    = curve.Points as IPointListEdit;
            int            lastPos = list.Count - 1;

            if (curve.GetType() == typeof(JapaneseCandleStickItem))
            {
                if (lastPos >= 0)
                {
                    (list as StockPointList).RemoveAt(lastPos);
                }
                for (int idx = Math.Max(0, lastPos); idx < myData.DateTime.Count; idx++)
                {
                    StockPt item = new StockPt(myData.DateTime[idx], myData.High.Values[idx], myData.Low.Values[idx],
                                               myData.Open.Values[idx], myData.Close.Values[idx], myData.Volume.Values[idx]);

                    (list as StockPointList).Add(item);
                }
            }
            else
            {
                if (lastPos >= 0)
                {
                    (list as PointPairList).RemoveAt(lastPos);
                }
                for (int idx = Math.Max(0, lastPos); idx < myData.DateTime.Count; idx++)
                {
                    PointPair item = new PointPair(myData.DateTime[idx], myData.Close.Values[idx]);
                    (list as PointPairList).Add(item);
                }
            }
        }
コード例 #3
0
ファイル: CurveDataHandlers.cs プロジェクト: zrolfs/pwiz
        /// <summary>
        /// Returns a new instance of a <see cref="ICurveDataHandler"/> appropriate for the
        /// <paramref name="curveItem"/>.
        /// </summary>
        public static ICurveDataHandler FindCurveHandler(CurveItem curveItem)
        {
            var handlerClass = curveItem.GetType().GetCustomAttributes(typeof(CurveDataHandlerAttribute), true)
                               .Cast <CurveDataHandlerAttribute>().Select(attribute => attribute.Class)
                               .FirstOrDefault() ??
                               ((curveItem is HiLowBarItem) ? typeof(HiLowBarDataHandler) : typeof(CurveDataHandler));
            var constructorInfo = handlerClass.GetConstructor(new Type[0]);

            if (constructorInfo != null)
            {
                return((ICurveDataHandler)constructorInfo.Invoke(new object[0]));
            }
            return(null);
        }
コード例 #4
0
        private void UpdateCurvePRICE(int noOfUpdate)
        {
            CurveItem      curve   = pricePanel.myGraphObj.myGraphPane.CurveList[pricePanel.Name];
            IPointListEdit list    = curve.Points as IPointListEdit;
            int            lastPos = list.Count - 1;

            if (curve.GetType() == typeof(JapaneseCandleStickItem))
            {
                if (lastPos >= 0)
                {
                    (list as StockPointList).RemoveAt(lastPos);
                }
                for (int idx = Math.Max(0, lastPos); idx < myData.DateTime.Count; idx++)
                {
                    (list as StockPointList).Add(new StockPt(myData.DateTime[idx], myData.High.Values[idx], myData.Low.Values[idx],
                                                             myData.Open.Values[idx], myData.Close.Values[idx], myData.Volume.Values[idx]));
                }
            }
            else
            {
                if (lastPos >= 0)
                {
                    (list as PointPairList).RemoveAt(lastPos);
                }
                for (int idx = Math.Max(0, lastPos); idx < myData.DateTime.Count; idx++)
                {
                    (list as PointPairList).Add(new PointPair(myData.DateTime[idx], myData.Close.Values[idx]));
                }
            }
            //Only update chart when it is at the last view
            if (pricePanel.myGraphObj.IsLastView())
            {
                pricePanel.myGraphObj.UpdateSeries();
                pricePanel.myGraphObj.MoveToEnd();
            }
            pricePanel.myGraphObj.UpdateChart();
        }