Esempio n. 1
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. 2
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. 3
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. 4
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. 5
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. 6
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. 7
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. 8
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. 9
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);
        }