Ticker KXI
From 2018-05-02 00:00:00
Security Type Equity
Market USA
Resolution Daily
Status Waiting Review

When requesting historical data for this ticker, the closing price on May 2nd 2018 is equal to 98.37. On May 3rd 2018 the close price drops to 49.00.

Jupyter Notebook code: (I cannot attach the notebook, because it stays "Loading Notebooks..." in the drop-down menu)

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

qb = QuantBook()

assets = [
# Equity ETFs
"IXJ", # iShares Global Healthcare ETF
"KXI" # iShares Global Consumer Staples ETF
]

symbols = [qb.AddEquity(asset) for asset in assets]
for symbol in symbols:
symbol.SetDataNormalizationMode(DataNormalizationMode.TotalReturn)

def PlotCummulativeReturn(assets):

# Get historical data.
histdata = pd.DataFrame()
for symbol in symbols:
if str(symbol) in assets:
histdata = histdata.append(qb.History(symbol.Symbol, timedelta(days=12*31*4), Resolution.Daily).loc[:, "close"].unstack())

histdata = histdata.T
histdata = histdata.loc[((histdata.index + timedelta(days=2)).year >= 2018)
& (histdata.index.year <= 2020)]

# Normalise the data for plotting.
plotdata = histdata.apply(lambda x: x/x[0])
# Plot data.
plt.figure(figsize=(18,6))

for symbol in plotdata.columns:
plt.plot(plotdata.loc[:, symbol], label=str(symbol))

xlabels = pd.date_range(min(plotdata.index), max(plotdata.index), freq="M")
plt.xticks(xlabels, rotation=30)
plt.margins(x=0)
legend_labels = [symbol.split()[0] for symbol in plotdata.columns]
plt.legend(legend_labels)
plt.axhline(y=1, color='black', linestyle='--')
plt.axvline(x="2019-12-31", color='black', linestyle='--')
plt.show()

return histdata

PlotCummulativeReturn(assets)

histdata = pd.DataFrame()#dict()
for symbol in symbols:
histdata = histdata.append(qb.History(symbol.Symbol, timedelta(days=12*31*4), Resolution.Daily).loc[:, "close"].unstack())

histdata = histdata.T
histdata = histdata.loc[histdata.index.year == 2018]
histdata = histdata.loc[histdata.index.month >= 4]
histdata = histdata.loc[histdata.index.month <= 5]
returns = histdata.apply(lambda x: x)#/x[0])
returns.loc[:, ["IXJ", "KXI"]]