Ejemplo n.º 1
0
        public string getUserInsts(GlobalClass setting)
        {
            string        ret    = "";
            List <string> allTxt = new List <string>();
            AmoutSerials  amts   = setting.DefaultHoldAmtSerials;

            for (int i = 0; i < this.Count; i++)
            {
                ChanceClass cc           = this[i];
                string      strccNewInst = "";
                if (cc.ChanceCode.Trim().Length == 0)
                {
                    continue;
                }
                if (cc.UnitCost == 0)
                {
                    continue;
                }
                //修改为自动计算出来的结果
                //Int64 Amt = cc.UnitCost*setting.SerTotal(cc.ChipCount);
                int chips  = cc.ChipCount - 1;
                int maxcnt = amts.MaxHoldCnts[chips];
                int bShift = 0;
                if (cc.HoldTimeCnt > maxcnt)
                {
                    bShift = (int)maxcnt * 2 / 3;
                }
                int   RCnt = (cc.HoldTimeCnt % (maxcnt + 1)) + bShift;
                Int64 Amt  = amts.Serials[cc.ChipCount - 1][RCnt];
                if (cc.ChanceType != 2)     //非对冲
                {
                    if (cc.ChanceType == 1) //一次性下注
                    {
                        Amt = cc.UnitCost * setting.SerTotal(1);
                    }
                    strccNewInst = string.Format("{0}/{1}", cc.ChanceCode.Replace("+", string.Format("/{0}+", Amt)), Amt);
                }
                else
                {
                    if (!setting.JoinHedge)//不参与对冲
                    {
                        continue;
                    }
                    Amt = cc.UnitCost * setting.HedgeTimes;//对冲倍数
                    if (setting.AllowHedge)
                    {
                        Int64 BaseAmt = cc.BaseCost * setting.HedgeTimes;
                        strccNewInst = string.Format("{0}/{1}+{2}/{3}", cc.ChanceCode, Amt + BaseAmt, ChanceClass.getRevChance(cc.ChanceCode), BaseAmt);
                    }
                    else
                    {
                        strccNewInst = string.Format("{0}/{1}", cc.ChanceCode, Amt);
                    }
                }
                allTxt.Add(strccNewInst);
            }
            return(string.Join(" ", allTxt.ToArray()).Trim());
        }
Ejemplo n.º 2
0
        public override long getChipAmount(double RestCash, ChanceClass cc, AmoutSerials amts)
        {
            try
            {
                //////if (amts.Serials[cc.ChipCount - 1].Length == 0)
                //////{
                //////    Log("获取单码金额", "队列长度为0");
                //////}
                //////else
                //////{
                //////    Log(string.Format("获取到{0}码金额:{1}",cc.ChipCount,cc.HoldTimeCnt),string.Join(",",amts.Serials[cc.ChipCount-1]));
                //////}


                if (cc.IncrementType == InterestType.CompoundInterest)
                {
                    double rate = KellyMethodClass.KellyFormula(cc.ChipCount, 10, 9.75, 1.01);
                    long   ret  = (long)Math.Floor((double)(RestCash * rate));
                    return(ret);
                }
                int chips  = cc.ChipCount - 1;
                int maxcnt = amts.MaxHoldCnts[chips];
                int bShift = 0;
                if (cc.HoldTimeCnt > maxcnt)
                {
                    Log("风险", "达到最大上限", string.Format("机会{0}持有次数达到{1}次总投入金额已为{2}", cc.ChanceCode, cc.HoldTimeCnt, Cost));
                    bShift = (int)maxcnt * 2 / 3;
                }
                int RCnt = (cc.HoldTimeCnt % (maxcnt + 1)) + bShift - 1;
                return(amts.Serials[chips][RCnt]);
            }
            catch (Exception e)
            {
                Log("错误", "获取单码金额错误", e.Message);
            }
            return(1);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 计算最优投注金额数组
        /// </summary>
        /// <param name="odds">赔率</param>
        /// <param name="MaxValue">最大投入</param>
        /// <returns></returns>
        public static AmoutSerials getOptSerials(double odds, Int64 MaxValue, int FirstAmt, bool NeedAddFirst)
        {
            string model = "key_{0}_{1}_{2}";
            string key   = string.Format(model, odds, MaxValue, FirstAmt);

            if (AllSerialSettings == null)
            {
                AllSerialSettings = new Dictionary <string, AmoutSerials>();
            }
            if (AllSerialSettings.ContainsKey(key))
            {
                return(AllSerialSettings[key]);
            }
            AmoutSerials retval = new AmoutSerials();

            if (double.IsNaN(odds) || MaxValue == 0)
            {
                return(retval);
            }
            int[]     ret     = new int[8];
            double[]  Rates   = new double[8];
            Int64[]   MaxSum  = new Int64[8];
            Int64[][] Serials = new Int64[8][];
            //int MaxValue = 20000;
            //double odds = 9.75;
            for (int i = 0; i < ret.Length; i++)
            {
                Int64[] Ser      = new Int64[0];
                int     MaxCnts  = 1;
                double  bRate    = 0.0005;
                double  stepRate = 0.001;
                Int64   CurrSum  = getSum(i + 1, MaxCnts, FirstAmt, odds, 0, out Ser);
                while (CurrSum < MaxValue)//计算出在指定资金范围内保本所能达到的次数
                {
                    MaxCnts++;
                    CurrSum = getSum(i + 1, MaxCnts, 1, odds, 0, out Ser);
                }
                MaxCnts--;              //回退1
                long TestSum = getSum(i + 1, MaxCnts, FirstAmt, odds, bRate, out Ser);
                if (TestSum > MaxValue) //如果最少盈利下所需资金大于指定值,所能达到的次数减一
                {
                    bRate    = 0;
                    stepRate = 0.0001;
                    CurrSum  = getSum(i + 1, MaxCnts, FirstAmt, odds, bRate, out Ser);
                }
                else
                {
                    CurrSum = TestSum;
                }
                Int64 LastSum = CurrSum;
                while (CurrSum < MaxValue)
                {
                    LastSum = CurrSum;
                    bRate  += stepRate;
                    CurrSum = getSum(i + 1, MaxCnts, FirstAmt, odds, bRate, out Ser);
                }
                if (NeedAddFirst)
                {
                    List <long> list = Ser.ToList();
                    ret[i] = MaxCnts + 1;
                    list.Insert(0, FirstAmt);
                    Rates[i]   = bRate - stepRate;
                    MaxSum[i]  = LastSum + FirstAmt;
                    Serials[i] = list.ToArray();
                }
                else
                {
                    ret[i]     = MaxCnts;
                    Rates[i]   = bRate - stepRate;
                    MaxSum[i]  = LastSum;
                    Serials[i] = Ser;
                }
            }
            retval.MaxHoldCnts = ret;
            retval.MaxRates    = Rates;
            retval.Serials     = Serials;
            if (!AllSerialSettings.ContainsKey(key))//防止计算过程中有其他设置请求了
            {
                AllSerialSettings.Add(key, retval);
            }
            return(retval);
        }
Ejemplo n.º 4
0
 long ISpecAmount.getChipAmount(double RestCash, ChanceClass cc, AmoutSerials amts)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public abstract long getChipAmount(double RestCash, ChanceClass cc, AmoutSerials amts);