public void setStock(Stock stock) { stock_ = stock; dataList_ = stock_.dataList_; runtimeDataList_ = stock.runtimeDataList_; }
public String computeBonus(SelectItem item, Stock stock, int buyDate, out BuySellInfo info) { IStrategy_LF stra = (IStrategy_LF)this; float firstDayBonusL = firstDayBonusLimit(); float bonusL = bonusLimit(); float buyLimit = stra.buyLimit(); DataStoreHelper dsh = new DataStoreHelper(); dsh.setStock(stock); dsh.iIndex_ = App.ds_.index(stock, buyDate); float buyC = dsh.Ref(Info.C, 1) * (1 + buyLimit); --dsh.iIndex_; info = new BuySellInfo(); if (dsh.iIndex_ == -1) { return("");// 还未遇到交易日,不知道盈亏 } 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; float bonus = (sellC - buyC) / buyC; info.allBonus_ = Utils.ToBonus(bonus - 0.002f); return(info.allBonus_); }
public int index(Stock stock, int date, int iDateIndexHint = -1) { return(index(stock.dataList_, date, iDateIndexHint)); }