Esempio n. 1
0
        Dictionary <String, String> selectForGreen(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0.095 || zf < -0.095)
            {
                return(null);
            }
            if (dsh.IsLikeSTStop())
            {
                return(null);
            }
            if (dsh.Ref(Info.HF) > 0)
            {
                return(null);
            }
            if (dsh.IsRed())
            {
                return(null);
            }
            if (dsh.DownShadow() < -0.03)
            {
                return(null);
            }
            return(EmptyRateItemButSel);
        }
Esempio n. 2
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            float zf             = dsh.Ref(Info.ZF);
            bool  bIsTwoDownMode = false;
            Dictionary <String, String> ret;

            if (zf < -0.04 && zf > -0.095)
            {
                ret = selectFor(dsh, selectMode, ref sigInfo, 1, out bIsTwoDownMode);
                if (bIsTwoDownMode)
                {
                    var retDict = new Dictionary <String, String>();
                    retDict[String.Format("TwoDownMode/1")] = "";
                    return(retDict);
                }
            }
            ret = selectFor(dsh, selectMode, ref sigInfo, 0, out bIsTwoDownMode);
            if (ret == null)
            {
                return(null);
            }
            var szZF = dsh.SZRef(Info.ZF);

            if (szZF > 0 && szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03)
            {
                return(null);
            }
            if (!selectBySZ(dsh))
            {
                return(null);
            }
            ret[String.Format("TwoDownMode/0")] = "";
            return(ret);
        }
Esempio n. 3
0
        public void regress(RegressResult regressRe)
        {
            DataStoreHelper dsh        = new DataStoreHelper();
            SelectManager   selManager = new SelectManager();
            List <int>      dateList   = Utils.TraverTimeDay(regressRe.dateRangeList_);

            dateList.Reverse();
            App.host_.uiStartProcessBar();
            int nFinishCount = 0;
            int nTotalCount  = dateList.Count;

            SelectHint hint = new SelectHint();

            foreach (Stock sk in App.ds_.stockList_)
            {
                hint.nextWantedIndexHintDict_[sk] = -1;
            }
            foreach (int date in dateList)
            {
                SelectResult re = selManager.select(dsh, SelectMode.SM_Regress, date, regressRe.strategyList_, hint);
                regressRe.selItems_.AddRange(re.selItems_);
                App.host_.uiSetProcessBar(String.Format("{0}:正在回归{1}-{2},选择阶段:完成{3}的选择,当前选中记录数:{4}",
                                                        regressRe.solutionName_,
                                                        dateList.Last(), dateList.First(), date, regressRe.selItems_.Count),
                                          nFinishCount * 100 / nTotalCount);
                ++nFinishCount;
            }
            regressRe.selItems_.Sort(delegate(SelectItem lhs, SelectItem rhs)
            {
                var lhsBonus = lhs.getColumnVal("nsl");
                var rhsBonus = rhs.getColumnVal("nsl");
                if (lhsBonus == "")
                {
                    return(1);
                }
                if (rhsBonus == "")
                {
                    return(-1);
                }
                float lhsBonusValue = Utils.GetBonusValue(lhsBonus);
                float rhsBonusValue = Utils.GetBonusValue(rhsBonus);
                return(lhsBonusValue.CompareTo(rhsBonusValue));
            });
            foreach (var item in regressRe.selItems_)
            {
                item.allSelectItems_ = regressRe.selItems_;
            }
            App.host_.uiFinishProcessBar();
            if (regressRe.runMode_ == RunMode.RM_Asset)
            {
                regressRe.buyItems_ = App.grp_.desideToBuy(regressRe);
            }
            else
            {
                regressRe.buyItems_ = App.grp_.buyMostBonusPerDay(regressRe);
            }
        }
Esempio n. 4
0
 Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
 {
     if (null == selectForRed(dsh.newDsh(1), selectMode, ref sigInfo))
     {
         return(null);
     }
     if (null == selectForGreen(dsh, selectMode, ref sigInfo))
     {
         return(null);
     }
     return(EmptyRateItemButSel);
 }
Esempio n. 5
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            IStrategy_LF_M stra = (IStrategy_LF_M)this;

            if (dsh.stock_.code_ != "300780")
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF) > 0.095)
            {
                return(null);
            }

            return(EmptyRateItemButSel);
        }
Esempio n. 6
0
        public bool meetBuyChance(DataStoreHelper dsh, SelectMode selectMode)
        {
            IStrategy_LF stra     = (IStrategy_LF)this;
            float        buyLimit = stra.buyLimit();

            switch (selectMode)
            {
            case SelectMode.SM_Regress:
                return(dsh.Ref(Info.LF) < buyLimit);

            case SelectMode.SM_SelectOpen:
                return(true);

            default:
                return(dsh.Ref(Info.ZF) < buyLimit + 0.005f);
            }
        }
