public virtual void Initialize() { // Get Positions List<Position> positions = null; if (strategy.WebTD != null) { positions = strategy.WebTD.GetPositionsWeb(); } else positions = strategy.GetPositions(); if (positions == null || positions.Count == 0) { strategy.WriteTDLog("RiskM 没有持仓,请确认!"); return; } // process positions int i = 1; foreach (Position pos in positions) { Monitor monitor = strategy.GetMonitor(string.Format("{0}.{1}", pos.exchange, pos.sec_id)); if (monitor != null) { RiskPosition riskPos = new RiskPosition(pos.available, pos.vwap); riskPos.VolumeAux = monitor.Target.Volume; riskPos.StopLossPrice = monitor.Target.StopLossPrice; riskPositions.Add(riskPos); monitor.SetPosition(riskPos); strategy.WriteTDLog(string.Format("({0}) {1}的可用持仓为({2})", i++, monitor.TargetTitle, riskPos.Volume)); } else { strategy.WriteTDLog(string.Format("{0}.{1}的持仓没有设置对应的监控器!", pos.exchange, pos.sec_id)); } } }
public virtual void SetPosition(RiskPosition pos) { riskPosition = pos; }