コード例 #1
0
ファイル: views.py プロジェクト: virtuallynathan/dr_stock
def view_historical(request, exchange, ticker, start_date, end_date):
    try:
        symbol = Symbol.objects.get(ticker=ticker,
                                    exchange__abbreviation=exchange)
    except Symbol.DoesNotExist:
        return json_response({'error': 'Symbol not found'})

    start_date = datetime.strptime(start_date, '%Y-%m-%d')
    end_date = datetime.strptime(end_date, '%Y-%m-%d')
    quotes = get_quotes(symbol, start_date, end_date)

    result = serialize_historical(symbol, quotes)
    return json_response(result)
コード例 #2
0
def view_historical(request, exchange, ticker, start_date, end_date):
    try:
        symbol = Symbol.objects.get(ticker=ticker,
                                    exchange__abbreviation=exchange)
    except Symbol.DoesNotExist:
        return json_response({'error': 'Symbol not found'})

    start_date = datetime.strptime(start_date, '%Y-%m-%d')
    end_date = datetime.strptime(end_date, '%Y-%m-%d')
    quotes = get_quotes(symbol, start_date, end_date)

    result = serialize_historical(symbol, quotes)
    return json_response(result)
コード例 #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