Backbone application for simulated trading with real-time stock quotes for Ada capstone projects.
To get started with the Ada Trader project follow these steps:
- Fork and clone this repository
cdinto the directory for your cloned projectnpm installnpm start
You should use the following files when building your application:
| File | Purpose |
|---|---|
src/app/views/application_view.js |
Overall "container" for the entire application, similar to TaskListView in the live code. |
src/app/views/quote_view.js |
View for an individual quote. |
src/app.js |
Main entry-point of the application. |
build/index.html |
Static HTML & Underscore template script for the quote view. |
In this wave we will build our first Backbone view, which will display the name (known as a symbol) and price for a single stock. In order to achieve this your application should:
- Have a
QuoteViewclass extended fromBackbone.View(insrc/app/views/quote_view.js). - The
QuoteViewshould:
- Have an
initializefunction that should:- Receive and store a JavaScript object with quote data (
symbolandprice). See Example Stocks for inspiration. - Compile an Underscore template using the script named
tmpl-quote-view(which is already defined inindex.html).
- Receive and store a JavaScript object with quote data (
- Have a
renderfunction that should:- Use the compiled template to render HTML for a single quote, using the quote data stored by
initialize.
- Use the compiled template to render HTML for a single quote, using the quote data stored by
In this wave we will create a second Backbone view, ApplicationView, which is responsible for displaying our entire web application. It will manage a list of QuoteView instances and render each of them. In order to achieve this your application should:
- Have an
ApplicationViewclass extended fromBackbone.View(insrc/app/views/application_view.js). - The
ApplicationViewshould:
- Have an
initializefunction that should:- Receive and store a list of quote data objects.
- Compile the same Underscore template from Wave 1. This compiled template will replace the one used in
QuoteViewduring Wave 1. - Create and store a list of at least two
QuoteViewinstances. Each instance should be given:- The data for a single quote.
- The compiled Underscore template from the above step.
- Store the HTML unordered list element from
index.htmlthat will contain the list of renderedquotes.
- Have a
renderfunction that should:- Render each
QuoteViewinstance in the list created withininitialize. - Use the stored HTML unordered list element.
- Append to that element the jQuery object for each
QuoteViewinstance we rendered.
- Render each
In this wave we will extend our QuoteView class to support clicking on the Buy and Sell buttons for each quote. In order to achieve this your application should be updated so that:
- The
QuoteViewclass should:
- Have an
eventsproperty that defines two handlers for theclickevent, one for eachbuttonin the quote template. - Have a function that runs when the
clickevent happens on the buy button. This function should:- Increase the stock's price by a fixed amount (say, $1.00).
- Re-render the view so that the new price is displayed to the user.
- Have a function that runs when the
clickevent happens on the sell button. This function should:- Decrease the stocks' price by a fixed amount (say, $1.00).
- Re-render the view so that the new price is displayed to the user.
The optional enhancement for this wave is to implement a simulation of the broader stock market. To make this simulation as true-to-life as possible, we'll be randomly moving the stock price up or down by a small amount, once per second. In order to achieve this your application should be updated so that:
- The
QuoteViewclass should:
- Setup an event listener for a custom event named
change:price. This should be done in theinitializefunction. - Have a function that runs when the
change:priceevent happens. This function should:- Expect that a
changeparameter will be passed into it. - Expect that the
changeparameter will be a number, positive OR negative. - Add the
changeparameter onto the current stock price. - Re-render the view so that the new price is displayed to the user.
- Expect that a
- The application entry-point (
src/app.js) should:
- Implement the anonymous function passed to
setInterval. It should:- Get the list of all
QuoteViewinstances from theApplicationView. - Call the
simulatefunction on each of thoseQuoteViewinstances.
- Get the list of all
- Add buy/sell buttons to the
ApplicationViewwhich buy or sell all stocks at once. Yay diversification! - Deal with the case of a stock price reaching zero or negative values.
- Symbol:
HUMOR, Price: $88.50 - Cristal's HumorUs capstone - Symbol:
CLOTH, Price: $81.70 - Sophia's Cloth Sim capstone - Symbol:
HABIT, Price: $98.00 - Val's Habitmon capstone - Symbol:
SUPER, Price: $83.10 - Rowan's Super Hero Draft capstone - Symbol:
INGRD, Price: $79.40 - Nicole's Ingredient Inspector capstone - Symbol:
MXTPE, Price: $109.20 - Jess's Digital Mixtape capstone - Symbol:
CNTAR, Price: $90.70 - Leah's Centaur capstone - Symbol:
EVCLR, Price: $101.90 - Lisa's Evolution In Color capstone - Symbol:
FUZZY, Price: $88.60 - Jade's Fuzz Therapy capstone