Exemple #1
0
 def test_yahoo_key_info_url(self):
     """
     Test key info url from yahoo
     """
     yahoo_test_url = r"http://finance.yahoo.com/d/quotes.csv?s="
     yahoo_test_url += "GOOG+FB"
     yahoo_test_url += r"&f=see9db4j1j4p5p6s7m8"
     produced = key_info_url(["GOOG", "FB"])
     self.assertEqual(yahoo_test_url, produced)
Exemple #2
0
def get_weights():
    '''
    Uses least squares with the top stocks to predict recent close prices
    '''
    top_url = key_info_url(top_symbols())
    data = request_csv(top_url)
    numeric_data = process(data)
    A = numeric_data[:, :9]
    b = numeric_data[:, 9]
    weights = np.linalg.lstsq(A, b)[0]
    return weights
Exemple #3
0
def predict_change(symbol):
    '''
    Takes a single stock and predicts its change from 50 day average
    returns both guess and actual change
    '''
    weights = get_weights()
    symbol_url = key_info_url(symbol).replace('+', '')
    data = request_csv(symbol_url)
    numeric_data = process(data)
    guess = weights.dot(numeric_data[0, :9])
    actual = numeric_data[0, 9]
    return [guess, actual]