Example #1
0
        protected override string TransferInternal(decimal amount, string address)
        {
            KrakenRequest transferRequest = new KrakenRequest(_transferPath, _apiInfo);

            transferRequest.AddParameter("asset", BTC_SYMBOL);
            transferRequest.AddParameter("key", address);
            transferRequest.AddParameter("amount", amount);
            transferRequest.AddSignatureHeader();

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

            return((string)GetValueFromResponseResult(response, "refid"));
        }
Example #2
0
        /// <summary>
        /// With Kraken, 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)
        {
            KrakenRequest sellRequest = new KrakenRequest(_addOrderPath, _apiInfo);

            sellRequest.AddParameter("pair", _btcFiatPairSymbol);
            sellRequest.AddParameter("type", orderType.ToString().ToLower());     //Important note: Kraken api requires that the order type be lower case (else there will be an error), thus the ToLower().
            sellRequest.AddParameter("ordertype", "limit");
            sellRequest.AddParameter("price", price);
            sellRequest.AddParameter("volume", amount);
            sellRequest.AddSignatureHeader();

            Dictionary <string, dynamic> sellResponse = ApiPost(sellRequest);
            ArrayList transactionIdList = (ArrayList)GetValueFromResponseResult(sellResponse, "txid");

            return(StringManipulation.CreateDelimitedStringFromArrayList(transactionIdList, '|'));
        }
Example #3
0
        public override void UpdateOrderBook(int?maxSize = null)
        {
            KrakenRequest request = new KrakenRequest(OrderBookPath);

            request.AddParameter("pair", _btcFiatPairSymbol);

            if (maxSize != null)
            {
                request.AddParameter("count", maxSize.Value);
            }

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

            response = (Dictionary <string, dynamic>)GetValueFromResponseResult(response, _btcFiatPairSymbol);
            BuildOrderBook(response, 1, 0, maxSize);
        }
Example #4
0
        public override Dictionary <string, dynamic> GetOrderInformation(string orderId)
        {
            KrakenRequest request = new KrakenRequest(OrderQueryPath, _apiInfo);

            request.AddParameter("txid", orderId);
            request.AddSignatureHeader();

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

            response = (Dictionary <string, dynamic>)GetValueFromResponseResult(response, orderId);

            return(response);
        }
Example #5
0
        public override void SetTradeFee()
        {
            KrakenRequest request = new KrakenRequest(_tradeFeeInfoPath, _apiInfo);

            request.AddParameter("pair", _btcFiatPairSymbol);
            request.AddSignatureHeader();

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

            //The trade fee value is buried deep in the response; par down response until we get to the bit we want
            response = (Dictionary <string, dynamic>)GetValueFromResponseResult(response, "fees");
            response = (Dictionary <string, dynamic>)GetValueFromResponseResult(response, _btcFiatPairSymbol);

            TradeFee = TypeConversion.ParseStringToDecimalStrict((string)GetValueFromResponseResult(response, "fee"));
        }
Example #6
0
        public override void DeleteOrder(string orderId)
        {
            //Build the request
            KrakenRequest deleteOrderRequest = new KrakenRequest(DeleteOrderPath, _apiInfo);

            deleteOrderRequest.AddParameter("txid", orderId);
            deleteOrderRequest.AddSignatureHeader();

            //Post the request
            Dictionary <string, dynamic> response = ApiPost(deleteOrderRequest);

            //Kraken should return a response indicating that exactly 1 order was deleted. If more than 1 was deleted, something went wrong.
            if ((int)GetValueFromResponseResult(response, "count") > 1)
            {
                throw new Exception("Delete for order " + orderId + " at " + Name + " resulted in more than 1 order being deleted.");
            }
        }