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; }
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); } }
public async Task <XBalanceMap> GetBalances() { var res = await m_client.GetBalancesAsync(); //GetWalletsAsync(); return(new XBalanceMap(res.Data)); }