public decimal GetBalance(IExchangeMarket aMarket) { if (!IsCredentialsSet) { throw new Exception("No Credentials were set"); } using (PoloniexClient lClient = new PoloniexClient()) { var lResponse = lClient.GetBalances(); if (!lResponse.Success || !lResponse.Data.TryGetValue(aMarket.SellingCurrencyInfo.Ticker, out decimal lBalance)) { throw new Exception("Failed to retrieve balance"); } return(lBalance); } }
public void SetCredentials(string aApiKey, string aApiSecret) { var lKeyGuid = aApiKey.Replace("-", string.Empty); var lFormatedGUID = Enumerable.Range(0, lKeyGuid.Count() / 8) .Select(lCounter => lKeyGuid.Substring(lCounter * 8, 8)) .Aggregate((first, second) => string.Concat(first, "-", second)).ToUpperInvariant(); var lCredentials = new ApiCredentials(lFormatedGUID, aApiSecret.ToLowerInvariant()); PoloniexClientOptions lClientOptions = new PoloniexClientOptions { ApiCredentials = lCredentials }; PoloniexClient.SetDefaultOptions(lClientOptions); using (PoloniexClient lClient = new PoloniexClient()) { var lResponse = lClient.GetBalances(); if (!lResponse.Success) { throw new PandoraExchangeExceptions.InvalidExchangeCredentials("Incorrect Key Pair for selected exchange"); } } FUserCredentials = new Tuple <string, string>(lFormatedGUID, aApiSecret.ToLowerInvariant()); IsCredentialsSet = true; }
public Dictionary <string, Exchange.Clients.Poloniex.UserBalance> GetBalances() { var res = m_api.GetBalances().Result; return(res); }