コード例 #1
0
ファイル: RequestClass.cs プロジェクト: samuelyi/PK10Tracer
        public string getUserInsts(GlobalClass setting, DataTypePoint dtp, string NewExpectNo, string forweb, Func <string, string, int, SelectTimeInstClass> getRemoteCnt)
        {
            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      strAssetId = cc.AssetId;
                int         AssetCnt   = 0;

                string strccNewInst = "";
                if (cc.ChanceCode.Trim().Length == 0)
                {
                    continue;
                }
                if (cc.UnitCost == 0)
                {
                    continue;
                }
                string strCurrExpect = cc.ExpectCode;
                int    calcHoldTimes = (int)DataReader.getInterExpectCnt(strCurrExpect, NewExpectNo, dtp);
                if (cc.HoldTimeCnt + 1 < calcHoldTimes)
                {
                    continue;
                }
                if (!cc.Tracerable)        //只要是非跟踪策略
                {
                    if (calcHoldTimes > 1) //和要下注的期数大于1就过滤,因为不要跟踪,只有当期才要下注
                    {
                        continue;
                    }
                }
                if (setting.AssetUnits.ContainsKey(strAssetId))
                {
                    AssetInfoConfig aic = setting.AssetUnits[strAssetId];
                    if (aic == null)
                    {
                        continue;
                    }
                    AssetCnt = aic.value;
                    if (aic.NeedSelectTimes == 1)
                    {
                        int newVal = 0;
                        if (SelectTimeDic == null)
                        {
                            SelectTimeDic = new Dictionary <string, int>();
                        }
                        if (SelectTimeDic.ContainsKey(cc.GUID))
                        {
                            newVal = SelectTimeDic[cc.GUID];
                        }
                        else
                        {
                            SelectTimeInstClass obj = getSelectTimeAmt(dtp, cc.ExpectCode, AssetCnt, getRemoteCnt);
                            if (obj == null)
                            {
                                continue;
                            }
                            newVal = obj.RetCnt;
                            SelectTimeChanged?.Invoke(strAssetId, AssetCnt, obj);
                            AssetCnt = obj.RetCnt;
                            setting.AssetUnits[strAssetId].value = newVal;
                            SelectTimeDic.Add(cc.GUID, newVal);
                        }
                        AssetCnt = newVal;
                    }
                }
                //修改为自动计算出来的结果
                //Int64 Amt = cc.UnitCost*setting.SerTotal(cc.ChipCount);
                int chips  = cc.ChipCount - 1;
                int maxcnt = 1;
                if (amts.MaxHoldCnts.Length < chips)//只支持小注数策略,大注数全部使用1
                {
                    maxcnt = amts.MaxHoldCnts[chips];
                }
                int bShift = 0;
                if (cc.HoldTimeCnt > maxcnt)
                {
                    bShift = (int)maxcnt * 2 / 3;
                }
                int   RCnt = (cc.HoldTimeCnt % (maxcnt + 1)) + bShift - 1;
                Int64 Amt  = 1;
                if (amts.MaxHoldCnts.Length < chips)
                {
                    Amt = amts.Serials[chips][RCnt] * AssetCnt;
                }
                if (cc.ChanceType != 2)     //非对冲
                {
                    if (cc.ChanceType == 1) //一次性下注
                    {
                        Amt = cc.UnitCost * setting.SerTotal(1) * AssetCnt;
                    }
                    strccNewInst = string.Format("{0}/{1}", cc.ChanceCode.Replace("+", string.Format("/{0}+", Amt)), Amt);
                }
                else
                {
                    if (!setting.JoinHedge)//不参与对冲
                    {
                        continue;
                    }
                    Amt = cc.UnitCost * setting.HedgeTimes * AssetCnt;//对冲倍数
                    if (setting.AllowHedge)
                    {
                        Int64 BaseAmt = cc.BaseCost * setting.HedgeTimes * AssetCnt;
                        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);
            }
            GlobalClass.SetConfig(forweb);
            return(string.Join(" ", allTxt.ToArray()).Trim());
        }
コード例 #2
0
ファイル: RequestClass.cs プロジェクト: samuelyi/PK10Tracer
        public SelectTimeInstClass getSelectTimeAmt(DataTypePoint dtp, string expectNo, int currCnt, Func <string, string, int, SelectTimeInstClass> getRemoteCnt)
        {
            SelectTimeInstClass ret = getRemoteCnt(dtp.DataType, expectNo, currCnt);

            return(ret);
        }