Esempio n. 7
0
        public bool selectBySZ(DataStoreHelper dsh)
        {
            {
                var szzf = dsh.SZRef(Info.ZF);
                if (dsh.SZRef(Info.ZF, dsh.SZLL(Info.ZF, 3)) < -0.03 &&
                    szzf < 0.005 && szzf > -0.005 &&
                    dsh.SZUpShadow() > 0.005 && dsh.SZDownShadow() < -0.005)
                {
                    return(false);
                }
            }

            float minSZZF   = float.MaxValue;
            float maxSZZF   = float.MinValue;
            int   iSigIndex = -1;

            for (int i = 1; i <= 3; ++i)
            {
                var szzf = dsh.SZRef(Info.ZF, i);
                if (minSZZF > szzf)
                {
                    minSZZF = szzf;
                    if (minSZZF < -0.02)
                    {
                        iSigIndex = i;
                        break;
                    }
                }
                maxSZZF = Math.Max(maxSZZF, szzf);
            }
            if (iSigIndex != -1 && maxSZZF < 0.01)
            {
                var acc = dsh.SZAcc(Info.ZF, 3, iSigIndex + 1);
                if (acc > 0.02)
                {
                    return(false);
                }
            }
            if (dsh.SZAcc(Info.ZF, 6, 1) < -0.06 && dsh.SZRedCount(6, 1) < 3)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 8
0
        Dictionary <String, String> selectForHStrugle(DataStoreHelper dsh, float topMostC, float maxUpZF)
        {
            if (dsh.MaxCO(1) > dsh.MaxCO())
            {
                bool bHasGreen = false;
                for (int i = 1; i <= 2; i++)
                {
                    if (dsh.Ref(Info.C, i) < dsh.Ref(Info.O, i))
                    {
                        bHasGreen = true;
                        break;
                    }
                }
                if (!bHasGreen)
                {
                    return(null);
                }
            }
            for (int i = 1; i <= 2; i++)
            {
                if (!dsh.IsReal(i))
                {
                    return(null);
                }
            }
            float upLimitRate = maxUpZF > 0.01f ? 0 : 0.01f;
//             if (dsh.Ref(Info.ZF) < 0.005)
//             {
//                 upLimitRate = 0.03f;
//             }
            var upRate = (dsh.Ref(Info.H) - topMostC) / topMostC;

            if ((dsh.Ref(Info.H, 1) - topMostC) / topMostC < 0 &&
                upRate > upLimitRate /* && dsh.UpShadow() > 0.02*/ &&
                dsh.MaxCO() < topMostC && dsh.Ref(Info.ZF) > 0.005)
            {
                return(EmptyRateItemButSel);
            }
            return(null);
        }
Esempio n. 9
0
        public SelectResult selectNow()
        {
            DataStoreHelper dsh = new DataStoreHelper();
//             List<IStrategy> strategyList = new List<IStrategy>();
//             strategyList.Add(App.grp_.strategy("LStopUp"));

            List <IStrategy> strategyList;
            SelectMode       selectMode = SelectMode.SM_SelectInDay;
            DateTime         curTime    = DateTime.Now;

            if (Utils.IsOpenTime(curTime.Hour, curTime.Minute))
            {
                strategyList = App.Solution("lf_good").straList_;
                selectMode   = SelectMode.SM_SelectOpen;
            }
            else if (Utils.IsCloseTime(curTime.Hour, curTime.Minute))
            {
                strategyList = App.Solution("close_good").straList_;
                selectMode   = SelectMode.SM_SelectClose;
            }
            else if (Utils.IsTradeTime(curTime.Hour, curTime.Minute))
            {
                strategyList = App.Solution("lf_good").straList_;
                selectMode   = SelectMode.SM_SelectInDay;
            }
            else
            {
                strategyList = App.Solution("close_good").straList_;
                selectMode   = SelectMode.SM_SelectClose;
            }
            if (strategyList.Count == 0)
            {
                throw new Exception("No strategy provide!");
            }
            SelectResult re = select(dsh, selectMode, Utils.NowDate(), strategyList);

            foreach (var item in re.selItems_)
            {
                item.allSelectItems_ = re.selItems_;
            }
            var buyItem = App.grp_.makeDeside(re.selItems_, Utils.NowDate(), RankBuyDesider.buyer_, true);

            if (buyItem != null)
            {
                buyItem.iamBuyItem_ = true;
            }
            re.selItems_.Sort(delegate(SelectItem lhs, SelectItem rhs)
            {
                if (lhs.iamBuyItem_)
                {
                    return(-1);
                }
                if (rhs.iamBuyItem_)
                {
                    return(1);
                }
                return(Utils.ToType <int>(lhs.getColumnVal("prirank")).CompareTo(Utils.ToType <int>(rhs.getColumnVal("prirank"))));
            });


            return(re);
        }
Esempio n. 10
0
        public SelectResult select(DataStoreHelper dsh, SelectMode selectMode, int date, List <IStrategy> strategyList, SelectHint hint = null)
        {
            bool bShowProgress = date == Utils.NowDate();

            if (bShowProgress)
            {
                App.host_.uiStartProcessBar();
            }
            SelectResult re = new SelectResult();

            dsh.iSZIndex_ = App.ds_.index(App.ds_.szListData_, date);
            for (int isk = 0; isk < App.ds_.stockList_.Count; ++isk)
            {
                Stock sk = App.ds_.stockList_[isk];
                if (bShowProgress)
                {
                    App.host_.uiSetProcessBar(String.Format("正在检测是否选择{0}", sk.code_), isk * 100 / App.ds_.stockList_.Count);
                }
                int iDateIndexHint = -1;
                if (hint != null)
                {
                    iDateIndexHint = hint.nextWantedIndexHintDict_[sk];
                }
                dsh.setStock(sk);
                for (int i = 0; i < strategyList.Count; ++i)
                {
                    IStrategy stra = strategyList[i];
                    Dictionary <String, String> rateItemDict = null;
                    String sigInfo = "";
                    try {
                        int iIndex = App.ds_.index(sk, date, iDateIndexHint);
                        if (iIndex == -1)
                        {
                            continue;
                        }
                        if (hint != null)
                        {
                            hint.nextWantedIndexHintDict_[sk] = iIndex + 1;
                        }
                        dsh.iIndex_ = iIndex;

                        if (dsh.dataList_[iIndex] == Data.NowInvalidData)
                        {
                            continue;
                        }

                        FocusOn fon            = stra.focusOn();
                        int     beforDateCount = sk.dataList_.Count - iIndex;
                        bool    isNewStock     = beforDateCount < Setting.MyNewStockLimit;
                        switch (fon)
                        {
                        case FocusOn.FO_Old:
                            if (isNewStock)
                            {
                                continue;
                            }
                            break;

                        case FocusOn.FO_All:
                            break;

                        case FocusOn.FO_New:
                            if (!isNewStock)
                            {
                                continue;
                            }
                            break;

                        default:
                            throw new ArgumentException("Unknown focusOn");
                        }
                        if (!isNewStock && dsh.MA(Info.A, 5, 1) < 20000)
                        {
                            continue;
                        }

                        rateItemDict = stra.select(dsh, selectMode, ref sigInfo);
                        if (rateItemDict == null)
                        {
                            continue;
                        }
                    } catch (DataException /*ex*/) {
                        continue;
                    }
                    SelectItem selItem = new SelectItem();
                    selItem.code_         = sk.code_;
                    selItem.date_         = date;
                    selItem.sigInfo_      = sigInfo;
                    selItem.strategyName_ = stra.name();
                    selItem.rateItemDict_ = rateItemDict;
                    re.selItems_.Add(selItem);
                }
            }
            Dictionary <String, int> strategySelCountDict = new Dictionary <String, int>();

            foreach (var item in re.selItems_)
            {
                if (strategySelCountDict.ContainsKey(item.strategyName_))
                {
                    ++strategySelCountDict[item.strategyName_];
                }
                else
                {
                    strategySelCountDict.Add(item.strategyName_, 1);
                }
            }
            foreach (var item in re.selItems_)
            {
                item.sameDayStrategySelCount_ = strategySelCountDict[item.strategyName_];
                item.sameDaySelCount_         = re.selItems_.Count;
            }
            if (bShowProgress)
            {
                App.host_.uiFinishProcessBar();
            }
            return(re);
        }
Esempio n. 11
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            IStrategy stra = (IStrategy)this;
            var       zf   = dsh.Ref(Info.ZF);

            if (zf > 0.095 || zf < -0.095)
            {
                return(null);
            }
            if (dsh.birthCount() > 50)
            {
                return(null);
            }
            int iOpenUpStopIndex = -1;
            int nDayCount        = 0;

            for (int i = dsh.dataList_.Count - 2; i > 0; --i)
            {
                if (dsh.ds_.Ref(Info.ZF, dsh.dataList_, i) < 0.095)
                {
                    iOpenUpStopIndex = i - dsh.iIndex_;
                    break;
                }
                ++nDayCount;
            }
            if (nDayCount < 3)
            {
                return(null);
            }
            if (iOpenUpStopIndex == -1)
            {
                return(null);
            }
            int iTopMostIndex = -1;

            iTopMostIndex = iOpenUpStopIndex + 1;
            float topMostSimpleC     = Math.Max(dsh.Ref(Info.O, iTopMostIndex), dsh.Ref(Info.C, iTopMostIndex));
            int   iSerarchBeginIndex = -1;

            for (int i = iOpenUpStopIndex; i > 0; --i)
            {
                float curTop = Math.Max(dsh.Ref(Info.O, i), dsh.Ref(Info.C, i));
                if (curTop > topMostSimpleC)
                {
                    topMostSimpleC = curTop;
                    iTopMostIndex  = i;
                }
                if (
                    (dsh.Ref(Info.C, i) < dsh.Ref(Info.O, i)) &&
                    dsh.MaxCO(i) > dsh.MaxCO(i - 1))
                {
                    iSerarchBeginIndex = i;
                    break;
                }
            }
            if (iTopMostIndex == -1 || iSerarchBeginIndex == -1)
            {
                return(null);
            }

            for (int i = 3; i >= 1; --i)
            {
                bool bContinue = true;
                if (dsh.Ref(Info.ZF, iTopMostIndex - i) > 0.095)
                {
                    for (int j = iTopMostIndex - i; j > 0; --j)
                    {
                        if (dsh.Ref(Info.ZF, j) < 0)
                        {
                            bContinue = false;
                            break;
                        }
                        float curTop = Math.Max(dsh.Ref(Info.O, j), dsh.Ref(Info.C, j));
                        if (curTop > topMostSimpleC)
                        {
                            topMostSimpleC = curTop;
                            iTopMostIndex  = iTopMostIndex - i;
                        }
                    }
                }
                if (!bContinue)
                {
                    break;
                }
            }

            int   iSearchIndex2 = iSerarchBeginIndex;
            float topMostC      = topMostSimpleC;

            sigInfo = dsh.Date(iTopMostIndex).ToString();

            int   iStruggleUpIndex = -1;
            float maxUpZF          = float.MinValue;

            for (int i = iSearchIndex2; i >= 0; --i)
            {
                if (iStruggleUpIndex == -1)
                {
                    if (dsh.Ref(Info.C, i + 2) < topMostC && (dsh.Ref(Info.C, i + 1) - topMostC) / topMostC > 0)
                    {
                        iStruggleUpIndex = i;
                    }
                }
                float curZF = (dsh.Ref(Info.C, i) - topMostC) / topMostC;
                maxUpZF = Math.Max(curZF, maxUpZF);
            }
            if (iStruggleUpIndex == -1)
            {
                return(null);
            }

            return(selectForHStrugle(dsh, topMostC, maxUpZF));
        }
Esempio n. 12
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0.095 || zf < -0.095)
            {
                return(null);
            }
            if (zf < 0.01)
            {
                return(null);
            }
            if (dsh.IsLikeSTStop())
            {
                return(null);
            }
            if (dsh.DownShadow() < -0.04)
            {
                return(null);
            }

            if ((dsh.Ref(Info.C, 1) - dsh.Ref(Info.L, 3)) / dsh.Ref(Info.C, 1) > 0)
            {
                return(null);
            }
            if (dsh.Ref(Info.HL, 1) > dsh.Ref(Info.HL, 2) * 2)
            {
                return(null);
            }
            if (dsh.Ref(Info.HL, 2) > dsh.Ref(Info.HL, 1) * 2)
            {
                return(null);
            }
            if (dsh.Ref(Info.C) < dsh.Ref(Info.O, 1))
            {
                return(null);
            }
            if ((dsh.Ref(Info.C, 1) - dsh.Ref(Info.O, 5)) / dsh.Ref(Info.C, 1) > 0.01)
            {
                return(null);
            }
            if (dsh.Ref(Info.L) < dsh.Ref(Info.L, 1) && dsh.Ref(Info.H) > dsh.Ref(Info.H, 1))
            {
                return(null);
            }

            if (dsh.AccZF(2, 1) < -0.1)
            {
                return(null);
            }
            if (dsh.AccZF(3) > 0.02)
            {
                return(null);
            }
            if (dsh.AccZF(2) < -0.04)
            {
                return(null);
            }
            var accZF6 = dsh.AccZF(6);

            if (accZF6 > 0.08)
            {
                return(null);
            }
            int nDownCount = 2;

            if (dsh.EveryDown(1) != nDownCount)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, nDownCount + 1) < 0.01)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, dsh.HH(Info.ZF, 6)) < 0.03)
            {
                return(null);
            }

            if (dsh.Ref(Info.ZF, nDownCount + 2) > -0.01)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, nDownCount + 3) < 0.01)
            {
                return(null);
            }
            var upV   = dsh.Acc(Info.V, 6, 0, 1);
            var downV = dsh.Acc(Info.V, 6, 0, -1);

            if (upV > downV * 1.5)
            {
                return(null);
            }

            for (int i = 0; i <= 5; ++i)
            {
                var curOF = dsh.Ref(Info.OF, i);
                var curZF = dsh.Ref(Info.ZF, i);
                if (!dsh.IsReal(i))
                {
                    return(null);
                }
                if (curZF > 0.095 || curZF < -0.095)
                {
                    return(null);
                }
                if (curOF > 0.02 && curZF < 0)
                {
                    return(null);
                }
                if (curOF < -0.02 && curZF < 0)
                {
                    return(null);
                }
                if (dsh.Ref(Info.CO, i) / dsh.Ref(Info.C, i + 1) < 0.006)
                {
                    return(null);
                }
            }
            var szZF = dsh.SZRef(Info.ZF);

            if (szZF > 0 && szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03)
            {
                return(null);
            }
            if (!selectBySZ(dsh))
            {
                return(null);
            }
            return(EmptyRateItemButSel);
        }
