public StockOrderRequestModel(string account, string venue, string symbol, decimal price, int quantity, StockOrderDirection direction, StockOrderType type) { this.Account = account; this.Venue = venue; this.Symbol = symbol; this.Price = price; this.Quantity = quantity; this.Direction = direction; this.Type = type; }
/// <summary> /// Place a buy or sell order for a stock. /// </summary> /// <param name="account">Account to place the order for.</param> /// <param name="stock">Stock to place the order for.</param> /// <param name="price">Price to place the order at.</param> /// <param name="quantity">Amount to buy/sell.</param> /// <param name="direction">Whether to buy or sell.</param> /// <param name="type">Type of the order.</param> /// <returns></returns> public async Task<StockOrderModel> PlaceStockOrder(string account, string stock, decimal price, int quantity, StockOrderDirection direction, StockOrderType type) { if (!Regex.IsMatch(stock, "[a-zA-z]*")) { throw new ArgumentException("Invalid stock symbol specification", stock); } using (var client = this.GetHttpClient()) { var order = new StockOrderRequestModel(account, this.m_venue, stock, price, quantity, direction, type); var content = SerializeObjectWithEnums(order); var response = await client.PostAsync(String.Format("venues/{0}/stocks/{1}/orders", this.m_venue, stock), content).ConfigureAwait(false); return await StockExchangeUtility.GetResponseOrErrorModel<StockOrderModel>(response).ConfigureAwait(false); } }