Beispiel #1
0
def _parse_components(index, html):
    exchange = index.exchange

    for row in html.xpath('//table[@class="yfnc_tableout1"]//tr[./td/@class="yfnc_tabledata1"]'):
        ticker = row[0][0][0].text  # <td><b><a>Symbol</td></b></a>
        dotpos = ticker.rfind(".")
        ticker = ticker[:dotpos] if dotpos > 0 else ticker

        try:
            symbol = get_symbol(exchange, ticker)
        except Symbol.DoesNotExist:
            stock_name = row[1].text
            symbol = Symbol(name=stock_name, ticker=ticker, exchange=exchange, type=Symbol.STOCK)

        yield symbol
Beispiel #2
0
def _parse_components(index, html):
    exchange = index.exchange

    for row in html.xpath(
            '//table[@class="yfnc_tableout1"]//tr[./td/@class="yfnc_tabledata1"]'
    ):
        ticker = row[0][0][0].text  # <td><b><a>Symbol</td></b></a>
        dotpos = ticker.rfind('.')
        ticker = ticker[:dotpos] if dotpos > 0 else ticker

        try:
            symbol = get_symbol(exchange, ticker)
        except Symbol.DoesNotExist:
            stock_name = row[1].text
            symbol = Symbol(name=stock_name,
                            ticker=ticker,
                            exchange=exchange,
                            type=Symbol.STOCK)

        yield symbol
Beispiel #3
0
import datetime
import sys

from data.cache import get_price, get_quotes
from data.models import get_symbol, get_exchange


try:
    lse = get_exchange('LSE')
    ftse = get_symbol(lse, 'FTSE')
except:
    print 'Please run the setup script first!'
    sys.exit(1)


start_date = datetime.date(year=2012, month=2, day=2)
end_date = datetime.date(year=2012, month=8, day=2)

quotes = get_quotes(ftse, start_date, end_date)

for quote in quotes:
    print quote


for symbol in ftse.components.all():
    price = get_price(symbol)
    print price