Esempio n. 13
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            IStrategy_LF stra = (IStrategy_LF)this;

            if (!meetBuyChance(dsh, selectMode))
            {
                return(null);
            }

            if (dsh.Ref(Info.OF) > 0.04 || dsh.Ref(Info.OF) < -0.015 || dsh.Ref(Info.ZF, 1) < -0.02 || dsh.Ref(Info.OF, 1) < -0.03)
            {
                return(null);
            }
            if (dsh.Ref(Info.CO, 1) / dsh.Ref(Info.C, 1) < 0.01)
            {
                return(null);
            }
            int   iSigDateIndex         = -1;
            int   nUpCount              = 0;
            int   nUStopCount           = 0;
            int   nDStopCount           = 0;
            bool  bMeetTradeSigAllready = false;
            bool  bMeetRealUp           = false;
            float sigDateVol            = 0;
            float otherMaxVol           = 0;
            bool  bHasUpShadowTooHight  = false;
            bool  bHasDownShadowTooLow  = false;
            float otherMaxZF            = 0;
            float otherMaxC             = 0;
            float otherMaxH             = 0;
            float sumOfSigDateZF        = 0;

            for (int i = 1; i < 8; ++i)
            {
                var curOf    = dsh.Ref(Info.OF, i);
                var curHf    = dsh.Ref(Info.HF, i);
                var curZf    = dsh.Ref(Info.ZF, i);
                var curPreZf = dsh.Ref(Info.ZF, i + 1);
                var vol      = dsh.Ref(Info.V, i);
                if (curOf < 0.03 && curZf > 0.03 && curZf < 0.095 &&
                    dsh.Ref(Info.OF, i + 1) < 0.03 && dsh.Ref(Info.ZF, i + 1) > 0.03)
                {
                    for (int j = i + 2; j < i + 5; j++)
                    {
                        if (dsh.Ref(Info.ZF, j) < 0)
                        {
                            break;
                        }

                        if (dsh.Ref(Info.ZF, j) > 0.05)
                        {
                            return(null);
                        }
                    }
                    bool bHasDown = false;
                    for (int j = i + 2; j < i + 7; j++)
                    {
                        if (dsh.Ref(Info.ZF, j) < 0)
                        {
                            bHasDown = true;
                            break;
                        }
                    }
                    if (dsh.AccZF(8, i + 2) < -0.15)
                    {
                        return(null);
                    }
                    float preVol = dsh.Ref(Info.V, i + 1);
                    float chkVol = Math.Max(vol, preVol);
                    for (int j = i + 2; j < i + 6; ++j)
                    {
                        if (dsh.Ref(Info.V, j) > chkVol * 2)
                        {
                            return(null);
                        }
                    }
                    if (!bHasDown)
                    {
                        return(null);
                    }
                    sumOfSigDateZF = curZf + dsh.Ref(Info.ZF, i + 1);
                    if (sumOfSigDateZF > 0.1)
                    {
                        iSigDateIndex = i;
                        sigDateVol    = Math.Max(dsh.Ref(Info.V, i + 1), vol);
                        break;
                    }
                }
                otherMaxVol = Math.Max(vol, otherMaxVol);
                if (curZf > 0 && dsh.IsReal(i))
                {
                    nUpCount++;
                }
                if (curZf > 0.095)
                {
                    nUStopCount++;
                }
                else if (curZf < -0.095)
                {
                    nDStopCount++;
                }
                if (curZf < -0.03)
                {
                    bMeetTradeSigAllready = true;
                }
                else if (curZf > 0.012)
                {
                    bMeetRealUp = true;
                }

                if (dsh.UpShadow(i) > 0.03)
                {
                    bHasUpShadowTooHight = true;
                }

                if (dsh.DownShadow(i) < -0.03)
                {
                    bHasDownShadowTooLow = true;
                }
                otherMaxZF = Math.Max(otherMaxZF, curZf);
                otherMaxC  = Math.Max(dsh.Ref(Info.C, i), otherMaxC);
                otherMaxH  = Math.Max(dsh.Ref(Info.H, i), otherMaxH);
            }
            if (iSigDateIndex == -1)
            {
                return(null);
            }
            sigInfo = dsh.Date(iSigDateIndex).ToString();

            int iMaxCOIndex = dsh.HH(Info.CO, 30, 1);

            if (dsh.Ref(Info.ZF, iMaxCOIndex) < 0)
            {
                return(null);
            }
            if (nUpCount < 2)
            {
                return(null);
            }
            if (dsh.Ref(Info.C, 1) * (1 + stra.buyLimit() - 0.01) < dsh.Ref(Info.L, iSigDateIndex))
            {
                return(null);
            }
            if (/*nUStopCount > 0 ||*//* nDStopCount > 0 || */ bMeetTradeSigAllready || !bMeetRealUp)
            {
                return(null);
            }
            if (sigDateVol > otherMaxVol * 2)
            {
                return(null);
            }
            float maxUpF = (otherMaxC - dsh.Ref(Info.C, iSigDateIndex)) / dsh.Ref(Info.C, iSigDateIndex);

            if (maxUpF < 0.015 /* || maxUpF > 0.04*/)
            {
                return(null);
            }
            if (sigDateVol < otherMaxVol * 1.2)
            {
                return(null);
            }

            if (bHasUpShadowTooHight || bHasDownShadowTooLow)
            {
                return(null);
            }


            if (
                dsh.Ref(Info.ZF, 2) < 0.005 &&
                dsh.Ref(Info.ZF, 3) < 0.005)
            {
                return(null);
            }
            if (Math.Min(dsh.Ref(Info.ZF, iSigDateIndex), dsh.Ref(Info.ZF, iSigDateIndex + 1)) + dsh.Ref(Info.ZF, iSigDateIndex + 2) < -0.01)
            {
                return(null);
            }


            if (dsh.Ref(Info.C, iSigDateIndex) < dsh.Ref(Info.O, iSigDateIndex))
            {
                return(null);
            }
            if (dsh.Ref(Info.C, iSigDateIndex + 1) < dsh.Ref(Info.O, iSigDateIndex + 1))
            {
                return(null);
            }
            return(EmptyRateItemButSel);
//             var delta = (dsh.Ref(Info.C) - dsh.Ref(Info.O, 1)) / dsh.Ref(Info.C, 1);
//             if (delta > -0.01)
//             {
//                 return null;
//             }
//             var ret = new Dictionary<String, String>();
//             ret[String.Format("sumSig/{0}", sumOfSigDateZF>0.12 ? "1": "0")] = "";
//             ret[String.Format("delta/{0}", delta < -0.02 ? "1" : "0")] = "";
//             ret[String.Format("maxUp/{0}", maxUpF > 0.02 ? "1" : "0")] = "";
//             ret[String.Format("diffzf/{0}", otherMaxZF + zf > -0.02 ? "1" : "0")] = "";
//             return ret;
        }
Esempio n. 14
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0.095 || zf < -0.095)
            {
                return(null);
            }
            if (zf > 0.03 || zf < 0.02)
            {
                return(null);
            }

            if (!dsh.IsReal())
            {
                return(null);
            }
            if (dsh.UpShadow() > 0.04)
            {
                return(null);
            }
            var of = dsh.Ref(Info.OF);

            if (of > 0.02 || of < -0.04)
            {
                return(null);
            }
            if ((dsh.Ref(Info.H) - dsh.Ref(Info.H, 1)) / dsh.Ref(Info.C, 1) < -0.03)
            {
                return(null);
            }
            int   nOccurCount     = 0;
            bool  bSearchDown     = true;
            int   iMaxSearchIndex = 1;
            float maxDownVol      = float.MinValue;
            float maxUpVol        = float.MinValue;

            for (int i = 1; i < 100; ++i)
            {
                var curZF = dsh.Ref(Info.ZF, i);
                var curOf = dsh.Ref(Info.OF, i);
                if (curOf > 0.04 && curZF < 0)
                {
                    return(null);
                }
                if (curOf < -0.02 && curZF < 0)
                {
                    return(null);
                }
                if (curZF < -0.095)
                {
                    break;
                }
                if (!dsh.IsReal(i))
                {
                    return(null);
                }
                if (bSearchDown && curZF > 0)
                {
                    break;
                }
                if (!bSearchDown && curZF < 0)
                {
                    break;
                }
                if (dsh.Ref(Info.CO, i) / dsh.Ref(Info.C, 1) < 0.01)
                {
                    break;
                }
                if (dsh.IsReal(i) && curZF < -0.01 &&
                    dsh.IsReal(i + 1) && dsh.Ref(Info.ZF, i + 1) > 0.01 &&
                    dsh.IsReal(i + 2) && dsh.Ref(Info.ZF, i + 2) < -0.01)
                {
                    ++nOccurCount;
                    iMaxSearchIndex = i;
                }
                bSearchDown = !bSearchDown;
                if (curZF > 0)
                {
                    maxUpVol = Math.Max(maxUpVol, dsh.Ref(Info.V, i));
                }
                else
                {
                    maxDownVol = Math.Max(maxDownVol, dsh.Ref(Info.V, i));
                }
            }
            if (nOccurCount != 2)
            {
                return(null);
            }
            if (dsh.Ref(Info.V) > Math.Max(maxDownVol, maxUpVol) * 1.5)
            {
                return(null);
            }
            if (maxUpVol > maxDownVol * 2)
            {
                return(null);
            }

            var szZF = dsh.SZRef(Info.ZF);

            if (szZF > 0 && szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03)
            {
                return(null);
            }
            if (!selectBySZ(dsh))
            {
                return(null);
            }
            return(EmptyRateItemButSel);
        }
Esempio n. 15
0
 Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
 {
     return(selectFor(dsh, selectMode, ref sigInfo));
 }
