Calculating BIST Index in USD
To calculate historical BIST values in USD, get those data seperately first.
from yahoo_fin.stock_info import get_data
import pandas as pd
import matplotlib.pyplot as plt
start_date = "31/10/1997" # begging of index
end_date = "30/06/2022"
bist = get_data('XU100.IS',
start_date, end_date,
index_as_date = True, interval = "1d")
usd_try = get_data('TRY=X',
start_date, end_date,
index_as_date = True, interval = "1d")
BIST index needs some adjustment:
# index dropped zeros at 2020-07-27
bist.loc['2020-07-27':,'adjclose'] = bist.loc['2020-07-27':,'adjclose']*100
Combine two dataframes in a signle one and simply divide the index by usd:
bist_usd = pd.concat([usd_try['adjclose'], bist['adjclose']], axis=1)
bist_usd.dropna(inplace=True) # yahoo usd_try goes back to 2005
bist_usd.columns = ['usd','bist']
bist_usd['bist_usd'] = bist_usd['bist'] / bist_usd['usd']
Here's the resulting data visualized:
bist_usd['bist_usd'].plot()
plt.title('BIST 100 index in USD')
plt.ylabel('Price (USD)')
plt.xlabel('Date')
plt.show()