Example #1
0
 /// <summary>
 /// Factory Constructor for limit order
 /// </summary>
 /// <param name="orderId"> </param>
 /// <param name="pair"></param>
 /// <param name="price"></param>
 /// <param name="orderSide"></param>
 /// <param name="orderType"></param>
 /// <param name="volume"></param>
 /// <param name="traderId"></param>
 public Order(OrderId orderId, string pair, Price price, OrderSide orderSide, OrderType orderType, Volume volume,
              TraderId traderId)
 {
     OrderId      = orderId;
     CurrencyPair = pair;
     if (orderType == OrderType.Limit)
     {
         AssertionConcern.AssertGreaterThanZero(price.Value, "Limit order price must be greater than 0");
     }
     Price          = price;
     OrderSide      = orderSide;
     OrderType      = orderType;
     Volume         = volume;
     TraderId       = traderId;
     this.DateTime  = DateTime.Now;
     FilledQuantity = new Volume(0);
     _filledCost    = new Price(0);
     OpenQuantity   = Volume;
 }
Example #2
0
        public static Order CreateOrder(string traderId, string currencyPair, string type, string side, decimal volume, decimal limitPrice, IOrderIdGenerator orderIdGenerator)
        {
            Order    order       = null;
            TraderId id          = new TraderId(traderId);
            OrderId  orderId     = orderIdGenerator.GenerateOrderId();
            Volume   orderVolume = new Volume(volume);

            if (side.Equals(Constants.ORDER_SIDE_BUY, StringComparison.CurrentCultureIgnoreCase) &&
                type.Equals(Constants.ORDER_TYPE_MARKET, StringComparison.CurrentCultureIgnoreCase))
            {
                Price price = new Price(0);
                order = BuyMarketOrder(orderId, currencyPair, OrderType.Market, orderVolume, price, id);
            }
            else if (side.Equals(Constants.ORDER_SIDE_SELL, StringComparison.CurrentCultureIgnoreCase) &&
                     type.Equals(Constants.ORDER_TYPE_MARKET, StringComparison.CurrentCultureIgnoreCase))
            {
                Price price = new Price(0);
                order = SellMarketOrder(orderId, currencyPair, OrderType.Market, orderVolume, price, id);
            }
            else if (side.Equals(Constants.ORDER_SIDE_BUY, StringComparison.CurrentCultureIgnoreCase) &&
                     type.Equals(Constants.ORDER_TYPE_LIMIT, StringComparison.CurrentCultureIgnoreCase))
            {
                Price price = new Price(limitPrice);
                order = BuyLimitOrder(orderId, currencyPair, price, OrderType.Limit, orderVolume, id);
            }
            else if (side.Equals(Constants.ORDER_SIDE_SELL, StringComparison.CurrentCultureIgnoreCase) &&
                     type.Equals(Constants.ORDER_TYPE_LIMIT, StringComparison.CurrentCultureIgnoreCase))
            {
                Price price = new Price(limitPrice);
                order = SellLimitOrder(orderId, currencyPair, price, OrderType.Limit, orderVolume, id);
            }

            //TODO:Validation of funds and other things

            return(order);
        }
Example #3
0
 private static Order SellLimitOrder(OrderId orderId, string pair, Price limitPrice, OrderType orderType, Volume volume, TraderId traderId)
 {
     return(new Order(orderId, pair, limitPrice, OrderSide.Sell, orderType, volume, traderId));
 }
Example #4
0
 private static Order SellMarketOrder(OrderId orderId, string pair, OrderType orderType, Volume volume, Price price, TraderId traderId)
 {
     return(new Order(orderId, pair, price, OrderSide.Sell, orderType, volume, traderId));
 }
 public OrderCancellation(OrderId orderId, TraderId traderId, string currencyPair)
 {
     OrderId      = orderId;
     TraderId     = traderId;
     CurrencyPair = currencyPair;
 }