コード例 #1
0
        public static void BindHistoryVolAndAmountDatas(ChartAEx chart, CTable dataSource, int[] fields, List <SecurityData> historyDatas)
        {
            dataSource.Clear();
            int size = (int)historyDatas.Count;;

            dataSource.SetRowsCapacity(size + 10);
            dataSource.SetRowsGrowStep(100);
            int columnsCount = dataSource.ColumnsCount;

            for (int i = 0; i < size; i++)
            {
                SecurityData securityData = historyDatas[i];
                double[]     ary          = new double[columnsCount];
                ary[0] = securityData.m_volume;
                ary[1] = securityData.m_amount;
                dataSource.AddRow((double)securityData.m_date, ary, columnsCount);
            }
        }
コード例 #2
0
        public static void BindHistoryDatas(ChartAEx chart, CTable dataSource, List <CIndicator> indicators, int[] fields, List <SecurityData> historyDatas)
        {
            dataSource.Clear();
            int sizeData = (int)historyDatas.Count;

            if (sizeData > 0)
            {
                dataSource.SetRowsCapacity(sizeData + 10);
                dataSource.SetRowsGrowStep(100);
                int columnsCount = dataSource.ColumnsCount;
                for (int i = 0; i < sizeData; i++)
                {
                    SecurityData securityData = historyDatas[i];
                    if (dataSource == chart.DataSource)
                    {
                        if (securityData.m_close > 0)
                        {
                            InsertData(chart, dataSource, fields, securityData);
                        }
                    }
                    else
                    {
                        double[] ary = new double[columnsCount];
                        ary[0] = securityData.m_close;
                        ary[1] = securityData.m_high;
                        ary[2] = securityData.m_low;
                        ary[3] = securityData.m_open;
                        ary[4] = securityData.m_volume;
                        ary[5] = securityData.m_amount;
                        ary[6] = securityData.m_avgPrice;
                        dataSource.AddRow((double)securityData.m_date, ary, columnsCount);
                    }
                }
                int indicatorsSize = (int)indicators.Count;
                for (int i = 0; i < indicatorsSize; i++)
                {
                    indicators[i].OnCalculate(0);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 绑定历史数据
        /// </summary>
        /// <param name="chart">股票控件</param>
        /// <param name="dataSource">数据源</param>
        /// <param name="indicators">指标</param>
        /// <param name="fields">字段</param>
        /// <param name="historyDatas">历史数据</param>
        public static void BindHistoryDatas(ChartA chart, CTable dataSource, List <CIndicator> indicators, int[] fields, List <SecurityData> historyDatas)
        {
            dataSource.Clear();
            int size = historyDatas.Count;

            dataSource.SetRowsCapacity(size + 10);
            dataSource.SetRowsGrowStep(100);
            int columnsCount = dataSource.ColumnsCount;

            for (int i = 0; i < size; i++)
            {
                SecurityData securityData = historyDatas[i];
                if (dataSource == chart.DataSource)
                {
                    InsertData(chart, dataSource, fields, securityData);
                }
                else
                {
                    double[] ary = new double[columnsCount];
                    ary[0] = securityData.m_close;
                    ary[1] = securityData.m_high;
                    ary[2] = securityData.m_low;
                    ary[3] = securityData.m_open;
                    ary[4] = securityData.m_volume;
                    for (int j = 5; j < columnsCount; j++)
                    {
                        ary[j] = double.NaN;
                    }
                    dataSource.AddRow(securityData.m_date, ary, columnsCount);
                }
            }
            int indicatorsSize = indicators.Count;

            for (int i = 0; i < indicatorsSize; i++)
            {
                indicators[i].OnCalculate(0);
            }
        }