Skip to content

Instantly share code, notes, and snippets.

@quantra-go-algo
Last active October 20, 2022 05:35
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 quantra-go-algo/62607b3c7b7352de3b8ac1b4bd069e88 to your computer and use it in GitHub Desktop.
Save quantra-go-algo/62607b3c7b7352de3b8ac1b4bd069e88 to your computer and use it in GitHub Desktop.
Get price to book
# get price to book
pb = msft.info['priceToBook']
pe = msft.info['regularMarketPrice']/msft.info['trailingEps']
print('Price to Book Ratio is: %.2f' % pb)
print('Price to Earnings Ratio is: %.2f' % pe)
@matandalfcar
Copy link

get price to book

pb = msft.info['priceToBook']
pe = msft.info['regularMarketPrice']/msft.info['epsTrailingTwelveMonths']
print('Price to Book Ratio is: %.2f' % pb)
print('Price to Earnings Ratio is: %.2f' % pe)

KeyError: 'epsTrailingTwelveMonths'

@quantra-go-algo
Copy link
Author

@matandalfcar Thanks for pointing this out! We have updated the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment