public List <SubmitPriceSetting> LoadStrategies() { string lines = FileUtils.ReadTxtFile(StrategyPath); List <SubmitPriceSetting> settings = new List <SubmitPriceSetting>(); string[] lis = lines.Split('\n'); foreach (string li in lis) { logger.InfoFormat("load submit setting {0}", li); if (li == null || li.Trim().StartsWith("#")) { continue; } var sps = SubmitPriceSetting.fromLine(li.Trim()); if (sps != null) { settings.Add(sps); } } LoadedTime = DateTime.Now; return(settings); }
public BiddingPriceRequest CheckPriceOffer(PagePrice pp, SubmitPriceSetting strategy, bool needCheckSecond = true) { if (needCheckSecond && pp.pageTime.Second != strategy.second) { return(null); } logger.InfoFormat("CheckPriceOffer sec#{0}, strategy is {1} ", strategy.second, strategy); BiddingPriceRequest req = new BiddingPriceRequest(); req.OperateStatus = StrategyOperateStatus.NEED_OFFER_PRICE; req.OfferedScreenTime = pp.pageTime; req.OfferedScreenPrice = pp.basePrice; req.ComputedDelayMills = 0; req.StrategySecond = strategy.second; req.TargetPrice = strategy.deltaPrice + pp.basePrice; req.CaptchaUuid = ""; req.IsRangeTriggered = strategy.IsRange; return(req); }
public BiddingPriceRequest Calc(PagePrice pp, SubmitPriceSetting strategy) { if (pp.pageTime.Second < strategy.second) { return(null); } // 检查是否 为 区间决策 且 未执行过检查 if (strategy.IsRange && !strategy.IsRangeChecked) { /* * 参考设置为50,700-1000,1200 * 意思表示在时间点11:29:50判断当前的出价, * 如果当前没有任何出价,或者当前的出价<最低成交价+700,或者当前的出价>最低成交价+1000,则取消当前出价,重新出该时间点的最低成交价+1200。 * */ var reqs = GetPreviousUnSubmitRequest(pp.pageTime.Second); var last = reqs != null && reqs.Count > 0 ? reqs.Last() : null; var currentOfferPrice = last != null ? last.TargetPrice : 0; strategy.IsRangeChecked = true; // 如果有前一个出价,且在区间内,则不操作 if (last != null && currentOfferPrice >= pp.basePrice + strategy.RangeStartDelta && currentOfferPrice <= pp.basePrice + strategy.RangeEndDelta) { logger.InfoFormat("strategy#{0} is matched, currentOfferPrice#{1}, base#{2}, start#{3}, end#{4}", strategy.second, currentOfferPrice, pp.basePrice, strategy.RangeStartDelta, strategy.RangeEndDelta); BiddingPriceRequest reqx = new BiddingPriceRequest(); reqx.OperateStatus = StrategyOperateStatus.STRATEGY_RANGE_MATCHED; return(reqx); } logger.InfoFormat("strategy#{0} is not matched, currentOfferPrice#{1}, base#{2}, start#{3}, end#{4}", strategy.second, currentOfferPrice, pp.basePrice, strategy.RangeStartDelta, strategy.RangeEndDelta); // 剩下的 区间策略 和 一般策略 无任何不同 } BiddingPriceRequest req = null; strategySecondRequests.TryGetValue(strategy.second, out req); if (req == null) { req = CheckPriceOffer(pp, strategy); strategySecondRequests[strategy.second] = req; } if (req == null) { return(null); } if (req.OperateStatus == StrategyOperateStatus.PRICE_SUBMITTED || req.OperateStatus == StrategyOperateStatus.CANCELLED) { logger.WarnFormat("strategy#{0} status#{1} still try calc", strategy.second, req.OperateStatus); return(null); } // 检测 策略的出价是否符合提交规则 if (UsePriceMatchRule(pp, req) || UseBack2PriceRule(pp, req) || UseBack3PriceRule(pp, req) || UseFinalRule(pp, req) ) { return(req); } return(req); }