Esempio n. 1
0
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProvider.GetApi(context);

            var r = await api.GetAccountBalancesAsync().ConfigureAwait(false);

            var balances = new BalanceResults(this);

            var btcAsset = "btc".ToAsset(this);
            var usdAsset = "usd".ToAsset(this);
            var eurAsset = "eur".ToAsset(this);

            balances.Add(new BalanceResult(btcAsset)
            {
                Available = new Money(r.btc_available, btcAsset),
                Balance   = new Money(r.btc_balance, btcAsset),
                Reserved  = new Money(r.btc_reserved, btcAsset)
            });

            balances.Add(new BalanceResult(usdAsset)
            {
                Available = new Money(r.usd_available, usdAsset),
                Balance   = new Money(r.usd_balance, usdAsset),
                Reserved  = new Money(r.usd_reserved, usdAsset)
            });

            balances.Add(new BalanceResult(eurAsset)
            {
                Available = new Money(r.eur_available, eurAsset),
                Balance   = new Money(r.eur_reserved, eurAsset),
                Reserved  = new Money(r.eur_balance, eurAsset)
            });

            return(balances);
        }
Esempio n. 2
0
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProvider.GetApi(context);

            var body = CreateKrakenBody();

            var r = await api.GetBalancesAsync(body).ConfigureAwait(false);

            CheckResponseErrors(r);

            var results = new BalanceResults(this);

            foreach (var pair in r.result)
            {
                var asset = pair.Key.ToAsset(this);
                var money = new Money(pair.Value, asset);

                results.Add(new BalanceResult(asset)
                {
                    Available = money,
                    Balance   = money,
                    Reserved  = 0
                });
            }

            return(results);
        }
Esempio n. 3
0
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProvider.GetApi(context);
            var r   = await api.GetBalancesAsync().ConfigureAwait(false);

            var balances = new BalanceResults(this);

            foreach (var rBalance in r)
            {
                balances.Add(rBalance.currency.ToAsset(this), rBalance.available, rBalance.reserved);
            }

            return(balances);
        }
Esempio n. 4
0
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProvider.GetApi(context);

            var r = await api.GetUserWalletInfoAsync("XBt").ConfigureAwait(false);

            var results = new BalanceResults(this);

            var btcAmount = (decimal)ConversionRate * r.amount;

            var c = Asset.Btc;

            results.Add(c, btcAmount, 0);
            return(results);
        }
Esempio n. 5
0
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProvider.GetApi(context);
            var r   = await api.GetAccountInformationAsync().ConfigureAwait(false);

            var balances = new BalanceResults();

            foreach (var b in r.balances)
            {
                var asset = b.asset.ToAsset(this);
                balances.Add(asset, b.free, b.locked);
            }

            return(balances);
        }
Esempio n. 6
0
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProvider.GetApi(context);

            var body = CreatePoloniexBody(PoloniexBodyType.ReturnCompleteBalances);

            var r = await api.GetBalancesDetailedAsync(body).ConfigureAwait(false);

            var results = new BalanceResults(this);

            foreach (var kvp in r)
            {
                var c = kvp.Key.ToAsset(this);
                results.Add(c, kvp.Value.available, kvp.Value.onOrders);
            }

            return(results);
        }
Esempio n. 7
0
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProvider.GetApi(context);

            var r = await api.GetAllBalancesAsync().ConfigureAwait(false);

            CheckResponseErrors(r);

            var balances = new BalanceResults();

            foreach (var rBalance in r.result)
            {
                var asset = rBalance.Currency.ToAsset(this);
                balances.Add(asset, rBalance.Available, rBalance.Pending);
            }

            return(balances);
        }
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api  = ApiProvider.GetApi(context);
            var rRaw = await api.GetBalanceAsync(new CryptopiaSchema.BalanceRequest()).ConfigureAwait(false);

            CheckCryptopiaResponseErrors(rRaw);

            var r = rRaw.GetContent();

            var balances = new BalanceResults(this);

            foreach (var rBalance in r.Data)
            {
                var asset = rBalance.Symbol.ToAsset(this);
                balances.Add(asset, rBalance.Available, rBalance.HeldForTrades + rBalance.PendingWithdraw);
            }

            return(balances);
        }
Esempio n. 9
0
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProvider.GetApi(context);
            var r   = await api.GetBalancesAsync().ConfigureAwait(false);

            var balances = new BalanceResults(this);

            foreach (var rBalance in r.balance)
            {
                balances.Add(new BalanceResult(rBalance.currency_code.ToAsset(this))
                {
                    Available = rBalance.balance,
                    Balance   = rBalance.balance,
                    Reserved  = 0
                });
            }

            return(balances);
        }
Esempio n. 10
0
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProvider.GetApi(context);
            var r   = await api.GetAccountsAsync().ConfigureAwait(false);

            var results = new BalanceResults(this);

            foreach (var a in r.data)
            {
                if (a.balance == null)
                {
                    continue;
                }

                var c = a.balance.currency.ToAsset(this);
                results.Add(c, a.balance.amount, 0);
            }

            return(results);
        }
        public virtual async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProviderPrivate.GetApi(context);

            var body = CreatePostBody();

            body.Add("method", ApiMethodsConfig[ApiMethodNamesTiLiWe.GetInfoExt]);

            var r = await api.GetUserInfoExtAsync(body).ConfigureAwait(false);

            CheckResponse(r);

            var balances = new BalanceResults(this);

            foreach (var fund in r.return_.funds)
            {
                var c = fund.Key.ToAsset(this);
                balances.Add(c, fund.Value.value, fund.Value.inOrders);
            }

            return(balances);
        }
Esempio n. 12
0
        public async Task <BalanceResults> GetBalancesAsync(NetworkProviderPrivateContext context)
        {
            var api = ApiProvider.GetApi(context);

            var body = new BitfinexSchema.WalletBalancesRequest.Descriptor();

            var rRaw = await api.GetWalletBalancesAsync(body).ConfigureAwait(false);

            CheckBitfinexResponseErrors(rRaw);

            var r = rRaw.GetContent();

            var balances = new BalanceResults(this);

            foreach (var rBalance in r)
            {
                var asset = rBalance.currency.ToAsset(this);
                balances.Add(asset, rBalance.available, rBalance.amount - rBalance.available);
            }

            return(balances);
        }