Пример #1
0
        private AddOrderJsonBody BuildAddOrderJsonBody(OrderType orderType, decimal price, decimal amount)
        {
            AddOrderJsonBody returnBody = new AddOrderJsonBody();

            returnBody.amount     = amount.ToString(CultureInfo.InvariantCulture);
            returnBody.price      = price.ToString(CultureInfo.InvariantCulture);
            returnBody.currency   = "XBT";
            returnBody.instrument = _btcFiatPairSymbol;
            returnBody.side       = orderType.ToString();
            returnBody.type       = "limit";

            return(returnBody);
        }
Пример #2
0
        /// <summary>
        /// With ItBit, buying and selling is the same Api call. So both SellInternal and BuyInternal point to this.
        /// </summary>
        /// <param name="amount">Amount of btc to be bought/sold.</param>
        /// <param name="price">Price to set for the order.</param>
        /// <param name="orderType">Can be either be "buy" or "sell".</param>
        /// <returns>String representation of the executed order.</returns>
        private string ExecuteOrder(decimal amount, decimal price, OrderType orderType)
        {
            //Need to round amount to 4 decimal places, as that is all ItBit accepts
            amount = Math.Round(amount, 4);

            AddOrderJsonBody requestBody = BuildAddOrderJsonBody(orderType, price, amount);

            ItBitRequest request = new ItBitRequest(BaseUrl, _addOrderPath, _apiInfo.Key, _apiInfo.Secret, requestBody);

            request.AddSignatureHeader();

            Dictionary <string, dynamic> response = ApiPost(request);

            //Pull the order Id from the response and return it
            return((string)GetValueFromResponseResult(response, "id"));
        }
Пример #3
0
        private string ExecuteOrder(decimal amount, decimal price, OrderType orderType)
        {
            AddOrderJsonBody requestBody = new AddOrderJsonBody()
            {
                product_id = _btcFiatPairSymbol,
                side       = orderType.ToString().ToLower(),
                price      = price.ToString(),
                size       = amount.ToString(),
                type       = "limit"
            };

            CoinbaseRequest orderRequest = new CoinbaseRequest(_addOrderPath, _apiInfo, requestBody, Method.POST);

            orderRequest.AddSignatureHeader();

            Dictionary <string, dynamic> orderResponse = ApiPost(orderRequest);

            return((string)GetValueFromResponseResult(orderResponse, "id"));
        }