Esempio n. 16
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0 || zf < -0.06)
            {
                return(null);
            }
            if (!dsh.IsReal())
            {
                return(null);
            }
            if (dsh.Ref(Info.OF, 1) < -0.03)
            {
                return(null);
            }
            int   iSigDateIndex         = -1;
            int   nUpCount              = 0;
            int   nUStopCount           = 0;
            int   nDStopCount           = 0;
            bool  bMeetTradeSigAllready = false;
            bool  bMeetRealUp           = false;
            float sigDateVol            = 0;
            float otherMaxVol           = 0;
            bool  bHasUpShadowTooHight  = false;
            bool  bHasDownShadowTooLow  = false;
            float otherMaxZF            = 0;
            float otherMaxC             = 0;
            float otherMaxH             = 0;
            float sumOfSigDateZF        = 0;
            float totalUp   = 0;
            float totalDown = 0;

            for (int i = 1; i < 8; ++i)
            {
                var curOf    = dsh.Ref(Info.OF, i);
                var curHf    = dsh.Ref(Info.HF, i);
                var curZf    = dsh.Ref(Info.ZF, i);
                var curPreZf = dsh.Ref(Info.ZF, i + 1);
                var vol      = dsh.Ref(Info.V, i);
                if (curOf < 0.03 && curZf > 0.03 && curZf < 0.095 &&
                    dsh.Ref(Info.OF, i + 1) < 0.03 && dsh.Ref(Info.ZF, i + 1) > 0.03)
                {
                    for (int j = i + 2; j < i + 5; j++)
                    {
                        if (dsh.Ref(Info.ZF, j) < 0)
                        {
                            break;
                        }

                        if (dsh.Ref(Info.ZF, j) > 0.05)
                        {
                            return(null);
                        }
                    }
                    if (dsh.AccZF(8, i + 2) < -0.15)
                    {
                        return(null);
                    }
                    float preVol = dsh.Ref(Info.V, i + 1);
                    float chkVol = Math.Max(vol, preVol);
                    for (int j = i + 2; j < i + 6; ++j)
                    {
                        if (dsh.Ref(Info.V, j) > chkVol * 2)
                        {
                            return(null);
                        }
                    }
                    sumOfSigDateZF = curZf + dsh.Ref(Info.ZF, i + 1);
                    if (sumOfSigDateZF > 0.1)
                    {
                        iSigDateIndex = i;
                        sigDateVol    = Math.Max(dsh.Ref(Info.V, i + 1), vol);
                        break;
                    }
                }
                otherMaxVol = Math.Max(vol, otherMaxVol);
                if (curZf > 0 && dsh.IsReal(i))
                {
                    nUpCount++;
                }

                if (curZf > 0.095)
                {
                    nUStopCount++;
                }
                else if (curZf < -0.095)
                {
                    nDStopCount++;
                }
                if (curZf < -0.03)
                {
                    bMeetTradeSigAllready = true;
                }
                else if (curZf > 0.012)
                {
                    bMeetRealUp = true;
                }

                if (curZf > 0)
                {
                    totalUp += curZf;
                }
                else
                {
                    totalDown += curZf;
                }
                if (dsh.UpShadow(i) > 0.03)
                {
                    bHasUpShadowTooHight = true;
                }

                if (dsh.DownShadow(i) < -0.03)
                {
                    bHasDownShadowTooLow = true;
                }
                otherMaxZF = Math.Max(otherMaxZF, curZf);
                otherMaxC  = Math.Max(dsh.Ref(Info.C, i), otherMaxC);
                otherMaxH  = Math.Max(dsh.Ref(Info.H, i), otherMaxH);
            }
            if (iSigDateIndex == -1)
            {
                return(null);
            }
            //          sigInfo = dsh.Date(iSigDateIndex).ToString();
            if (dsh.Ref(Info.C) < dsh.Ref(Info.L, iSigDateIndex))
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF) + Math.Min(dsh.Ref(Info.ZF, iSigDateIndex), dsh.Ref(Info.ZF, iSigDateIndex + 1)) < -0.01)
            {
                return(null);
            }
            if (totalDown + totalUp < -0.01)
            {
                return(null);
            }
            if (nUpCount < 2)
            {
                return(null);
            }

            if (/*nUStopCount > 0 ||*//* nDStopCount > 0 || */ bMeetTradeSigAllready || !bMeetRealUp)
            {
                return(null);
            }

            float maxUpF = (otherMaxC - dsh.Ref(Info.C, iSigDateIndex)) / dsh.Ref(Info.C, iSigDateIndex);

            if (maxUpF < 0.015 /* || maxUpF > 0.04*/)
            {
                return(null);
            }
            if (sigDateVol < otherMaxVol * 1.2)
            {
                return(null);
            }
            if (sigDateVol > otherMaxVol * 2)
            {
                return(null);
            }
            if (otherMaxZF + zf > 0)
            {
                return(null);
            }
            sigInfo = (otherMaxZF + zf).ToString("F4");


            if (dsh.Ref(Info.LF) < -0.06)
            {
                return(null);
            }
            if (bHasUpShadowTooHight || bHasDownShadowTooLow)
            {
                return(null);
            }
            //             if (dsh.Ref(Info.OF) < -0.02)
            //             {
            //                 return null;
            //             }

            if (
                dsh.Ref(Info.ZF, 2) < 0.005 &&
                dsh.Ref(Info.ZF, 3) < 0.005)
            {
                return(null);
            }

            //             if (dsh.Ref(Info.ZF, iSigDateIndex-1) < 0 &&
            //                  dsh.Ref(Info.ZF, iSigDateIndex - 2) < 0)
            //             {
            //                 return null;
            //             }

            if (dsh.Ref(Info.C, iSigDateIndex) < dsh.Ref(Info.O, iSigDateIndex))
            {
                return(null);
            }
            if (dsh.Ref(Info.C, iSigDateIndex + 1) < dsh.Ref(Info.O, iSigDateIndex + 1))
            {
                return(null);
            }

            var delta = (dsh.Ref(Info.C) - dsh.Ref(Info.O, 1)) / dsh.Ref(Info.C, 1);

            if (delta > -0.01)
            {
                return(null);
            }
            var szZF = dsh.SZRef(Info.ZF);

            if (szZF > 0 && szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03)
            {
                return(null);
            }
            if (!selectBySZ(dsh))
            {
                return(null);
            }
            var ret = new Dictionary <String, String>();

            ret[String.Format("delta/{0}", delta < -0.02 ? "1" : "0")]           = "";
            ret[String.Format("maxUp/{0}", maxUpF > 0.02 ? "1" : "0")]           = "";
            ret[String.Format("maxZF/{0}", otherMaxZF + zf > -0.01 ? "1" : "0")] = "";
            ret[String.Format("prezf/{0}", dsh.Ref(Info.ZF, 1) > 0 ? "1" : "0")] = "";
            return(ret);
        }
Esempio n. 17
0
        Dictionary <String, String> selectFor(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo, int iIndex, out bool isTwoDownMode)
        {
            isTwoDownMode = false;
            var zf = dsh.Ref(Info.ZF, iIndex);

            if (zf > -0.05 || zf < -0.095)
            {
                return(null);
            }
            if (!dsh.IsRealDown())
            {
                return(null);
            }
            if (zf < -0.09 && dsh.Ref(Info.ZF, iIndex + 1) < -0.08)
            {
                return(null);
            }

            int   iSigDateIndex            = -1;
            int   nUStopCount              = 0;
            int   nDStopCount              = 0;
            float sigDateVol               = 0;
            float sigZF                    = 0;
            int   nMeetMinus5PercentCount  = 0;
            int   iFirstMinus5PercentIndex = -1;
            int   iTwoMinus5PercentIndex   = -1;
            int   nPlus5PercentCount       = 0;
            bool  bDanger                  = false;

            for (int i = iIndex + 1; i < SearchDayCount; ++i)
            {
                var curOf    = dsh.Ref(Info.OF, i);
                var curHf    = dsh.Ref(Info.HF, i);
                var curZf    = dsh.Ref(Info.ZF, i);
                var curLf    = dsh.Ref(Info.LF, i);
                var curPreZf = dsh.Ref(Info.ZF, i + 1);
                var vol      = dsh.Ref(Info.V, i);
                if (dsh.IsUpStopEveryDay(EveryUpCount, i))
                {
                    iSigDateIndex = i;
                    sigDateVol    = vol;
                    sigZF         = curZf;
                    break;
                }
                if (curHf > 0.095 && curZf < 0)
                {
                    bDanger = true;
                }
            }
            for (int i = iSigDateIndex + EveryUpCount; i < iSigDateIndex + EveryUpCount + SearchDayCount; i++)
            {
                if (dsh.IsUpStopEveryDay(EveryUpCount, i))
                {
                    return(null);
                }
            }
            for (int i = iSigDateIndex - 1; i > iIndex; --i)
            {
                var curOf    = dsh.Ref(Info.OF, i);
                var curHf    = dsh.Ref(Info.HF, i);
                var curZf    = dsh.Ref(Info.ZF, i);
                var curLf    = dsh.Ref(Info.LF, i);
                var curPreZf = dsh.Ref(Info.ZF, i + 1);
                var vol      = dsh.Ref(Info.V, i);
                if (curZf > 0.095)
                {
                    nUStopCount++;
                }
                else if (curZf < -0.095)
                {
                    nDStopCount++;
                }
                if (curZf < -0.05)
                {
                    if (iFirstMinus5PercentIndex == -1)
                    {
                        iFirstMinus5PercentIndex = i;
                    }
                    ++nMeetMinus5PercentCount;
                    if (nMeetMinus5PercentCount == 2)
                    {
                        iTwoMinus5PercentIndex = i;
                    }
                }
                if (curZf > 0.06)
                {
                    ++nPlus5PercentCount;
                }
            }
            if (iSigDateIndex == -1)
            {
                return(null);
            }
            int orgThreshold = 3;
            int nThreshold   = orgThreshold;

            if (iTwoMinus5PercentIndex != -1)
            {
                bool bHasUp = false;
                for (int i = iIndex + 1; i < iTwoMinus5PercentIndex; i++)
                {
                    if (dsh.Ref(Info.ZF, i) > 0.01)
                    {
                        bHasUp = true;
                        break;
                    }
                }
                if (!bHasUp)
                {
                    nThreshold++;
                }
            }
            if (nThreshold == orgThreshold)
            {
                if (dsh.Ref(Info.ZF, 1 + iIndex) < 0 &&
                    dsh.Ref(Info.ZF, 2 + iIndex) < 0)
                {
                    nThreshold++;
                }
            }

//             if (nDStopCount > 1)
//             {
//                 return null;
//             }
            nThreshold += nPlus5PercentCount;
            nThreshold += nDStopCount;

            if (dsh.UpShadow(1) > 0.04 && dsh.Ref(Info.ZF, 1) < 0 && dsh.Ref(Info.ZF) > -0.08)
            {
                ++nThreshold;
            }
            //  nThreshold += (int)Math.Ceiling(nPlus5PercentCount*0.5);
            if (nMeetMinus5PercentCount < nThreshold - 1)
            {
                return(null);
            }

            if (nMeetMinus5PercentCount > nThreshold - 1)
            {
                if (dsh.Ref(Info.ZF, iIndex + 1) > 0)
                {
                    return(null);
                }
            }
            var preZF = dsh.Ref(Info.ZF, iIndex + 1);

            if (preZF > 0.02)
            {
                isTwoDownMode = true;
                return(null);
            }
            if (dsh.AccZF(3, iIndex + 1) > 0.02 && dsh.EveryUp(iIndex + 1) >= 3)
            {
                isTwoDownMode = true;
            }

            if (bDanger)
            {
                return(null);
            }
//             if (dsh.Ref(Info.C, iIndex) > dsh.Ref(Info.O, iIndex))
//             {
//                 return null;
//             }
            var ret = new Dictionary <String, String>();

            ret[String.Format("Threshold/{0}", nThreshold)] = "";
            ret[String.Format("Meet/{0}", nMeetMinus5PercentCount == nThreshold - 1 ? "1" : "0")] = "";
            return(ret);
        }
