public ClosePositionCommand(Position position) { if (position == null) throw new ArgumentNullException("position"); Position = position; }
public RevertPositionCommand(Position position) { if (position == null) throw new ArgumentNullException(nameof(position)); Position = position; }
/// <summary> /// To copy fields of the current position to <paramref name="destination" />. /// </summary> /// <param name="destination">The position in which you should to copy fields.</param> public void CopyTo(Position destination) { base.CopyTo(destination); destination.Portfolio = Portfolio; destination.Security = Security; destination.DepoName = DepoName; destination.LimitType = LimitType; }
public PositionCommand(DateTimeOffset time, Position position, bool isNew) { if (position == null) throw new ArgumentNullException("position" + ""); Time = time; Position = position; IsNew = isNew; }
private void ClosePosition(Position position, decimal volume) { var side = position.CurrentValue > 0 ? Sides.Sell : Sides.Buy; var security = position.Security; var order = new Order { Security = security, Portfolio = position.Portfolio, Direction = side, Volume = volume, Type = position.Portfolio.Board.IsSupportMarketOrders ? OrderTypes.Market : OrderTypes.Limit, }; if (order.Type == OrderTypes.Limit) order.Price = security.GetMarketPrice(SafeGetConnector(), side) ?? 0; RegisterOrder(order); }
private void OnStrategyNewPosition(Position position) { PositionGrid.Positions.Add(position); }
private void RaisePositionChanged(Position position) { PositionChanged.SafeInvoke(position); var multiEvt = PositionsChanged; if (multiEvt == null) return; multiEvt.SafeInvoke(new[] { position }); }
private void RaiseNewPosition(Position position) { NewPosition.SafeInvoke(position); var multiEvt = NewPositions; if (multiEvt == null) return; multiEvt.SafeInvoke(new[] { position }); }
/// <summary> /// Create a copy of <see cref="Position"/>. /// </summary> /// <returns>Copy.</returns> public Position Clone() { var clone = new Position(); CopyTo(clone); return clone; }
private void ClosePosition(Position position, decimal vol) { if(position.CurrentValue == 0) return; var side = position.CurrentValue > 0 ? Sides.Sell : Sides.Buy; var security = position.Security; var supportMarket = position.Portfolio.Board?.IsSupportMarketOrders ?? false; var order = new Order { Security = security, Portfolio = position.Portfolio, Direction = side, Volume = vol, Type = supportMarket ? OrderTypes.Market : OrderTypes.Limit, }; if (order.Type == OrderTypes.Limit) { order.Price = security.GetMarketPrice(_connector, side) ?? 0; if (order.Price == 0) { OnErrorEvent("Unable to determine market price!", "Error"); return; } } _connector.RegisterOrder(order); }
// возвращает строку позиции private static string PositionToString(Position position) { return "{0};{1};{2};{3}".Put( position.Security.Id, position.Portfolio.Name, position.CurrentValue, position.AveragePrice); }