Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        public Dictionary <string, Exchange.Clients.Poloniex.UserBalance> GetBalances()
        {
            var res = m_api.GetBalances().Result;

            return(res);
        }