0

I'm a programmer and recently I'm approaching to the world of trading. Now I'm attempting to obtain historical data of AAPL. This is code for obtaining historical data from Quandl:

import datetime
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline

pd.options.display.max_rows = 99999

import quandl
quandl.ApiConfig.api_key = "PersonalCode"

dataset_quandl = quandl.get('AAPL', start_date="2018-01-01", end_date="2018-12-31")
dataset_quandl = dataset_quandl.iloc[:,:4]
dataset_quandl.columns = ["open","high","low","close"]
dataset_quandl.head(10)

And i will obtain the following DataFrame: Prices from Quandl

If i try to download the same data from Yahoo Finance, i will read totally different prices:

import ffn

dataset_ffn = ffn.get('aapl:Open,aapl:High,aapl:Low,aapl:Close', start='2018-01-01', end='2018-12-31')
dataset_ffn.columns = ["open","high","low","close"]
dataset_ffn = dataset_ffn.apply(lambda x: round(x,2))
dataset_ffn.head(10)

prices from yahoo

I would like to know what is the reason for this difference. How I should behave in these cases?

2
  • 3
    This is answered in the related question here: money.stackexchange.com/a/33695/83653 Apple has had a 4-1 stock split in 2020 (investor.apple.com/faq/default.aspx), hence the Quandl numbers are exactly four times the Yahoo numbers.
    – Jeroen
    Feb 11, 2021 at 10:26
  • To fix the problem, see if either provider has an "adjusted close" column that matches. Yahoo shows that column on their web site - but I don't know how that's represented in their API.
    – D Stanley
    Feb 11, 2021 at 14:14

0

Browse other questions tagged or ask your own question.