import ujson

from noobit.server import settings
from noobit.server.views import APIRouter



router = APIRouter()


@router.get('/account/balance/{exchange}')
async def get_balance_full(exchange: str):
    '''
    returns: entire balance(holdings + positions)
    '''

    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get("balances")
    user_balances = ujson.loads(user_balances)

    # exch_balance = [balance for balance in all_balances if balance["exchange_id"]==settings.EXCHANGE_IDS[exchange]]
    # above code useless since we cleaned up the dict straight in the startup balance file

    return user_balances[exchange]


@router.get('/account/balance/holdings/{exchange}')
async def get_balance_holdings(exchange: str):
    '''
    returns: balance holdings
    '''

    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get("balances")
    user_balances = ujson.loads(user_balances)

    # exch_balance = [balance for balance in all_balances if balance["exchange_id"]==settings.EXCHANGE_IDS[exchange]]
    # above code useless since we cleaned up the dict straight in the startup balance file

    return user_balances[exchange]["holdings"]


@router.get('/account/balance/positions/{exchange}')
async def get_balance_positions(exchange: str):
    '''
    returns : balance positions
    '''

    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get("balances")
    user_balances = ujson.loads(user_balances)

    # exch_balance = [balance for balance in all_balances if balance["exchange_id"]==settings.EXCHANGE_IDS[exchange]]
    # above code useless since we cleaned up the dict straight in the startup balance file

    return user_balances[exchange]["positions"]
fc91aeafb9cb8cad291f8fb92a9a68c3f6c8d05a
<mask token>

<mask token>


@router.get('/account/balance/{exchange}')
async def get_balance_full(exchange: str):
    """
    returns: entire balance(holdings + positions)
    """
    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get('balances')
    user_balances = ujson.loads(user_balances)
    return user_balances[exchange]


@router.get('/account/balance/holdings/{exchange}')
async def get_balance_holdings(exchange: str):
    """
    returns: balance holdings
    """
    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get('balances')
    user_balances = ujson.loads(user_balances)
    return user_balances[exchange]['holdings']


@router.get('/account/balance/positions/{exchange}')
async def get_balance_positions(exchange: str):
    """
    returns : balance positions
    """
    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get('balances')
    user_balances = ujson.loads(user_balances)
    return user_balances[exchange]['positions']

<mask token>
router = APIRouter()


@router.get('/account/balance/{exchange}')
async def get_balance_full(exchange: str):
    """
    returns: entire balance(holdings + positions)
    """
    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get('balances')
    user_balances = ujson.loads(user_balances)
    return user_balances[exchange]


@router.get('/account/balance/holdings/{exchange}')
async def get_balance_holdings(exchange: str):
    """
    returns: balance holdings
    """
    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get('balances')
    user_balances = ujson.loads(user_balances)
    return user_balances[exchange]['holdings']


@router.get('/account/balance/positions/{exchange}')
async def get_balance_positions(exchange: str):
    """
    returns : balance positions
    """
    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get('balances')
    user_balances = ujson.loads(user_balances)
    return user_balances[exchange]['positions']

import ujson
from noobit.server import settings
from noobit.server.views import APIRouter
router = APIRouter()


@router.get('/account/balance/{exchange}')
async def get_balance_full(exchange: str):
    """
    returns: entire balance(holdings + positions)
    """
    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get('balances')
    user_balances = ujson.loads(user_balances)
    return user_balances[exchange]


@router.get('/account/balance/holdings/{exchange}')
async def get_balance_holdings(exchange: str):
    """
    returns: balance holdings
    """
    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get('balances')
    user_balances = ujson.loads(user_balances)
    return user_balances[exchange]['holdings']


@router.get('/account/balance/positions/{exchange}')
async def get_balance_positions(exchange: str):
    """
    returns : balance positions
    """
    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get('balances')
    user_balances = ujson.loads(user_balances)
    return user_balances[exchange]['positions']

import ujson

from noobit.server import settings
from noobit.server.views import APIRouter



router = APIRouter()


@router.get('/account/balance/{exchange}')
async def get_balance_full(exchange: str):
    '''
    returns: entire balance(holdings + positions)
    '''

    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get("balances")
    user_balances = ujson.loads(user_balances)

    # exch_balance = [balance for balance in all_balances if balance["exchange_id"]==settings.EXCHANGE_IDS[exchange]]
    # above code useless since we cleaned up the dict straight in the startup balance file

    return user_balances[exchange]


@router.get('/account/balance/holdings/{exchange}')
async def get_balance_holdings(exchange: str):
    '''
    returns: balance holdings
    '''

    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get("balances")
    user_balances = ujson.loads(user_balances)

    # exch_balance = [balance for balance in all_balances if balance["exchange_id"]==settings.EXCHANGE_IDS[exchange]]
    # above code useless since we cleaned up the dict straight in the startup balance file

    return user_balances[exchange]["holdings"]


@router.get('/account/balance/positions/{exchange}')
async def get_balance_positions(exchange: str):
    '''
    returns : balance positions
    '''

    redis_pool = settings.AIOREDIS_POOL
    user_balances = await redis_pool.get("balances")
    user_balances = ujson.loads(user_balances)

    # exch_balance = [balance for balance in all_balances if balance["exchange_id"]==settings.EXCHANGE_IDS[exchange]]
    # above code useless since we cleaned up the dict straight in the startup balance file

    return user_balances[exchange]["positions"]