Ejemplo n.º 1
0
        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            var dapi  = GlobalData.GetDataApi();
            var ticks = dapi.GetTick(code, trading_day).Value;

            if (ticks == null || ticks.Length == 0)
            {
                return;
            }

            if (top_chart != null)
            {
                top_chart.Visible = false;
            }

            if (tick_chart == null)
            {
                tick_chart        = new TickChart();
                tick_chart.Parent = this.panelTrend;
                tick_chart.Dock   = DockStyle.Fill;
            }

            tick_chart.SetData(code, ticks[0].TradingDay, ticks);

            tick_chart.Visible = true;
            top_chart          = tick_chart;
        }
Ejemplo n.º 2
0
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            //var dapi = GlobalData.GetDataApi();
            //var bars = dapi.GetBar(code, "1m", trading_day).Value;
            //if (bars == null || bars.Length == 0)
            //    return;

            var dapi  = GlobalData.GetDataApi();
            var ticks = dapi.GetTick(code, trading_day).Value;

            if (ticks == null || ticks.Length == 0)
            {
                return;
            }

            var bars = BuildBar(ticks, 60);

            if (bar_chart == null)
            {
                bar_chart        = new BarChart();
                bar_chart.Parent = this.panelTrend;
                bar_chart.Dock   = DockStyle.Fill;
            }

            bar_chart.SetData(code, bars, 60);
            SetVisibleChart(bar_chart);
        }
Ejemplo n.º 3
0
        bool IsTradingDay(DateTime dt)
        {
            int date = dt.Year * 10000 + dt.Month * 100 + dt.Day;

            if (trading_day_set.Count == 0)
            {
                var dapi = GlobalData.GetDataApi();
                dapi.Subscribe(new String[] { "000001.SH" });
                var bars = dapi.GetDailyBar("000001.SH").Value;
                if (bars != null)
                {
                    foreach (var b in bars)
                    {
                        trading_day_set.Add(b.Date);
                    }
                }
            }

            if (trading_day_set != null)
            {
                return(trading_day_set.Contains(date));
            }

            return(dt.DayOfWeek != DayOfWeek.Saturday && dt.DayOfWeek != DayOfWeek.Sunday);
        }
Ejemplo n.º 4
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            var dapi = GlobalData.GetDataApi();
            var bars = dapi.GetBar(code, "1m", trading_day).Value;

            if (bars == null || bars.Length == 0)
            {
                return;
            }

            double[] prices  = new double[bars.Length];
            long[]   volumes = new long[bars.Length];
            int[]    times   = new int[bars.Length];

            for (int i = 0; i < bars.Length; i++)
            {
                prices[i]  = bars[i].Close;
                times[i]   = bars[i].Time;
                volumes[i] = bars[i].Volume;
            }

            double pre_close = 0.0;
            var    q         = dapi.GetQuote(code).Value;

            if (q != null && q.TradingDay == bars[0].TradingDay)
            {
                pre_close = q.PreClose;
            }

            var daily_bars = dapi.GetDailyBar(code).Value;

            for (int i = daily_bars.Length - 1; i >= 0; i--)
            {
                // FXIME: no pre_close in daily_bar!
                if (daily_bars[i].Date < bars[0].TradingDay)
                {
                    pre_close = daily_bars[i].Close;
                    break;
                }
            }

            if (top_chart != null)
            {
                top_chart.Visible = false;
            }

            if (trend_chart == null)
            {
                trend_chart        = new TrendChart();
                trend_chart.Parent = this.panelTrend;
                trend_chart.Dock   = DockStyle.Fill;
            }

            trend_chart.SetData(code, trading_day, pre_close, prices, volumes, times);

            trend_chart.Visible = true;
            top_chart           = trend_chart;
        }
Ejemplo n.º 5
0
        public TrendForm(String code, int trading_day)
        {
            this.code        = code;
            this.trading_day = trading_day;
            InitializeComponent();
            this.DoubleBuffered = true;
            var dapi = GlobalData.GetDataApi();

            dapi.Subscribe(new String[] { code });

            this.toolStripButton1_Click(this, null);
        }
Ejemplo n.º 6
0
        void UpdateData()
        {
            var dapi = GlobalData.GetDataApi();

            dapi.Subscribe(new String[] { code });
            var r = dapi.GetTick(code, this.trading_day);

            if (r.Value == null)
            {
                MessageBox.Show("GetTick Error: " + r.Msg);
                return;
            }

            this.ticks = r.Value;

            UpdateListView();
            UpdateTrendChart();
        }