Benzinga Exchange Code Challenge

Create a simple stock exchange and show us what you're made of!

Introduction

Everything we do at Benzinga revolves around finance and the stock market. The core of the stock market is an exchange where people can buy and sell shares of stock that they own. For this code challenge, we would like you to use our live stock exchange data API to create a simple stock portfolio simulator. This project should be built using a web friendly language and the frontend interface should be built in HTML/CSS.

Provide us with a publicly accessible URL to access your application once you have it completed. For ease of development, we'd suggest pushing to a free Heroku instance, however, you're free to use what ever method for deployment you see fit. Also note that this project doesn't require knowledge of any advanced finance concepts.

Please host your code in a private git repository, and send us a link to it so that we may review it. GitLab and Bitbucket are examples of sites that offer the ability to create private git repositories for free. We prefer GitHub internally, but please do not use it for this challenge unless you have the ability to create a private repository.

How an Exchange Works

A live order book for the symbol QQQQ

The exchange of stock occurs by matching up prices in something called an order book. An order book displays the current bidding and asking prices for shares of a particular stock. In the actual stock market, there will also be a bid size and an ask size that shows how many shares of stock are available at that particular price. Real order books also show a list of all the stock exchanges that have bid/asks for shares of stock.

In the order book on the right, the left side is the current market depth for bids and the right side is the depth for asks. Right now, the best bid price for the symbol QQQQ is 38.08 and there are a total of 287 shares available at this price on the BRUT, SIZE, TRAC, and ETRD exchanges. If you were to sell 290 shares of QQQQ, 287 of these shares would be sold at 38.08 and 3 shares would be sold at 38.07.

It's important to remember that the bid price is the price at which shares can currently be sold and the ask price is the price is the price at which shares can currently be bought.

The bids and asks in an order book are from people who have placed limit orders. For a bid this means that the person selling this shares has specified that this is the lowest possible price at which they are willing to sell shares. As we will be buying off the bid and the ask, we are effectively placing something called a market order.

A market order is just an order that says give me the best possible price for buying or selling this stock and execute this trade right away. Unlike a limit order, there is no set price or "limit" to buy or sell at for a market order and you are buying off the bid and ask so they don't appear in the order book.

Project Details

Example mockup for the front-end display of the project

For this challenge, you will be creating a simple portfolio system that allows a user to buy and sell stock according to the the top bid and ask in the order book. When a user lands on the page they will be given $100,000.00 in cash to create their portfolio with (this can just be stored in a cookie or session). They will be able to lookup stocks by symbol and then buy shares of that particular stock at the current ask price. Once bought, stocks will appear in their portfolio and the total cost of the trade will be deducted from their cash balance. When they sell shares, the shares will be sold at the current bid price and the quantity sold will be taken out of their portfolio (removed completely if all shares sold) and the total amount from the sale will be added to their cash balance.

The only required external connection is for our stock data API. Below we provide you with the endpoint for the REST API that you will use to pull down the bid and ask for a symbol as JSON. If a symbol is not found, an error will be returned and you should display to users on your frontend that the symbol they requested was not found.

We will not be taking the bid and ask sizes into effect and instead will be assuming that there are an infinite amount of shares available at the current bid and ask prices. Users should be prevented from placing trades that would cause their total cash balance to go negative. Users should not be allowed to sell more shares than the currently have available in their portfolio (For those familliar with shorting, this challenge is only for long stock trades).

The way the completed project actually functions is entirely up to you. You could build out the interface with a Javascript MVC and use websockets for exchanging data or you could just use simple HTML pages with standard POST and GET requests. You should treat this challenge as a chance to showcase your knowledge and expertise. If you don't know anything about websockets, we don't want you to spend 8 hours hacking together a solution that will work with that. We'd much rather see you complete this challenge quickly and effeciently using the skillset you know best.

Project Requirements

Project Resources

All data for the bid/ask/company name can be pulled down as JSON using this endpoint: http://careers-data.benzinga.com/rest/richquote?symbols=<symbol>

Examples

"Code wins arguments" - Mark Zuckerberg