Esempio n. 18
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0.095 || zf < -0.095)
            {
                return(null);
            }
            if (zf > 0.002 || zf < -0.002)
            {
                return(null);
            }
//             if (Math.Abs(dsh.Ref(Info.C) - dsh.Ref(Info.C, 1)) > 0.02*Setting.NormalizeRate)
//             {
//                 return null;
//             }
            if (dsh.Ref(Info.HF) < 0.012)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 2) < 0.04 || dsh.Ref(Info.ZF, 2) > 0.095)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 1) < 0.01 || dsh.Ref(Info.ZF, 1) > 0.095)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 3) < -0.095)
            {
                return(null);
            }
            if (dsh.Ref(Info.V) > dsh.Ref(Info.V, 1) * 1.2 && dsh.Ref(Info.V) > dsh.Ref(Info.V, 2) * 1.2)
            {
                return(null);
            }
            if (dsh.Ref(Info.OF) < -0.002 || dsh.Ref(Info.OF) > 0.005)
            {
                return(null);
            }
            if (dsh.AccZF(8, 3) < -0.15)
            {
                return(null);
            }
            var accZF3 = dsh.AccZF(3, 3);

            if (accZF3 > 0.02 && accZF3 < 0.05)
            {
                return(null);
            }
            if (accZF3 > 0.1)
            {
                return(null);
            }
            if (dsh.Ref(Info.OF, 1) > 0.03)
            {
                return(null);
            }
            if (dsh.Ref(Info.OF, 2) > 0.03)
            {
                return(null);
            }
            if (dsh.Ref(Info.HF, 1) > 0.095)
            {
                return(null);
            }
            int iMaxVolIndex = dsh.HH(Info.V, 20, 3);

            if (dsh.Ref(Info.C, iMaxVolIndex) < dsh.Ref(Info.O, iMaxVolIndex))
            {
                return(null);
            }
            else
            {
                if (dsh.Ref(Info.HF, iMaxVolIndex - 1) <= 0 &&
                    dsh.Ref(Info.L, iMaxVolIndex - 1) <= dsh.Ref(Info.L, iMaxVolIndex))
                {
                    return(null);
                }
                if (dsh.UpShadow(iMaxVolIndex) > 0.06)
                {
                    return(null);
                }
            }
            for (int i = 0; i < 8; ++i)
            {
                if (dsh.UpShadow(i) > 0.04)
                {
                    return(null);
                }
            }
            int iMaxCOIndex = dsh.HH(Info.CO, 30, 1);

            if (dsh.Ref(Info.C, iMaxCOIndex) > dsh.Ref(Info.O, iMaxCOIndex))
            {
                return(null);
            }

            if (!selectBySZ(dsh))
            {
                return(null);
            }
            var ret = new Dictionary <String, String>();

            ret[String.Format("of/{0}", dsh.Ref(Info.OF) > 0 ? "1" : "-1")]               = "";
            ret[String.Format("hf/{0}", dsh.Ref(Info.HF) > 0.02 ? "1" : "-1")]            = "";
            ret[String.Format("zf/{0}", Math.Abs(dsh.Ref(Info.ZF)) > 0.001 ? "1" : "-1")] = "";
            return(ret);
        }
Esempio n. 19
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0.095 || zf < -0.095)
            {
                return(null);
            }
            if (zf < 0.02 || zf > 0.03)
            {
                return(null);
            }
            if (dsh.IsLikeSTStop())
            {
                return(null);
            }
            if (dsh.Ref(Info.OF) < -0.015)
            {
                return(null);
            }
            if (dsh.EveryDown(1) >= 3)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 1) > -0.02 || dsh.Ref(Info.ZF, 1) < -0.05)
            {
                return(null);
            }
            if (dsh.UpShadow() > 0.04)
            {
                return(null);
            }
            if (dsh.Ref(Info.CO) / dsh.Ref(Info.C, 1) < 0.01)
            {
                return(null);
            }
            if (dsh.AccZF(8) > -0.1)
            {
                return(null);
            }
            if (dsh.AccZF(2) > 0)
            {
                return(null);
            }
            if (dsh.HH(Info.V, 8) == 0)
            {
                return(null);
            }
            if (dsh.DownShadow() < -0.04)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 2) < -0.01)
            {
                return(null);
            }
            if (!dsh.IsReal())
            {
                return(null);
            }

            for (int i = 1; i < 8; ++i)
            {
                var curZF = dsh.Ref(Info.ZF, i);
                var curOF = dsh.Ref(Info.OF, i);
                if (curZF < -0.095 || curZF > 0.095)
                {
                    return(null);
                }
                if (curOF > 0.04 && dsh.IsGreen(i))
                {
                    return(null);
                }
                if (dsh.IsUpStopEveryDay(3, i))
                {
                    return(null);
                }
            }
            if (!selectBySZ(dsh))
            {
                return(null);
            }

            return(EmptyRateItemButSel);
        }
Esempio n. 20
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            IStrategy_LF stra = (IStrategy_LF)this;

            if (!meetBuyChance(dsh, selectMode))
            {
                return(null);
            }

            if (dsh.Ref(Info.OF) > 0.04 || dsh.Ref(Info.OF) < -0.015 || dsh.Ref(Info.ZF, 1) < -0.02 || dsh.Ref(Info.OF, 1) < -0.03)
            {
                return(null);
            }
            if (dsh.Ref(Info.CO, 1) / dsh.Ref(Info.C, 1) < 0.01)
            {
                return(null);
            }

            int   iSigDateIndex         = -1;
            int   nUpCount              = 0;
            int   nDownCount            = 0;
            int   nUStopCount           = 0;
            int   nDStopCount           = 0;
            bool  bMeetTradeSigAllready = false;
            bool  bMeetRealUp           = false;
            bool  bHasUpShadowTooHight  = false;
            bool  bHasDownShadowTooLow  = false;
            float otherMaxVol           = float.MinValue;
            float otherMaxC             = float.MinValue;
            float otherMaxH             = float.MinValue;
            float otherMaxZF            = float.MinValue;
            float sigDateVol            = 0;
            float sigZF         = 0;
            float minDownShadow = float.MaxValue;
            float maxUpShadow   = float.MinValue;
            float otherMinZF    = float.MaxValue;
            float totalUp       = 0;
            float totalDown     = 0;

            for (int i = 1; i < 8; ++i)
            {
                var curOf    = dsh.Ref(Info.OF, i);
                var curHf    = dsh.Ref(Info.HF, i);
                var curZf    = dsh.Ref(Info.ZF, i);
                var curPreZf = dsh.Ref(Info.ZF, i + 1);
                var vol      = dsh.Ref(Info.V, i);
                if (curZf > 0.095)
                {
                    return(null);
                }
                if (curOf < 0.04 && curHf > 0.095 && curZf < 0.095 && curZf > 0)
                {
                    iSigDateIndex = i;
                    sigDateVol    = vol;
                    sigZF         = curZf;
                    for (int j = i + 1; j < i + 5; ++j)
                    {
                        if (dsh.Ref(Info.V, j) > vol * 2)
                        {
                            return(null);
                        }
                    }
                    if (dsh.AccZF(8, i + 1) < -0.15)
                    {
                        return(null);
                    }
                    if (dsh.AccZF(3, i + 1) > 0.095)
                    {
                        return(null);
                    }
                    break;
                }
                if (curOf < -0.04)
                {
                    return(null);
                }

                if (curZf > 0 && dsh.IsReal(i))
                {
                    nUpCount++;
                }
                if (curZf < 0 && dsh.IsReal(i))
                {
                    nDownCount++;
                }
                if (curZf > 0.095)
                {
                    nUStopCount++;
                }
                else if (curZf < -0.095)
                {
                    nDStopCount++;
                }
                if (curZf < -0.03)
                {
                    bMeetTradeSigAllready = true;
                }
                else if (curZf > 0.012)
                {
                    bMeetRealUp = true;
                }
                float upShadow   = dsh.UpShadow(i);
                float downShadow = dsh.DownShadow(i);
                if (upShadow > maxUpShadow)
                {
                    maxUpShadow = upShadow;
                }
                if (downShadow < minDownShadow)
                {
                    minDownShadow = downShadow;
                }
                if (curZf > 0)
                {
                    totalUp += curZf;
                }
                else
                {
                    totalDown += curZf;
                }
                otherMaxVol = Math.Max(vol, otherMaxVol);
                otherMaxC   = Math.Max(dsh.Ref(Info.C, i), otherMaxC);
                otherMaxH   = Math.Max(dsh.Ref(Info.H, i), otherMaxH);
                otherMaxZF  = Math.Max(otherMaxZF, curZf);
                otherMinZF  = Math.Min(otherMinZF, curZf);
            }
            if (iSigDateIndex == -1)
            {
                return(null);
            }
            sigInfo = dsh.Date(iSigDateIndex).ToString();

            if (dsh.Ref(Info.ZF, iSigDateIndex) + dsh.Ref(Info.ZF, iSigDateIndex + 1) < -0.01)
            {
                return(null);
            }
            if (sigDateVol > otherMaxVol * 2)
            {
                return(null);
            }
            if (otherMinZF > 0.03)
            {
                return(null);
            }
            if (totalDown + totalUp < -0.01)
            {
                return(null);
            }
            if (otherMaxH < dsh.Ref(Info.H, iSigDateIndex))
            {
                return(null);
            }
            if (dsh.Ref(Info.C, 1) * (1 + stra.buyLimit() - 0.01) < dsh.Ref(Info.L, iSigDateIndex))
            {
                return(null);
            }
            if (maxUpShadow > 0.03)
            {
                bHasUpShadowTooHight = true;
            }

            if (minDownShadow < -0.03)
            {
                bHasDownShadowTooLow = true;
            }
            if (nUpCount < 2)
            {
                return(null);
            }
            if (/*nUStopCount > 0 ||*//* nDStopCount > 0 || */ bMeetTradeSigAllready || !bMeetRealUp)
            {
                return(null);
            }
            float maxUpF = (otherMaxC - dsh.Ref(Info.C, iSigDateIndex)) / dsh.Ref(Info.C, iSigDateIndex);

            if (maxUpF < 0.02 /* || maxUpF > 0.04*/)
            {
                return(null);
            }

