public static void PrintPositionStatus(StrategyEx se, Order[] orders = null, bool checkStatusIfPositionNotEmpty = false) { PositionSeries ps = se.GetPosition(se.TriggerFuture.Market, se.DefaultAccount); se.Print("打印当前仓位信息:"); if (ps == null || ps.Count == 0) { se.Print("空仓"); return; } foreach (Position pos in ps) { se.Print(pos.ToString()); if (pos.TodayPosition != 0 && orders != null && checkStatusIfPositionNotEmpty) { se.Print("警告:当前仓位不为空!!!!"); foreach (Order order in orders) { if (order.InstrumentID.Equals(pos.InstrumentID)) { OrderHelper.PrintOrderStatus(se, order); se.Print("最新tick数据:" + se.LastFutureTick(order.InstrumentID).ToString()); break; } } } } }
/// <summary> /// 建構子 /// </summary> public SimulateOrderService() { __cReserves = new Queue<string>(16); __cDeals = new Queue<TradeOrder>(16); __cEntrusts = new TradeList<TradeOrder>(64); __cNextBarRequires = new HashSet<string>(); __cPNextBarRequires = new HashSet<string>(); __cCurrentPosition = new MarketPosition(16); //建立目前留倉部位 __cPositions = new PositionSeries(); //建立留倉部位陣列 __cPositions.Value = __cCurrentPosition; }
private bool isProfitCoverCost() { if (_orderStatusTracerA.Order == null || _orderStatusTracerB.Order == null) { return(true); } double totalProfit = 0; PositionSeries ps = GetPosition(EnumMarket.期货, DefaultAccount); foreach (Position position in ps) { totalProfit += position.PositionProfit; } return(totalProfit > 0); }
/// <summary> /// 建構子 /// </summary> public RealOrderService() { this.ApiNumber = 1; //預設通道編號 this.PipeNumber = 1; //預設通道編號 __cDeals = new Queue<TradeOrder>(16); __cReserves = new Queue<string>(16); __cEntrusts = new TradeList<TradeOrder>(64); __cNextBarRequires = new HashSet<string>(); __cPNextBarRequires = new HashSet<string>(); __cCurrentPosition = new MarketPosition(16); //建立目前留倉部位 __cPositions = new PositionSeries(); //建立留倉部位陣列 __cPositions.Value = __cCurrentPosition; __cResetEvent = new AutoResetEvent(false); }