Пример #1
0
def profile():
    """Access the user's profile and stats"""
    if "user" in session:
        user = session["user"]
        geo_data = get_data()
        event_data = generate_buzz()

        return render_template('profile.html', title="My Profile | BestApp", username=user,
                               geo_data=geo_data, event_data=event_data)
    else:
        return redirect(url_for('login'))
Пример #2
0
def question4():
    q = """
    4.
    The event is defined as when the actual close of the stock price drops below $9.00, more specifically, when:
    price[t-1]>=9.0 and price[t]<9.0 an event has occurred on date t.
    * Test this event using the Event Profiler over the period from 1st Jan, 2008 to 31st Dec 2009.
    * Using the symbol list - SP5002012
    * Starting Cash: $50,000
    * At every event Buy 100 shares of the equity, and Sell them 5 trading days later. In case not enough days are available Sell them on the last trading day. (Similar to what the homework 4 description wanted).
    * Run this in your simulator and analyze the results.
    What is the sharpe ratio of the fund ?
    * 1.0 to 1.1
    * 0.9 to 1.0
    * 0.8 to 0.9
    * 0.7 to 0.8
    """

    dt_start = dt.datetime(2008, 1, 1)
    dt_end = dt.datetime(2009, 12, 31)
    cash = 50000

    ldt_timestamps = du.getNYSEdays(dt_start, dt_end, dt.timedelta(hours=16))
    dataobj = da.DataAccess('Yahoo')
    ls_keys = ['open', 'high', 'low', 'close', 'volume', 'actual_close']

    ls_2012_symbols = ev.get_symbols_in_year(dataobj, 2012)
    d_2012_data = ev.get_data(dataobj, ldt_timestamps, ls_2012_symbols)

    order_file = 'orders.csv'
    analysis_file = 'values_9_dollar_event.csv'
    benchmark_symbol = '$SPX'

    df_events = ev.find_9_dollar_events(ls_2012_symbols, d_2012_data)
    ev.generate_orders(ls_2012_symbols, df_events, order_file)

    simulation_result = mksim.simulate(cash, order_file)
    mksim.write_simulation_result(simulation_result, analysis_file)

    fund, benchmark = an.analyze(analysis_file, benchmark_symbol)

    return q, fund.sharpe