//             if (sigDateVol < otherMaxVol * 1.2)
//             {
//                 return null;
//             }

//             if (dsh.Ref(Info.LF) < -0.06)
//             {
//                 return null;
//             }
            if (bHasUpShadowTooHight || bHasDownShadowTooLow)
            {
                return(null);
            }
//             if (dsh.Ref(Info.OF) < -0.02)
//             {
//                 return null;
//             }
            if (
                dsh.Ref(Info.ZF, 2) < 0.005 &&
                dsh.Ref(Info.ZF, 3) < 0.005)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, iSigDateIndex - 1) < 0 && dsh.IsReal(iSigDateIndex - 1) &&
                dsh.Ref(Info.H, iSigDateIndex - 1) > dsh.Ref(Info.H, iSigDateIndex))
            {
                return(null);
            }
//              if (dsh.Ref(Info.ZF, iSigDateIndex-1) < 0 &&
//                   dsh.Ref(Info.ZF, iSigDateIndex - 2) < 0)
//              {
//                  return null;
//              }
            if (dsh.Ref(Info.C, iSigDateIndex) < dsh.Ref(Info.O, iSigDateIndex))
            {
                return(null);
            }

            var delta = (dsh.Ref(Info.C, 1) * (1 + stra.buyLimit() + 0.01) - dsh.Ref(Info.O, 1)) / dsh.Ref(Info.C, 1);

            if (delta > -0.01)
            {
                return(null);
            }
            var ret = new Dictionary <String, String>();

            ret[String.Format("vol/{0}", sigDateVol < otherMaxVol * 1.5 ? "1" : "0")] = "";
            //          ret[String.Format("maxUp/{0}", maxUpF > 0.03 ? "1" : "0")] = "";
            return(ret);
        }
Esempio n. 21
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0.095 || zf < -0.095)
            {
                return(null);
            }
            if (zf > 0.03 || zf < 0.02)
            {
                return(null);
            }
            if (!dsh.IsReal())
            {
                return(null);
            }
            if (dsh.UpShadow() > 0.04)
            {
                return(null);
            }
            var of = dsh.Ref(Info.OF);

            if (of > 0.02 || of < -0.04)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 1) > -0.005)
            {
                return(null);
            }

            if (dsh.Ref(Info.ZF, 2) < 0.005 || !dsh.IsReal(2))
            {
                return(null);
            }
            if (dsh.Ref(Info.V) > dsh.Ref(Info.V, 1) * 1.5)
            {
                return(null);
            }
            if ((dsh.Ref(Info.C) - dsh.Ref(Info.C, 2)) / dsh.Ref(Info.C, 1) > 0.01)
            {
                return(null);
            }
            if (dsh.Ref(Info.C) > dsh.Ref(Info.O, 1))
            {
                return(null);
            }
            if ((dsh.Ref(Info.L) - dsh.Ref(Info.L, 2)) / dsh.Ref(Info.C, 1) > 0.01)
            {
                return(null);
            }
            int nTotalDownDays = dsh.EveryDown(3);

            if (nTotalDownDays < 4)
            {
                return(null);
            }
            if (dsh.EveryUp(3 + nTotalDownDays) > nTotalDownDays)
            {
                return(null);
            }
            float totalZF = dsh.AccZF(nTotalDownDays, 3);

            if (totalZF > -0.1)
            {
                return(null);
            }
            var szZF = dsh.SZRef(Info.ZF);

            if (szZF > 0 && szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03)
            {
                return(null);
            }
            if (!selectBySZ(dsh))
            {
                return(null);
            }
            return(EmptyRateItemButSel);
        }
Esempio n. 22
0
        public String computeBonus(SelectItem item, Stock stock, int buyDate, out BuySellInfo info)
        {
            info = new BuySellInfo();
            if (item.buyNormlizePrice_ == 0)
            {
                return("");
            }
            IStrategy_LF_M  stra = (IStrategy_LF_M)this;
            DataStoreHelper dsh  = new DataStoreHelper();

            dsh.setStock(stock);
            dsh.iIndex_ = App.ds_.index(stock, buyDate);
            float buyC = item.buyNormlizePrice_;

            float firstDayBonusL = firstDayBonusLimit();
            float bonusL         = bonusLimit();
            float bL             = dsh.iIndex_ > 1 ? bonusL : firstDayBonusL;

            if (dsh.iIndex_ == 0)
            {
                var bonus = Utils.DeltaF(dsh.Ref(Info.C) - buyC, dsh.Ref(Info.C));
                info.sellDate_  = buyDate;
                info.tradeSpan_ = 0;
                info.allBonus_  = Utils.ToBonus(bonus - 0.002f);
                return(info.allBonus_);
            }
            else
            {
                --dsh.iIndex_;
                int   nBuySpan      = 0;
                int   nBuySpanLimit = buySpan();
                float sellC         = 0;
                for (; dsh.iIndex_ >= 0; --dsh.iIndex_, ++nBuySpan)
                {
                    float o = dsh.Ref(Info.O);
                    float h = dsh.Ref(Info.H);
                    float c = dsh.Ref(Info.C);

                    float of = dsh.Ref(Info.OF);
                    float hf = dsh.Ref(Info.HF);
                    float lf = dsh.Ref(Info.LF);
                    float zf = dsh.Ref(Info.ZF);

                    var   limit      = nBuySpan == 0 ? firstDayBonusL : bonusL;
                    float wantedC    = buyC * (1 + limit);
                    float wantedMinC = buyC * (1 + bonusL);
                    //
                    //                 if (lf < -0.111 || hf > 0.111)
                    //                 {//除权了
                    //                     return "";
                    //                 }
                    if (Utils.IsDownStop(hf))//一直跌停
                    {
                        info.bSellWhenMeetMyBounusLimit_ = false;
                        continue;
                    }
                    //今天没一直跌停,大概率能卖出
                    if (info.bSellWhenMeetMyBounusLimit_)
                    {
                        if (o > wantedC)//开盘超出盈利顶额
                        {
                            sellC = o;
                            ++nBuySpan;
                            break;
                        }
                        if (h > wantedC)//达到盈利顶额
                        {
                            sellC = wantedC;
                            ++nBuySpan;
                            break;
                        }
                        if (Utils.IsDownStop(zf))//尾盘跌停,卖不了
                        {
                            info.bSellWhenMeetMyBounusLimit_ = false;
                            continue;
                        }
                        sellC = c;
                        if (zf >= 0.01 || h >= wantedMinC || nBuySpan >= nBuySpanLimit - 1)
                        {
                            ++nBuySpan;
                            break;
                        }
                    }
                    else                           //逃命模式
                    {
                        if (!Utils.IsDownStop(of)) //开盘没跌停
                        {                          //跑了
                            sellC = o;
                            ++nBuySpan;
                            break;
                        }
                        //开盘跌停但因为没一直跌停,所以肯定可以以跌停价卖出
                        sellC = dsh.Ref(Info.C, 1) * (1 - 0.095f);
                        ++nBuySpan;
                        break;
                    }
                }
                if (dsh.iIndex_ == -1)
                {
                    return("");
                }

                info.sellDate_  = dsh.Date();
                info.tradeSpan_ = nBuySpan;
                var bonus = (sellC - buyC) / buyC;
                info.allBonus_ = Utils.ToBonus(bonus - 0.002f);
                return(info.allBonus_);
            }
        }
