Ejemplo n.º 1
0
        public bool collectRateItemHistory(RegressResult re,
                                           out Dictionary <String, HistoryData> strategyRateItemHistoryData,
                                           out List <HistoryData> dataList,
                                           out List <String> rateItemList
                                           )
        {
            Dictionary <String, List <SelectItem> > rateItemDict = RegressResult.ToRateItemDict(re.selItems_);
            var sortDict = from objDic in rateItemDict orderby objDic.Key select objDic;

            dataList     = new List <HistoryData>();
            rateItemList = new List <string>();
            strategyRateItemHistoryData = new Dictionary <string, HistoryData>();
            foreach (var kv in sortDict)
            {
                if (kv.Value.Count < 20)
                {
                    continue;
                }
                rateItemList.Add(kv.Key);
                List <DateSelectItem> items = RegressResult.ToDaySelectItemList(kv.Value, re.dateRangeList_);
                HistoryData           data  = StrategyAsset.GetHistoryData(items, 0, items.Count, RunMode.RM_Raw);
                dataList.Add(data);
            }
            if (dataList.Count == 0)
            {
                return(false);
            }
            for (int i = 0; i < rateItemList.Count; ++i)
            {
                strategyRateItemHistoryData[rateItemList[i]] = dataList[i];
            }
            return(true);
        }
Ejemplo n.º 2
0
        public bool writeAssetForAllSingleStrategy(String dateRangeName)
        {
            DB.Global().Execute(String.Format("Delete From stra_his"));
            DB.Global().Execute(String.Format("Delete From stra_opt"));
            foreach (var item in App.autoSolutionSettingList_)
            {
                if (item.name_ == "$All" || item.name_ == "$Tmp")
                {
                    continue;
                }
                RegressResult re = new RegressResult();
                re.runMode_       = RunMode.RM_Raw;
                re.name_          = item.name_ + "-" + dateRangeName;
                re.solutionName_  = item.name_;
                re.dateRangeName_ = dateRangeName;
                re.dateRangeList_ = App.DateRange(dateRangeName).rangeList_;
                re.strategyList_  = App.Solution(item.name_).straList_;

                if (re.EndDate >= Utils.LastTradeDay())
                {
                    if (!App.ds_.prepareForSelect())
                    {
                        MessageBox.Show("准备数据工作失败,无法继续执行!");
                        return(false);
                    }
                }
                RegressManager regressManager = new RegressManager();
                regressManager.regress(re);

                List <DateSelectItem> items = RegressResult.ToDaySelectItemList(re.selItems_, re.dateRangeList_);
                re.reHistory_ = StrategyAsset.GetHistoryData(items, 0, items.Count, re.runMode_);

                Dictionary <String, HistoryData> strategyRateItemHistoryData;
                List <HistoryData> dataList;
                List <String>      rateItemList;
                App.asset_.collectRateItemHistory(re, out strategyRateItemHistoryData, out dataList, out rateItemList);
                StrategyAsset.WriteStrategyAsset(re.strategyList_[0], re.reHistory_, strategyRateItemHistoryData);

                Dictionary <String, Object> straDataDict = re.reHistory_.toDictionary("");
                straDataDict["straname"] = re.solutionName_;
                DB.Global().Insert("stra_opt", straDataDict);
            }
            App.asset_.readAssetFromDB();
            App.host_.uiSetMsg("Write asset completed.");
            return(true);
        }