示例#1
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);
        }