Esempio n. 23
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            IStrategy_LF_M stra       = (IStrategy_LF_M)this;
            int            nowMiniute = Utils.NowMinute();

            if (nowMiniute < 60)
            {
                return(null);
            }
            if (dsh.stock_.name_.ToUpper().IndexOf("ST") != -1)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, dsh.HH(Info.ZF, 10)) > 0.095)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, dsh.LL(Info.ZF, 10)) < -0.095)
            {
                return(null);
            }
            var hf = dsh.Ref(Info.HF);

            if (hf > 0.05 || hf < 0.01)
            {
                return(null);
            }
            if (dsh.Ref(Info.LF) < -0.06)
            {
                return(null);
            }

            var lastDayC = dsh.Ref(Info.C, 1);
            var gllc     = dsh.Ref(Info.L);
            var ghhc     = dsh.Ref(Info.H);
            var c        = dsh.Ref(Info.C);
            var o        = dsh.Ref(Info.O);

            if (c >= lastDayC)
            {
                return(null);
            }

            if (ghhc <= lastDayC)
            {
                return(null);
            }
            var rsh = dsh.newRuntimeDsh();

            var c5 = rsh.Ref(Info.C, 5);

            if ((c - c5) / lastDayC > -0.01)
            {
                return(null);
            }
            var c10 = rsh.Ref(Info.C, 10);

            if ((c - c10) / lastDayC > -0.015)
            {
                return(null);
            }
            var c15 = rsh.Ref(Info.C, 15);

            if ((c - c15) / lastDayC > -0.02)
            {
                return(null);
            }
            var c20 = rsh.Ref(Info.C, 20);

            if ((c - c20) / lastDayC < -0.025)
            {
                return(null);
            }
            var c25 = rsh.Ref(Info.C, 25);

            if ((c - c25) / lastDayC < -0.03)
            {
                return(null);
            }
            var c30 = rsh.Ref(Info.C, 30);

            if ((c - c30) / lastDayC > -0.035)
            {
                return(null);
            }

            return(EmptyRateItemButSel);
        }
Esempio n. 24
0
        public virtual Dictionary <String, String> selectFor(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0.095 || zf < -0.095)
            {
                return(null);
            }
            if (zf < 0.02)
            {
                return(null);
            }
            if (dsh.IsLikeSTStop())
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 2) < 0.03)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 1) > -0.01)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 3) > 0)
            {
                return(null);
            }
            if (dsh.AccZF(3) < 0.05)
            {
                return(null);
            }
            if (dsh.AccZF(3, 3) > 0)
            {
                return(null);
            }
            if (dsh.Ref(Info.V) > dsh.Ref(Info.V, 1) * 2)
            {
                return(null);
            }
            for (int i = 0; i < 4; ++i)
            {
                if (dsh.DownShadow(i) < -0.04)
                {
                    return(null);
                }
                if ((dsh.Ref(Info.CO, i) / dsh.Ref(Info.C, i + 1)) < 0.005)
                {
                    return(null);
                }
                if (dsh.Ref(Info.OF, i) > 0.02 && dsh.Ref(Info.ZF, i) < -0.02)
                {
                    return(null);
                }
            }
            var hhCO = dsh.HH(Info.CO, 8);

            if (dsh.Ref(Info.ZF, hhCO) > 0)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, dsh.LL(Info.ZF, 8)) < -0.095)
            {
                return(null);
            }
            if (dsh.HH(Info.V, 6) == 0)
            {
                return(null);
            }

            return(EmptyRateItemButSel);
        }
Esempio n. 25
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0.095 || zf < -0.095)
            {
                return(null);
            }
            if (zf < 0.01)
            {
                return(null);
            }
            if (dsh.IsLikeSTStop())
            {
                return(null);
            }
            var szZF = dsh.SZRef(Info.ZF);

            if (szZF < 0.01)
            {
                return(null);
            }
            if (szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03)
            {
                return(null);
            }
            var recentMaxSZZF = dsh.SZRef(Info.ZF, dsh.SZHH(Info.ZF, 10, 1));

            if (recentMaxSZZF < 0.005)
            {
                return(null);
            }
            var minSZZFIndex = dsh.SZLL(Info.ZF, 8, 1);

            if (dsh.SZRef(Info.ZF, minSZZFIndex) > -0.005)
            {
                return(null);
            }


            if (!dsh.IsReal())
            {
                return(null);
            }
            if (dsh.UpShadow() > 0.04)
            {
                return(null);
            }
            if (dsh.DownShadow() < -0.04)
            {
                return(null);
            }
            var of = dsh.Ref(Info.OF);

            if (of > 0.02 || of < -0.04)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 1) > -0.02 || dsh.Ref(Info.ZF, 1) < -0.095)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 2) < -0.02)
            {
                return(null);
            }
            if (zf + dsh.Ref(Info.ZF, 1) < 0)
            {
                return(null);
            }
            if (dsh.Ref(Info.V) > dsh.Ref(Info.V, 1) * 1.5)
            {
                return(null);
            }
            for (int i = 1; i < 8; ++i)
            {
                var curZF = dsh.Ref(Info.ZF, i);
                var curOf = dsh.Ref(Info.OF, i);
                if (curOf > 0.04 && curZF < 0)
                {
                    return(null);
                }
                if (curOf < -0.02 && curZF < 0)
                {
                    return(null);
                }
            }
            if (dsh.AccZF(8, 1) < -0.1)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, dsh.HH(Info.CO, 10)) > 0)
            {
                return(null);
            }
            int iMaxVolIndex = dsh.HH(Info.V, 10);

            if (dsh.Ref(Info.C, iMaxVolIndex) > dsh.Ref(Info.O, iMaxVolIndex))
            {
                return(null);
            }
            if ((dsh.Ref(Info.H, dsh.HH(Info.H, 8)) - dsh.Ref(Info.L, dsh.LL(Info.L, 8))) / dsh.Ref(Info.C, 1) > 0.2)
            {
                return(null);
            }
            return(EmptyRateItemButSel);
        }
Esempio n. 26
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0 || zf < -0.06)
            {
                return(null);
            }
            if (dsh.Ref(Info.OF, 1) < -0.03)
            {
                return(null);
            }
            if (dsh.Ref(Info.ZF, 1) > 0)
            {
                return(null);
            }

            int   iSigDateIndex        = -1;
            int   nUpCount             = 0;
            int   nUStopCount          = 0;
            int   nDStopCount          = 0;
            bool  bMeetRealUp          = false;
            bool  bHasUpShadowTooHight = false;
            bool  bHasDownShadowTooLow = false;
            float otherMaxVol          = float.MinValue;
            float otherMaxZF           = float.MinValue;
            float otherMaxC            = 0;
            float otherMaxH            = 0;
            float sigDateVol           = 0;
            float sigZF                 = 0;
            float minDownShadow         = float.MaxValue;
            float maxUpShadow           = float.MinValue;
            float totalUp               = 0;
            float totalDown             = 0;
            float otherMinZF            = float.MaxValue;
            float otherMaxCO            = float.MinValue;
            bool  bMeetTradeSigAllready = false;
            int   nNotRealCount         = 0;

            for (int i = 1; i < 8; ++i)
            {
                var curOf    = dsh.Ref(Info.OF, i);
                var curHf    = dsh.Ref(Info.HF, i);
                var curLf    = dsh.Ref(Info.LF, i);
                var curZf    = dsh.Ref(Info.ZF, i);
                var curPreZf = dsh.Ref(Info.ZF, i + 1);
                var vol      = dsh.Ref(Info.V, i);
                var coRate   = dsh.Ref(Info.CO, i) / dsh.Ref(Info.C, i + 1);
                if (curZf > 0 && curZf < 0.095 && coRate > 0.05 &&
                    vol > dsh.MA(Info.V, 5, i + 1) && dsh.HH(Info.CO, 30, i) == i)
                {
                    for (int j = i + 1; j < i + 6; ++j)
                    {
                        if (dsh.Ref(Info.V, j) > vol && dsh.Ref(Info.C, j) < dsh.Ref(Info.O, j))
                        {
                            return(null);
                        }
                    }
                    if (dsh.AccZF(8, i + 1) < -0.1)
                    {
                        return(null);
                    }
                    if (dsh.AccZF(3, i + 1) > 0.095)
                    {
                        return(null);
                    }
                    int iMaxVolIndex = dsh.HH(Info.V, 20, i);
                    if (dsh.Ref(Info.C, iMaxVolIndex) > dsh.Ref(Info.O, iMaxVolIndex))
                    {
                        iSigDateIndex = i;
                        sigDateVol    = vol;
                        sigZF         = curZf;
                        break;
                    }
                }
                if (curOf < -0.04)
                {
                    return(null);
                }
                if (curZf > 0 && dsh.IsReal(i))
                {
                    nUpCount++;
                }
                if (!dsh.IsReal(i))
                {
                    ++nNotRealCount;
                }
                if (curZf > 0.095)
                {
                    nUStopCount++;
                }
                else if (curZf < -0.095)
                {
                    nDStopCount++;
                }
                else if (curZf > 0.012)
                {
                    bMeetRealUp = true;
                }
                if (curZf < -0.03 && dsh.Ref(Info.ZF, i - 1) > 0)
                {
                    bMeetTradeSigAllready = true;
                }
                float upShadow   = dsh.UpShadow(i);
                float downShadow = dsh.DownShadow(i);
                if (upShadow > maxUpShadow)
                {
                    maxUpShadow = upShadow;
                }
                if (downShadow < minDownShadow)
                {
                    minDownShadow = downShadow;
                }
                if (curZf > 0)
                {
                    totalUp += curZf;
                }
                else
                {
                    totalDown += curZf;
                }
                otherMaxVol = Math.Max(vol, otherMaxVol);
                otherMaxZF  = Math.Max(otherMaxZF, curZf);
                otherMaxC   = Math.Max(dsh.Ref(Info.C, i), otherMaxC);
                otherMaxH   = Math.Max(dsh.Ref(Info.H, i), otherMaxH);
                otherMinZF  = Math.Min(otherMinZF, curZf);
                otherMaxCO  = Math.Max(otherMaxCO, dsh.Ref(Info.CO, i));
            }
            if (iSigDateIndex == -1)
            {
                return(null);
            }
            sigInfo = dsh.Date(iSigDateIndex).ToString();
            if (otherMinZF > 0.02)
            {
                return(null);
            }
            if (nNotRealCount > 1)
            {
                return(null);
            }
            if (totalDown + totalUp < -0.01)
            {
                return(null);
            }
            if (maxUpShadow > 0.03)
            {
                bHasUpShadowTooHight = true;
            }

            if (minDownShadow < -0.03)
            {
                bHasDownShadowTooLow = true;
            }
            if (nUpCount < 2)
            {
                return(null);
            }
            if (otherMaxH < dsh.Ref(Info.H, iSigDateIndex))
            {
                return(null);
            }

            if (/*nUStopCount > 0 ||*//* nDStopCount > 0 || */ bMeetTradeSigAllready || !bMeetRealUp)
            {
                return(null);
            }

            float maxUpF = (otherMaxC - dsh.Ref(Info.C, iSigDateIndex)) / dsh.Ref(Info.C, iSigDateIndex);

            if (maxUpF < 0.015 /* || maxUpF > 0.04*/)
            {
                return(null);
            }
            if (dsh.Ref(Info.C) < dsh.Ref(Info.L, iSigDateIndex))
            {
                return(null);
            }
            if (bHasUpShadowTooHight || bHasDownShadowTooLow)
            {
                return(null);
            }
            if (
                dsh.Ref(Info.ZF, 2) < 0.005 &&
                dsh.Ref(Info.ZF, 3) < 0.005)
            {
                return(null);
            }


            if (sigDateVol < otherMaxVol * 1.2)
            {
                return(null);
            }
            if (sigDateVol > otherMaxVol * 2)
            {
                return(null);
            }
            if (otherMaxZF + zf > 0)
            {
                return(null);
            }
            if (otherMaxZF + zf < -0.02)
            {
                return(null);
            }

            if (dsh.Ref(Info.LF) < -0.06)
            {
                return(null);
            }
            var delta = (dsh.Ref(Info.C) - dsh.Ref(Info.O, 1)) / dsh.Ref(Info.C, 1);

            if (delta > -0.01)
            {
                return(null);
            }

            if (!selectBySZ(dsh))
            {
                return(null);
            }
            var ret = new Dictionary <String, String>();

            ret[String.Format("delta/{0}", delta < -0.02 ? "1" : "0")] = "";
            ret[String.Format("maxUp/{0}", maxUpF > 0.02 ? "1" : "0")] = "";
            return(ret);
        }
