Example #1
0
        public override void DeleteOrder(string orderId)
        {
            BitfinexRequest deleteOrderRequest = new BitfinexRequest(DeleteOrderPath, _apiInfo);

            deleteOrderRequest.AddPayloadParameter("order_id", orderId);
            deleteOrderRequest.AddSignatureHeader();

            Dictionary <string, dynamic> response = ApiPost(deleteOrderRequest);
        }
Example #2
0
        public override Dictionary <string, dynamic> GetOrderInformation(string orderId)
        {
            BitfinexRequest orderStatusRequest = new BitfinexRequest(OrderQueryPath, _apiInfo);

            orderStatusRequest.AddPayloadParameter("order_id", orderId);
            orderStatusRequest.AddSignatureHeader();

            return(ApiPost(orderStatusRequest));
        }
Example #3
0
        public override List <Dictionary <string, dynamic> > GetAllOpenOrders()
        {
            BitfinexRequest openOrderRequest = new BitfinexRequest(OpenOrderPath, _apiInfo);

            openOrderRequest.AddSignatureHeader();

            Dictionary <string, dynamic>[] response = ApiPost_Array(openOrderRequest);

            return(response.ToList());
        }
Example #4
0
        public override void SetTradeFee()
        {
            BitfinexRequest tradeFeeRequest = new BitfinexRequest(_tradeFeePath, ApiInfo);

            tradeFeeRequest.AddSignatureHeader();

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

            TradeFee = TypeConversion.ParseStringToDecimalStrict((string)GetValueFromResponseResult(response, "taker_fees"));
        }
Example #5
0
        public override void UpdateBalances()
        {
            bool btcFound  = false;
            bool fiatFound = false;

            BitfinexRequest balanceInfoRequest = new BitfinexRequest(AccountBalanceInfoPath, _apiInfo);

            balanceInfoRequest.AddSignatureHeader();

            Dictionary <string, dynamic>[] response = ApiPost_Array(balanceInfoRequest);

            //Loop through each of the dictionaries in the response; looking for the btc and usd exchange wallets
            foreach (Dictionary <string, dynamic> walletDictionary in response)
            {
                if (String.Equals((string)GetValueFromResponseResult(walletDictionary, "type"), "exchange", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (String.Equals((string)GetValueFromResponseResult(walletDictionary, "currency"), "usd", StringComparison.InvariantCultureIgnoreCase))
                    {
                        fiatFound = true;

                        TotalFiat     = TypeConversion.ParseStringToDecimalStrict((string)GetValueFromResponseResult(walletDictionary, "amount"));
                        AvailableFiat = TypeConversion.ParseStringToDecimalStrict((string)GetValueFromResponseResult(walletDictionary, "available"));
                    }

                    else if (String.Equals((string)GetValueFromResponseResult(walletDictionary, "currency"), "btc", StringComparison.InvariantCultureIgnoreCase))
                    {
                        btcFound = true;

                        TotalBtc     = TypeConversion.ParseStringToDecimalStrict((string)GetValueFromResponseResult(walletDictionary, "amount"));
                        AvailableBtc = TypeConversion.ParseStringToDecimalStrict((string)GetValueFromResponseResult(walletDictionary, "available"));
                    }
                }
            }

            //If there wasn't any btc or usd, Bitfinex does not return a dictionary of that currency. So if the currency dictionaries were not found, set values to 0.
            if (!btcFound)
            {
                AvailableBtc = 0.0m;
                TotalBtc     = 0.0m;
            }

            if (!fiatFound)
            {
                AvailableFiat = 0.0m;
                TotalFiat     = 0.0m;
            }
        }
Example #6
0
        private string ExecuteOrder(decimal amount, decimal price, OrderType orderType)
        {
            BitfinexRequest addOrderRequest = new BitfinexRequest(_addOrderPath, _apiInfo);

            addOrderRequest.AddPayloadParameter("symbol", _btcFiatPairSymbol);
            addOrderRequest.AddPayloadParameter("amount", amount.ToString());
            addOrderRequest.AddPayloadParameter("price", price.ToString("F"));
            addOrderRequest.AddPayloadParameter("exchange", "bitfinex");
            addOrderRequest.AddPayloadParameter("side", orderType.ToString().ToLower());
            addOrderRequest.AddPayloadParameter("type", "exchange limit");

            addOrderRequest.AddSignatureHeader();

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

            return(((int)GetValueFromResponseResult(orderResponse, "id")).ToString());
        }
Example #7
0
        public override void UpdateOrderBook(int?maxSize = null)
        {
            BitfinexRequest orderBookRequest = new BitfinexRequest(OrderBookPath);

            //If max size was given, add limit parameters to the request
            if (maxSize != null)
            {
                orderBookRequest.AddParameter("limit_bids", maxSize);
                orderBookRequest.AddParameter("limit_asks", maxSize);
            }


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

            if (!response.ContainsKey("bids") || !response.ContainsKey("asks"))
            {
                throw new Exception("Could not update order book for " + Name + ", 'asks' or 'bids' object was not in the response.");
            }

            BuildOrderBook(response, "amount", "price", maxSize);
        }