'Create dictionary with tickers as keys and values as stock prices
Is there a better way to achieve what the code below does? The list 'tickers' is a combination of stock tickers (e.g. AAPL, IBM)
list1 = tickers
list2 = []
dct = {}
count = 0
for i in tickers:
list2.extend(yf.Ticker(i).history(period='7d')['Close'])
dct[i] = list2[count:]
count+=7
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
