Exemplo n.º 1
0
        void fillRateItemChart()
        {
            if (re_.runMode_ != RunMode.RM_Raw)
            {
                return;
            }
            List <HistoryData> dataList;
            List <String>      rateItemList;

            if (App.asset_.collectRateItemHistory(re_, out strategyRateItemHistoryData_, out dataList, out rateItemList))
            {
                SUtils.FillHistoryDataToChart(chart_, dataList, rateItemList);
            }
        }
Exemplo n.º 2
0
        public void selItemsHistoryDataToChart(Chart chart, List <SelectItem> selItems, List <DateRange> dateRangeList, RunMode runMode, out ChartXUnit xUnit)
        {
            List <HistoryData>    dataList = new List <HistoryData>();
            List <DateSelectItem> items    = RegressResult.ToDaySelectItemList(selItems, dateRangeList);

            xUnit = SUtils.DetermineXUnit(items.Count);
            if (items.Count == 0)
            {
                return;
            }
            if (xUnit == ChartXUnit.CXU_Year)
            {
                items.Reverse();
                int startDate        = items[0].date_;
                int endDate          = items[items.Count - 1].date_;
                int startYear        = Utils.Year(startDate);
                int endYear          = Utils.Year(endDate);
                int iSearchStartHint = 0;
                for (int iYear = startYear; iYear <= endYear; iYear++)
                {
                    int iStartIndex = -1;
                    int nDaySpan    = 0;
                    for (int i = iSearchStartHint; i < items.Count; i++)
                    {
                        if (iStartIndex == -1 && Utils.Year(items[i].date_) == iYear)
                        {
                            iStartIndex = i;
                        }
                        if (iStartIndex != -1)
                        {
                            if (Utils.Year(items[i].date_) == iYear)
                            {
                                nDaySpan++;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    iSearchStartHint = iStartIndex + nDaySpan;
                    HistoryData data = StrategyAsset.GetHistoryData(items, iStartIndex, nDaySpan, runMode);
                    dataList.Add(data);
                }
            }
            else
            {
                int nDaySpan    = SUtils.ToDayCount(xUnit);
                int iStartIndex = 0;
                do
                {
                    if (iStartIndex + nDaySpan - 1 > items.Count)
                    {
                        break;
                    }
                    HistoryData data = StrategyAsset.GetHistoryData(items, iStartIndex, nDaySpan, runMode);
                    dataList.Add(data);
                    iStartIndex += nDaySpan;
                } while (iStartIndex < items.Count);
                dataList.Reverse();
            }

            List <String> xDescList = new List <string>();

            foreach (var item in dataList)
            {
                xDescList.Add(SUtils.ToXDesc(xUnit, item.startDate_, item.endDate_));
            }
            SUtils.FillHistoryDataToChart(chart, dataList, xDescList);
            re_.reHistory_ = StrategyAsset.GetHistoryData(items, 0, items.Count, re_.runMode_);
        }