Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="user"></param>
        /// <param name="symbol"></param>
        /// <param name="type"></param>
        /// <param name="side"></param>
        /// <param name="price"></param>
        /// <param name="quantity"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static async Task <string> PlaceAsync(this ICryptocoreHttpClient client, ICryptocoreApiUser user,
                                                     Symbol symbol, OrderType type, OrderSide side, decimal price, decimal quantity,
                                                     CancellationToken token = default)
        {
            Throw.IfNull(client, nameof(client));
            Throw.IfNull(user, nameof(user));
            Throw.IfNull(symbol, nameof(symbol));

            var request = new CryptocoreHttpRequest($"/v1/orders/{symbol.Exchange}/{symbol}")
            {
                ApiKey = user.ApiKey
            };

            request.AddParameter("type", type.ConvertToString());
            request.AddParameter("side", side.ConvertToString());
            request.AddParameter("price", price);
            request.AddParameter("quantity", quantity);

            return(await client.PostAsync(request, token)
                   .ConfigureAwait(false));
        }