Exemple #1
0
def get_symbol_part(symbol, options_list, start, end, days, tolerance):
    symbol_data = SymbolData(symbol=symbol,
                             options_list=options_list).get_data()
    trades = OptimalTrades(symbol=symbol,
                           start=start,
                           end=end,
                           tolerance=tolerance).get_data()
    data_in, data_out = filter_matching(symbol_data, trades)
    data_in = add_prior_days(data_in, days, symbol_data)
    new_in = json_to_matrix(data_in)
    new_out = json_to_matrix(data_out)
    return new_in, new_out
def graph_symbol_data(symbol, options_list, start, end):
    data = SymbolData(symbol=symbol,
                      options_list=options_list,
                      start=start,
                      end=end).get_data()
    columns = get_columns(data)
    data_list = [extract_column(col, data) for col in columns]

    xys = dicts_to_xys(data_list)

    fig = plt.figure()
    for x, y in xys:
        plt.plot(x, y)

    plt.title('Symbol Data (%s)' % symbol)
    plt.ylabel('Indicator Value')
    plt.xlabel('Date')
    # TODO add legend

    return fig
Exemple #3
0
def get_symbol_part(symbol, options_list, start, end, days, tolerance):
    symbol_data = SymbolData(symbol=symbol,
                             options_list=options_list).get_data()
    trades = OptimalTrades(symbol=symbol,
                           start=start,
                           end=end,
                           tolerance=tolerance).get_data()
    data_in, data_out = filter_matching(symbol_data, trades)
    data_in = add_prior_days(data_in, days, symbol_data)
    try:
        new_in = json_to_matrix(data_in)
        new_out = json_to_matrix(data_out)
    except:
        print(symbol, options_list)  # TODO fix
        raise Exception
    if 0 in new_in.shape:
        print(symbol, options_list)  # TODO fix
        # try again
        return get_symbol_part(symbol, options_list, start, end, days,
                               tolerance)
    return new_in, new_out
 def test_symbol_data2(self):
     SymbolData(symbol='AAPL',
                options_list=get_options_list(['macd', 'ema']))
 def test_symbol_data1(self):
     log('\n\nTesting symbol data...\n\n')
     SymbolData(symbol='AAPL',
                options_list=get_options_list(['sma', 'ema']))
Exemple #6
0
 def test_symbol_data3(self):
     data = SymbolData(symbol='AAPL', options_list=get_options_list(['sma']))
     log('refreshing data...')
     remove_last_line(data.get_symbol_path())
     SymbolData(symbol='AAPL', options_list=get_options_list(['sma', 'ema'])).refresh_data(update_old=True)