-
-
Save zachlim98/af68eac7acde77f793610f7df3fcb222 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get ticker names | |
stock_list = [driver.find_element(By.CSS_SELECTOR, "#etf_holding_table > tbody:nth-child(2) > tr:nth-child({}) > td:nth-child(2) > a:nth-child(2) > span:nth-child(1)".format(i)).text for i in range(1,51)] | |
#get portfolio weights | |
weight_list = [driver.find_element(By.CSS_SELECTOR, "#etf_holding_table > tbody:nth-child(2) > tr:nth-child({}) > td:nth-child(4)".format(i)).text for i in range(1,51)] | |
#get prices | |
price_list = [round(si.get_live_price(i),2) for i in stock_list] | |
#create dataframe | |
df = pd.DataFrame( | |
{ "Ticker" : stock_list, | |
"Last" : price_list, | |
"Weights" : weight_list | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment