def test_get_eod_data_no_date(): df = get_eod_data("AAPL", "US", api_key=api_key, session=session) print(df) # Note if df is Sentinel it means that the request was sent through but the response # was forbidden indicating that the APi Key may not have been authorized to perform the # Operation if df is not sentinel: assert df.index.name == "Date"
def test_get_eod_data_with_date(): df = get_eod_data("AAPL", "US", start="2016-02-01", end="2016-02-10", api_key=api_key, session=session) print(df) assert df.index.name == "Date" assert df.index[0] == pd.to_datetime("2016-02-01")
def test_get_eod_data_with_date(): df = get_eod_data("AAPL", "US", start="2020-02-01", end="2020-02-10", api_key=api_key, session=session) print(df) if df is not sentinel: assert df.index.name == "Date" assert df.index[0] != ""
def get_symbol_data(symbol, history_length, apikey): today = dt.datetime.now().strftime('%Y-%m-%d') history = (dt.datetime.now() - dt.timedelta(days=365 * history_length)).strftime('%Y-%m-%d') df = get_eod_data(symbol, 'US', start=history, end=today, api_key=apikey) df.loc[:, 'symbol'] = symbol factor = df.Adjusted_close / df.Close df.loc[:, 'adj_close'] = df.Adjusted_close df.loc[:, 'adj_open'] = df.Open * factor df.loc[:, 'adj_high'] = df.High * factor df.loc[:, 'adj_low'] = df.Low * factor return df
def test_get_eod_data_no_date(): df = get_eod_data("AAPL", "US", api_key=api_key, session=session) print(df) assert df.index.name == "Date"