Esempio n. 27
0
        Dictionary <String, String> IStrategy.select(DataStoreHelper dsh, SelectMode selectMode, ref String sigInfo)
        {
            var zf = dsh.Ref(Info.ZF);

            if (zf > 0 || zf < -0.095)
            {
                return(null);
            }
            if (!dsh.IsReal())
            {
                return(null);
            }
            if (dsh.Ref(Info.OF, 1) < -0.03)
            {
                return(null);
            }
            if (dsh.Ref(Info.LF) < -0.06)
            {
                return(null);
            }
            int   iSigDateIndex         = -1;
            int   nUpCount              = 0;
            int   nDownCount            = 0;
            int   nUStopCount           = 0;
            int   nDStopCount           = 0;
            bool  bMeetTradeSigAllready = false;
            bool  bMeetRealUp           = false;
            float sigDateVol            = 0;
            float otherMaxVol           = 0;
            bool  bHasUpShadowTooHight  = false;
            bool  bHasDownShadowTooLow  = false;
            float otherMaxZF            = 0;
            float otherMinZF            = float.MaxValue;
            float otherMaxC             = 0;
            float otherMaxH             = 0;
            float sumOfSigDateZF        = 0;
            float otherMaxDownV         = 0;
            float minSigV   = float.MaxValue;
            float totalUp   = 0;
            float totalDown = 0;

            for (int i = 1; i < 8; ++i)
            {
                var curOf    = dsh.Ref(Info.OF, i);
                var curHf    = dsh.Ref(Info.HF, i);
                var curZf    = dsh.Ref(Info.ZF, i);
                var curPreZf = dsh.Ref(Info.ZF, i + 1);
                var vol      = dsh.Ref(Info.V, i);
                var preVol   = dsh.Ref(Info.V, i + 1);
                if (dsh.Ref(Info.OF, i) > 0.03 && curZf < 0)
                {
                    return(null);
                }
                float ma5 = dsh.MA(Info.V, 10, i + 2);
                float hhv = dsh.Ref(Info.V, dsh.HH(Info.V, 5, i + 2));
                if (curZf > 0.01 && curPreZf > 0.01 && vol > 1.3 * hhv && preVol > 1.3 * hhv && (vol < vRate_ * preVol && preVol < vRate_ * vol) && vol / ma5 > vRate_ &&
                    preVol / ma5 > vRate_ && dsh.Ref(Info.ZF, i + 2) < 0.05 &&
                    dsh.Ref(Info.V, i + 2) / dsh.MA(Info.V, 5, i + 3) < vRate_)
                {
                    for (int j = i + 2; j < i + 7; j++)
                    {
                        if (dsh.Ref(Info.ZF, j) < -0.095)
                        {
                            return(null);
                        }
                    }
                    if (dsh.AccZF(2, i) < 0.05)
                    {
                        return(null);
                    }
                    {
                        iSigDateIndex = i;
                        sigDateVol    = Math.Max(dsh.Ref(Info.V, i + 1), vol);
                        minSigV       = Math.Min(dsh.Ref(Info.V, i + 1), vol);
                        break;
                    }
                }
                otherMaxVol = Math.Max(vol, otherMaxVol);
                if (curZf > 0.005 && dsh.IsReal(i))
                {
                    nUpCount++;
                }
                else if (curZf < -0.005 && dsh.IsReal(i))
                {
                    nDownCount++;
                }
                if (curZf > 0.095)
                {
                    nUStopCount++;
                }
                else if (curZf < -0.095)
                {
                    nDStopCount++;
                }

                if (curZf < -0.03)
                {
                    bMeetTradeSigAllready = true;
                }
                if (curZf > 0)
                {
                    totalUp += curZf;
                }
                else
                {
                    totalDown += curZf;
                }
                if (curZf > 0.012)
                {
                    bMeetRealUp = true;
                }

                if (dsh.UpShadow(i) > 0.03)
                {
                    bHasUpShadowTooHight = true;
                }

                if (dsh.DownShadow(i) < -0.03)
                {
                    bHasDownShadowTooLow = true;
                }
                otherMaxZF = Math.Max(otherMaxZF, curZf);
                otherMinZF = Math.Min(otherMinZF, curZf);
                otherMaxC  = Math.Max(dsh.Ref(Info.C, i), otherMaxC);
                otherMaxH  = Math.Max(dsh.Ref(Info.H, i), otherMaxH);
                if (curZf < 0)
                {
                    otherMaxDownV = Math.Max(otherMaxDownV, vol);
                }
            }
            if (iSigDateIndex == -1)
            {
                return(null);
            }
            //          sigInfo = dsh.Date(iSigDateIndex).ToString();
            if (totalDown + totalUp < -0.01)
            {
                return(null);
            }
            if (nUpCount < 2)
            {
                return(null);
            }
            if (/*nUStopCount > 0 ||*//* nDStopCount > 0 || */ bMeetTradeSigAllready || !bMeetRealUp)
            {
                return(null);
            }
            float maxUpF = (otherMaxC - dsh.Ref(Info.C, iSigDateIndex)) / dsh.Ref(Info.C, iSigDateIndex);

            if (maxUpF < 0.015 /* || maxUpF > 0.04*/)
            {
                return(null);
            }
            if (sigDateVol < otherMaxVol * 1.2)
            {
                return(null);
            }
            if (otherMaxZF + zf > 0)
            {
                return(null);
            }
            sigInfo = (otherMaxZF + zf).ToString("F4");

            if (otherMaxZF + zf < -0.02)
            {
                return(null);
            }

            if (bHasUpShadowTooHight || bHasDownShadowTooLow)
            {
                return(null);
            }
            if (
                dsh.Ref(Info.ZF, 2) < 0.005 &&
                dsh.Ref(Info.ZF, 3) < 0.005)
            {
                return(null);
            }

            if (dsh.Ref(Info.C, iSigDateIndex) < dsh.Ref(Info.O, iSigDateIndex))
            {
                return(null);
            }
            if (dsh.Ref(Info.C, iSigDateIndex + 1) < dsh.Ref(Info.O, iSigDateIndex + 1))
            {
                return(null);
            }
            if (Math.Min(dsh.Ref(Info.ZF, iSigDateIndex), dsh.Ref(Info.ZF, iSigDateIndex + 1)) + dsh.Ref(Info.ZF, iSigDateIndex + 2) < -0.01)
            {
                return(null);
            }


            var delta = (dsh.Ref(Info.C) - dsh.Ref(Info.O, 1)) / dsh.Ref(Info.C, 1);

            if (delta > -0.01)
            {
                return(null);
            }
            var szZF = dsh.SZRef(Info.ZF);

            if (szZF > 0 && szZF < 0.011 && dsh.SZAcc(Info.ZF, 7, 1) > 0.03)
            {
                return(null);
            }
            if (!selectBySZ(dsh))
            {
                return(null);
            }

            var ret = new Dictionary <String, String>();

            ret[String.Format("sumSig/{0}", sumOfSigDateZF > 0.12 ? "1" : "0")]   = "";
            ret[String.Format("delta/{0}", delta < -0.02 ? "1" : "0")]            = "";
            ret[String.Format("maxUp/{0}", maxUpF > 0.02 ? "1" : "0")]            = "";
            ret[String.Format("maxZF/{0}", otherMaxZF + zf > -0.01 ? "1" : "0")]  = "";
            ret[String.Format("diffzf/{0}", otherMaxZF + zf > -0.02 ? "1" : "0")] = "";
            return(ret);
        }