public ChartDataProviderYahoo(string chartName, ezBarInterval barInterval, ezSessionTimeRange session)
        {
            this.chartName = chartName;

            // If null has been passed as barInterval or session, then we will use default values for those.
            if (barInterval == null)
            {
                barInterval = new ezBarInterval(zChartInterval.Day, 1);
            }

            if (session == null)
            {
                session = new ezSessionTimeRange();
            }

            this.BarInterval = barInterval;
            this.Session     = session;

            // Create the EZChartDataSeries - this will be available via the ChartData property (but the caller
            // should subscribe to the events to know when the data has finished loading or updates occur).
            this.chartData = new EZChartDataSeries(chartName, barInterval, session);

            //var chartThread = new ChartDataThread(this, chartData, startDate, endDate);
            //var thread = new Thread(new ThreadStart(chartThread.Run));
            //thread.Name = chartName + ":" + barInterval;
            //thread.Start();
        }
        public ChartDataProviderCTS(string chartName, ezBarInterval barInterval, ezSessionTimeRange session)
        {
            this.chartName = chartName;

            // If null has been passed as barInterval or session, then we will use default values for those.
            if (barInterval == null)
            {
                barInterval = new ezBarInterval(zChartInterval.Day, 1);
            }

            if (session == null)
            {
                session = new ezSessionTimeRange();
            }

            this.BarInterval = barInterval;
            this.Session     = session;

            // Create the EZChartDataSeries - this will be available via the ChartData property (but the caller
            // should subscribe to the events to know when the data has finished loading or updates occur).
            this.chartData = new EZChartDataSeries(chartName, barInterval, session);

            this.chartData.DataLoadComplete  += chartData_DataLoadComplete;
            this.chartData.DataSeriesUpdated += chartData_DataSeriesUpdated;
        }
        public ChartDescriptor(object chartIdentifier, ezBarInterval interval, DateTime startDate, DateTime endDate, IndicatorMap indicators)
        {
            this.chartIdentifier = chartIdentifier;
            this.interval        = interval;
            this.startDate       = startDate;
            this.endDate         = endDate;
            this.indicators      = indicators;

            this.UniqueID = DateTime.Now.Ticks.ToString();
        }
Пример #4
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            ezBarInterval ezb = obj as ezBarInterval;

            if ((System.Object)ezb == null)
            {
                return(false);
            }

            return(Equals(ezb));
        }
Пример #5
0
        private void RequestChartData(EZInstrument instrument, zChartInterval interval, int period)
        {
            // Set EndDate to the current trading date.
            //DateTime dtEndDate = selectedContract.GetTradeDate(DateTime.Now);
            DateTime dtEndDate = DateTime.Now;

            DateTime       dtStartDate;
            zChartInterval enBarInterval = zChartInterval.Hour;

            if (interval == zChartInterval.Day)
            {
                enBarInterval = zChartInterval.Day;

                // User select Day bars, load a few months of them.
                dtStartDate = dtEndDate.AddMonths(-3);
            }
            else
            {
                enBarInterval = interval;

                // User selected non-Day bars (Hour, Minute, etc.), load a couple of days of them.
                dtStartDate = dtEndDate;
                dtStartDate = dtStartDate.AddDays(-3);

                /*// This little loop here will ensure that we load the previous trade date as well as today and will account for weekends
                 * // and holidays.
                 * while ((selectedContract.GetTradeDate(dtStartDate) == dtEndDate))
                 * {
                 *  dtStartDate = dtStartDate.AddDays(-1);
                 * }*/
            }

            // Create a BarInterval object to tell the API what bar interval we want.
            // So for example, if we wanted a 15 minute bar, we would do:  New ezBarInterval(zChartDataType.Minute, 15)
            ezBarInterval oBarIntvl = new ezBarInterval(enBarInterval, period);

            string             chartName = instrument.Name + " : " + oBarIntvl;
            IChartDataProvider provider  = new ChartDataProviderCTS(chartName, oBarIntvl, ezSessionTimeRange.Empty);

            if (LoadingNewChart != null)
            {
                LoadingNewChart(provider);
            }
            this.SetChartDataProvider(provider);
            WinForms.SetWaitCursor(true);
            provider.LoadHistoricalChartData(APIMain.MarketFromInstrument(instrument), dtStartDate, dtEndDate);
        }
Пример #6
0
        public bool Equals(ezBarInterval ezb)
        {
            bool result = true;

            if ((object)ezb == null)
            {
                return(false);
            }

            if (interval != ezb.interval)
            {
                result = false;
            }
            else if (period != ezb.period)
            {
                result = false;
            }

            return(result);
        }
Пример #7
0
        public void ZoomIn()
        {
            try
            {
                double xMin = chart1.ChartAreas["ChartAreaMain"].AxisX.ScaleView.ViewMinimum;
                double xMax = chart1.ChartAreas["ChartAreaMain"].AxisX.ScaleView.ViewMaximum;

                Point zoomPoint = new Point();
                zoomPoint.X = chart1.Location.X + (chart1.ClientRectangle.Width / 2);

                double posXStart  = chart1.ChartAreas["ChartAreaMain"].AxisX.PixelPositionToValue(zoomPoint.X) - (xMax - xMin) / 3;
                double posXFinish = chart1.ChartAreas["ChartAreaMain"].AxisX.PixelPositionToValue(zoomPoint.X) + (xMax - xMin) / 3;

                chart1.ChartAreas["ChartAreaMain"].AxisX.ScaleView.Zoom(posXStart, posXFinish);

                ezBarInterval        barInterval  = chartDataProvider.BarInterval;
                string               sInterval    = barInterval.Interval.ToString() + "s"; // DateTimeIntervalType enum values are plural
                DateTimeIntervalType intervalType = (DateTimeIntervalType)Enum.Parse(typeof(DateTimeIntervalType), sInterval, true);
                chart1.ChartAreas["ChartAreaMain"].AxisX.ScaleView.SmallScrollSize     = 1;
                chart1.ChartAreas["ChartAreaMain"].AxisX.ScaleView.SmallScrollSizeType = DateTimeIntervalType.Auto;
            }
            catch (Exception ex) { ExceptionHandler.TraceException(ex); }
        }