If you’re not quite sure what it means to buy and sell stocks (i.e., shares of a company), head here for a tutorial.

You’re about to implement C$50 Finance, a web app via which you can manage portfolios of stocks. Not only will this tool allow you to check real stocks’ actual prices and portfolios’ values, it will also let you buy (okay, “buy”) and sell (okay, “sell”) stocks by querying IEX for stocks’ prices.

Indeed, IEX lets you download stock quotes via their API (application programming interface) using URLs like Notice how Netflix’s symbol (NFLX) is embedded in this URL; that’s how IEX knows whose data to return. That link won’t actually return any data because IEX requires you to use an API key (more about that in a bit), but if it did, you’d see a response in JSON (JavaScript Object Notation) format like this:

{ "symbol": "NFLX",

"companyName": "Netflix, Inc.",

"primaryExchange": "NASDAQ",

"calculationPrice": "close",

"open": 317.49,

"openTime": 1564752600327,

"close": 318.83,

"closeTime": 1564776000616,

"high": 319.41,

"low": 311.8,

"latestPrice": 318.83,

"latestSource": "Close",

"latestTime": "August 2, 2019",

"latestUpdate": 1564776000616,

"latestVolume": 6232279,

"iexRealtimePrice": null,

"iexRealtimeSize": null,

"iexLastUpdated": null,

"delayedPrice": 318.83,

"delayedPriceTime": 1564776000616,

"extendedPrice": 319.37,

"extendedChange": 0.54,

"extendedChangePercent": 0.00169,

"extendedPriceTime": 1564876784244,

"previousClose": 319.5,

"previousVolume": 6563156,

"change": -0.67,

"changePercent": -0.0021,

"volume": 6232279,

"iexMarketPercent": null,

"iexVolume": null,

"avgTotalVolume": 7998833,

"iexBidPrice": null,

"iexBidSize": null,

"iexAskPrice": null,

"iexAskSize": null,

"marketCap": 139594933050,

"peRatio": 120.77,

"week52High": 386.79,

"week52Low": 231.23,

"ytdChange": 0.18907500000000002,

"lastTradeTime": 1564776000616 }

Notice how, between the curly braces, there’s a comma-separated list of key-value pairs, with a colon separating each key from its value.

Let’s turn our attention now to this problem’s distribution code!



$ wget

$ unzip

$ rm

$ cd finance

$ ls static/

finance.db requirements.txt templates/



Before getting started on this assignment, we’ll need to register for an API key in order to be able to query IEX’s data. To do so, follow these steps:

  • Visit

  • Enter your email address and a password, and click “Create account”.

  • On the next page, scroll down to choose the Start (free) plan.

  • Once you’ve confirmed your account via a confirmation email, sign in to

  • Click API Tokens.

  • Copy the key that appears under the Token column (it should begin with pk_).

  • In a terminal window within CS50 IDE, execute: 

$ export API_KEY=value

where value is that (pasted) value, without any space immediately before or after the =. You also may wish to paste that value in a text document somewhere, in case you need it again later.


More Detail go to link: