The user's balance with planned withdrawals deducted.
197163
def effective_balance(self, address: Address, block_identifier: BlockSpecification) -> Balance:
        
        fn = getattr(self.proxy.contract.functions, 'effectiveBalance')
        balance = fn(address).call(block_identifier=block_identifier)

        if balance == b'':
            raise RuntimeError(f"Call to 'effectiveBalance' returned nothing")

        return balance
486158
private static Double calculateMean(Money minMoney, Money maxMoney) {
    if (minMoney == null || maxMoney == null) {
      return null;
    }
    return calculateMean(minMoney.getMicroAmount(), maxMoney.getMicroAmount());
  }
573390
public function updateAccountBalance()
    {
        $this->getAccount()->setBalance($this->getAccount()->getBalance()+$this->getAmount());
        $this->setBalanceAfterwards($this->getAccount()->getBalance());
    }
1289739
def AddToBalance(self, assetId, fixed8_val):
        
        found = False
        for key, balance in self.Balances.items():
            if key == assetId:
                self.Balances[assetId] = self.Balances[assetId] + fixed8_val
                found = True
        if not found:
            self.Balances[assetId] = fixed8_val
1111514
function balance() {
	binance.balance((error, balances) => {
		if ( error ) console.error(error);
		let btc = 0.00;
		for ( let asset in balances ) {
			let obj = balances[asset];
			obj.available = parseFloat(obj.available);
			//if ( !obj.available ) continue;
			obj.onOrder = parseFloat(obj.onOrder);
			obj.btcValue = 0;
			obj.btcTotal = 0;
			if ( asset == 'BTC' ) obj.btcValue = obj.available;
			else if ( asset == 'USDT' ) obj.btcValue = obj.available / global.ticker.BTCUSDT;
			else obj.btcValue = obj.available * global.ticker[asset+'BTC'];
			if ( asset == 'BTC' ) obj.btcTotal = obj.available + obj.onOrder;
			else if ( asset == 'USDT' ) obj.btcTotal = (obj.available + obj.onOrder) / global.ticker.BTCUSDT;
			else obj.btcTotal = (obj.available + obj.onOrder) * global.ticker[asset+'BTC'];
			if ( isNaN(obj.btcValue) ) obj.btcValue = 0;
			if ( isNaN(obj.btcTotal) ) obj.btcTotal = 0;
			btc+= obj.btcTotal;
			global.balance[asset] = obj;
		}
		//fs.writeFile("json/balance.json", JSON.stringify(global.balance, null, 4), (err)=>{});
	});
}
135827
def churn(self):
		""""""
		canceled = self.canceled().count()
		active = self.active().count()
		return decimal.Decimal(str(canceled)) / decimal.Decimal(str(active))
288382
def withdraw(self, account_id, **params):
        """"""
        for required in ['payment_method', 'amount', 'currency']:
            if required not in params:
                raise ValueError("Missing required parameter: %s" % required)
        response = self._post('v2', 'accounts', account_id, 'withdrawals', data=params)
        return self._make_api_object(response, Withdrawal)
153138
def balance(ctx, accounts):
    
    t = [["Account", "Amount"]]
    for a in accounts:
        account = Account(a, bitshares_instance=ctx.bitshares)
        for b in account.balances:
            t.append([str(a), str(b)])
    print_table(t)
756190
def cancel(ctx, orders, account):
    
    print_tx(ctx.bitshares.cancel(orders, account=account))
1335294
def get_balance(self):
        
        on_date = Datum()
        on_date.today()
        return self.get_balance_on(on_date.value)
220098
def balance_get(self, nick):
        ''''''
        request = TOPRequest('xxxxx.xxxxx.account.balance.get')
        request['nick'] = nick
        self.create(self.execute(request))
        return self.result
273144
def handle_split(self, asset, ratio):
        
        if self.asset != asset:
            raise Exception("updating split with the wrong asset!")

        # adjust the # of shares by the ratio
        # (if we had 100 shares, and the ratio is 3,
        #  we now have 33 shares)
        # (old_share_count / ratio = new_share_count)
        # (old_price * ratio = new_price)

        # e.g., 33.333
        raw_share_count = self.amount / float(ratio)

        # e.g., 33
        full_share_count = np.floor(raw_share_count)

        # e.g., 0.333
        fractional_share_count = raw_share_count - full_share_count

        # adjust the cost basis to the nearest cent, e.g., 60.0
        new_cost_basis = round(self.cost_basis * ratio, 2)

        self.cost_basis = new_cost_basis
        self.amount = full_share_count

        return_cash = round(float(fractional_share_count * new_cost_basis), 2)

        log.info("after split: " + str(self))
        log.info("returning cash: " + str(return_cash))

        # return the leftover cash, which will be converted into cash
        # (rounded to the nearest cent)
        return return_cash
960537
def allocate(self):
        
        df = self.manager.get_historic_data()[self.SUPPORTED_COINS]

        #==== Calculate the daily changes ====#
        change_columns = []
        for column in df:
            if column in self.SUPPORTED_COINS:
                change_column = '{}_change'.format(column)
                values = pd.Series(
                    (df[column].shift(-1) - df[column]) /
                    -df[column].shift(-1)
                ).values
                df[change_column] = values
                change_columns.append(change_column)

        # print(df.head())
        # print(df.tail())

        #==== Variances and returns ====#
        columns = change_columns
        # NOTE: `risks` is not used, but may be used in the future
        risks = df[columns].apply(np.nanvar, axis=0)
        # print('\nVariance:\n{}\n'.format(risks))
        returns = df[columns].apply(np.nanmean, axis=0)
        # print('\nExpected returns:\n{}\n'.format(returns))

        #==== Calculate risk and expected return ====#
        cov_matrix = df[columns].cov()
        # NOTE: The diagonal variances weren't calculated correctly, so here is a fix.
        cov_matrix.values[[np.arange(len(self.SUPPORTED_COINS))] * 2] = df[columns].apply(np.nanvar, axis=0)
        weights = np.array([1/len(self.SUPPORTED_COINS)] * len(self.SUPPORTED_COINS)).reshape(len(self.SUPPORTED_COINS), 1)

        #==== Calculate portfolio with the minimum risk ====#
        min_risk = self.get_min_risk(weights, cov_matrix)
        min_return = np.dot(min_risk, returns.values)

        #==== Calculate portfolio with the maximum return ====#
        max_return = self.get_max_return(weights, returns)

        #==== Calculate efficient frontier ====#
        frontier = self.efficient_frontier(
            returns, cov_matrix, min_return, max_return, 6
        )
        return frontier
651317
def transferBalance(self, currency, amount, fromAccount, toAccount):
        """"""
        return self._private('transferBalance', currency=currency,
                             amount=amount, fromAccount=fromAccount,
                             toAccount=toAccount)
986931
def get_withdrawal(self, withdrawal_id, **params):
        """"""
        return self.api_client.get_withdrawal(self.id, withdrawal_id, **params)
1256983
def average_balance_recharges(user, **kwargs):
    

    balance = 0
    for r1, r2 in pairwise(user.recharges):
        # If the range is less than 1 day, cap at 1
        balance += r1.amount * min(1, (r2.datetime - r1.datetime).days) / 2

    first_recharge = user.recharges[0]
    last_recharge = user.recharges[-1]
    duration = (last_recharge.datetime - first_recharge.datetime).days
    return balance / min(1, duration)
743843
def request_withdrawal(self, amount: Number, address: str, subtract_fee: bool=False, **params) -> Withdrawal:
        """"""
        self.log.debug(f'Requesting {self.currency} withdrawal from {self.name} to {address}')
        amount = self._parse_money(amount)

        if self.dry_run:
            withdrawal = Withdrawal.create_default(TxType.WITHDRAWAL, self.currency, amount, address)
            self.log.warning(f'DRY RUN: Withdrawal requested on {self.name}: {withdrawal}')
            return withdrawal

        try:
            withdrawal = self._withdraw(amount, address, subtract_fee, **params)
        except Exception as e:
            msg = f'Failed requesting withdrawal on {self.name}!: amount={amount}, address={address}'
            raise self.exception(InvalidWithdrawal, msg, e) from e

        self.log.info(f'Withdrawal requested on {self.name}: {withdrawal}')
        return withdrawal