Ejemplo n.º 1
0
 internal MarketOrder(
     String symbol,
     OrderQuantity quantity,
     OrderSide side)
     : base(
         symbol, quantity.Value.AsInteger(), side,
         OrderType.Market) =>
 public static JsonNewOrder WithQuantity(
     this JsonNewOrder order,
     OrderQuantity quantity)
 {
     order.Quantity = quantity.AsFractional();
     order.Notional = quantity.AsNotional();
     return(order);
 }
Ejemplo n.º 3
0
 internal TrailingStopOrder(
     String symbol,
     OrderQuantity quantity,
     OrderSide side,
     TrailOffset trailOffset)
     : base(
         symbol, quantity, side,
         OrderType.TrailingStop) =>
Ejemplo n.º 4
0
 internal LimitOrder(
     String symbol,
     OrderQuantity quantity,
     OrderSide side,
     Decimal limitPrice)
     : base(
         symbol, quantity, side,
         OrderType.Limit) =>
Ejemplo n.º 5
0
 internal MarketOrder(
     String symbol,
     OrderQuantity quantity,
     OrderSide side)
     : base(
         symbol, quantity, side,
         OrderType.Market)
 {
 }
Ejemplo n.º 6
0
 internal StopOrder(
     String symbol,
     OrderQuantity quantity,
     OrderSide side,
     Decimal stopPrice
     )
     : base(
         symbol, quantity, side,
         OrderType.Stop) =>
Ejemplo n.º 7
0
        public static OrderQuantity GetOrderQuantity(
            this IOrder order)
        {
            var notNullOrder = order.EnsureNotNull(nameof(order));

            return(notNullOrder.Quantity.HasValue
                ? OrderQuantity.Fractional(notNullOrder.Quantity.Value)
                : notNullOrder.Notional.HasValue
                    ? OrderQuantity.Notional(notNullOrder.Notional.Value)
                    : throw new InvalidOperationException());
        }
 /// <summary>
 /// Creates new instance of the <see cref="SimpleOrderBase"/> class.
 /// </summary>
 /// <param name="symbol">Alpaca symbol for order.</param>
 /// <param name="quantity">Order quantity (absolute value).</param>
 /// <param name="side">Order side (buy or sell).</param>
 /// <param name="type">Order type (market, limit, stop, stop-limit).</param>
 protected internal SimpleOrderBase(
     String symbol,
     OrderQuantity quantity,
     OrderSide side,
     OrderType type)
     : base(
         symbol,
         quantity,
         side,
         type)
 {
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates new instance of the <see cref="OrderBase"/> class.
 /// </summary>
 /// <param name="symbol">Alpaca symbol for order.</param>
 /// <param name="quantity">Order quantity (absolute value).</param>
 /// <param name="side">Order side (buy or sell).</param>
 /// <param name="type">Order type (market, limit, stop, stop-limit).</param>
 protected internal OrderBase(
     String symbol,
     OrderQuantity quantity,
     OrderSide side,
     OrderType type)
 {
     Symbol = symbol ?? throw new ArgumentException(
                        "Symbol name cannot be null.", nameof(symbol));
     Quantity = quantity;
     Side     = side;
     Type     = type;
 }
Ejemplo n.º 10
0
 internal StopLimitOrder(
     String symbol,
     OrderQuantity quantity,
     OrderSide side,
     Decimal stopPrice,
     Decimal limitPrice)
     : base(
         symbol, quantity, side,
         OrderType.StopLimit)
 {
     StopPrice  = stopPrice;
     LimitPrice = limitPrice;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates new instance of <see cref="NewOrderRequest"/> object.
 /// </summary>
 /// <param name="symbol">Order asset name.</param>
 /// <param name="quantity">Order quantity.</param>
 /// <param name="side">Order side (buy or sell).</param>
 /// <param name="type">Order type.</param>
 /// <param name="duration">Order duration.</param>
 public NewOrderRequest(
     String symbol,
     OrderQuantity quantity,
     OrderSide side,
     OrderType type,
     TimeInForce duration)
 {
     Symbol = symbol ?? throw new ArgumentException(
                        "Symbol name cannot be null.", nameof(symbol));
     Quantity = quantity;
     Side     = side;
     Type     = type;
     Duration = duration;
 }
Ejemplo n.º 12
0
 public static MarketOrder Buy(
     String symbol,
     OrderQuantity quantity) =>
 public static MarketOrder Market(
     this OrderSide orderSide,
     String symbol,
     OrderQuantity quantity) =>
Ejemplo n.º 14
0
 public static StopLimitOrder Sell(
     String symbol,
     OrderQuantity quantity,
     Decimal stopPrice,
     Decimal limitPrice) =>