Ejemplo n.º 1
0
def view_index(request, ticker):
    try:
        index = Symbol.objects.get(ticker=ticker)
    except Symbol.DoesNotExist:
        return json_response({'error': 'Index not found'})

    price = get_price(index)
    components = get_components(index)

    result = serialize_symbol(index, price)
    prices = get_prices(components)
    result['components'] = [serialize_symbol(p.symbol, p) for p in prices]

    return json_response(result)
Ejemplo n.º 2
0
def view_index(request, ticker):
    try:
        index = Symbol.objects.get(ticker=ticker)
    except Symbol.DoesNotExist:
        return json_response({'error': 'Index not found'})

    price = get_price(index)
    components = get_components(index)

    result = serialize_symbol(index, price)
    prices = get_prices(components)
    result['components'] = [serialize_symbol(p.symbol, p) for p in prices]

    return json_response(result)
Ejemplo n.º 3
0
from data.models import Exchange, Symbol
from data.cache import get_components


lse, created = Exchange.objects.get_or_create(abbreviation='LSE',
    defaults={'name': 'London Stock Exchange',
              'ticker': 'L'})
lse.save()


ftse100, created = Symbol.objects.get_or_create(ticker='FTSE',
    defaults={'name': 'FTSE 100',
              'exchange': lse,
              'type': Symbol.INDEX})
ftse100.save()


components = get_components(ftse100)
Ejemplo n.º 4
0
from data.models import Exchange, Symbol
from data.cache import get_components


nasdaq, created = Exchange.objects.get_or_create(abbreviation='NASDAQ',
    defaults={'name': 'NASDAQ Stock Market',
              'ticker': ''})
nasdaq.save()


ndx, created = Symbol.objects.get_or_create(ticker='NDX',
    defaults={'name': 'NASDAQ-100',
              'exchange': nasdaq,
              'type': Symbol.INDEX})
ndx.save()


components = get_components(ndx)
Ejemplo n.º 5
0
from data.models import Exchange, Symbol
from data.cache import get_components


lse, created = Exchange.objects.get_or_create(
    abbreviation="LSE", defaults={"name": "London Stock Exchange", "ticker": "L"}
)
lse.save()


ftse100, created = Symbol.objects.get_or_create(
    ticker="FTSE", defaults={"name": "FTSE 100", "exchange": lse, "type": Symbol.INDEX}
)
ftse100.save()


components = get_components(ftse100)
Ejemplo n.º 6
0
from data.models import Exchange, Symbol
from data.cache import get_components

nasdaq, created = Exchange.objects.get_or_create(abbreviation='NASDAQ',
                                                 defaults={
                                                     'name':
                                                     'NASDAQ Stock Market',
                                                     'ticker': ''
                                                 })
nasdaq.save()

ndx, created = Symbol.objects.get_or_create(ticker='NDX',
                                            defaults={
                                                'name': 'NASDAQ-100',
                                                'exchange': nasdaq,
                                                'type': Symbol.INDEX
                                            })
ndx.save()

components = get_components(ndx)