Ejemplo n.º 1
0
        public void SetCredentials(string aApiKey, string aApiSecret)
        {
            var lCredentials = new ApiCredentials(aApiKey, aApiSecret);

            var lClientOptions = new BitfinexClientOptions {
                ApiCredentials = lCredentials
            };

            BitfinexClient.SetDefaultOptions(lClientOptions);
            using (BitfinexClient lClient = new BitfinexClient())
            {
                var lResponse = lClient.GetBalancesAsync().Result;
                if (!lResponse.Success)
                {
                    throw new PandoraExchangeExceptions.InvalidExchangeCredentials("Incorrect Key Pair for selected exchange");
                }
            }
            FUserCredentials = new Tuple <string, string>(aApiKey, aApiSecret);
            IsCredentialsSet = true;
        }
Ejemplo n.º 2
0
        public decimal GetBalance(IExchangeMarket aMarket)
        {
            if (!IsCredentialsSet)
            {
                throw new Exception("No Credentials were set");
            }

            using (var lClient = new BitfinexClient())
            {
                var lResponse = lClient.GetBalancesAsync().Result;
                if (!lResponse.Success)
                {
                    throw new Exception($"Failed to retrieve balance. Details: {lResponse.Error}");
                }
                var lBalances       = lResponse.Data;
                var lDecimalBalance = lBalances.Where(lBalance => lBalance.Currency == aMarket.SellingCurrencyInfo.Ticker).FirstOrDefault();
                if (lDecimalBalance == null)
                {
                    throw new Exception($"Failed to get balance for currency {aMarket.SellingCurrencyInfo.Name}");
                }
                return(lDecimalBalance.Balance);
            }
        }
Ejemplo n.º 3
0
        public async Task <XBalanceMap> GetBalances()
        {
            var res = await m_client.GetBalancesAsync();    //GetWalletsAsync();

            return(new XBalanceMap(res.Data));
        }