Skip to content

Instantly share code, notes, and snippets.

@zachlim98
Last active November 18, 2020 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachlim98/af68eac7acde77f793610f7df3fcb222 to your computer and use it in GitHub Desktop.
Save zachlim98/af68eac7acde77f793610f7df3fcb222 to your computer and use it in GitHub Desktop.
#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