Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 8 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Ada Trader
In this project you will create the Ada Trader platform for real-time stock trading. All trading will happen with fake stocks that represent previous Ada capstone projects, and will be connected to a "real-time" simulation that randomly adjusts the prices for each stock over time.
# Crypto Trader

This is an individual, [stage 2](https://github.com/Ada-Developers-Academy/pedagogy/blob/master/rule-of-three.md) project.
This was a project with the aim of learning more about event handling. Stocks, or in this case cryptocurrencies, are updated every second. You can buy, sell, view your trade history, and set up automatic orders.

![Ada Trader](ada-trader.gif)

## Learning Goals
This project should demonstrate your ability to:
This project should demonstrates the ability to:
- Create Backbone Views of Models
- Create Backbone Views of Collections
- Create multiple Backbone Models that relate to each other
Expand All @@ -15,16 +13,17 @@ This project should demonstrate your ability to:
- Create Model instances from the user input in that form
- Test model logic in a Backbone application

Although real terminology is used throughout this project, and the interface design is intended to loosely mimic real-world trading platforms, having actual trading "domain knowledge" is **NOT** a learning goal. If you're unclear on any of the terminology used in this document please consult the [vocabulary section](#trading-vocabulary) for an explanation, or ask Charles / other instructional staff!

## Setup
### Starting project
To get started with the Ada Trader project follow these steps:
To get started with the Crypto Trader project follow these steps:

1. Fork and clone this repository
1. `cd` into the directory for your cloned project
1. `npm install`
1. `npm start`
```
npm install
npm start
```

### Project Baseline
This project uses the same structure as BackTREK and is based on our [backbone baseline](https://github.com/AdaGold/backbone-baseline). The baseline for this project includes some models and collections that have already been implemented:
Expand Down Expand Up @@ -147,24 +146,3 @@ Additionally, when:
- Each order executes, in the same manner as though the user had clicked "Buy" on the quote
- Each order is removed from the open order list
- Each order will never execute again

### Testing
You should have tests for any validations your models have, as well as any custom functions that you create on those models. **Optional**: Write a test which verifies that limit orders are executed and destroyed when the relevant stock reaches the order's target price.

### Advice
Before you start working on this wave, set aside time with another Adie and make a diagram to explore the flow of events, and make a plan of action. Discuss with that person where the pieces of information currently exist, and how they can flow and propagate to where they need to be.

To get the list of symbols for the order entry form's drop-down, you may need to give the View that controls the form access to the quote collection.

When removing a Backbone View from the page, that does not mean that the associated Model is gone! Be careful when cancelling an order, because an order that isn't shown on the page might still "hear" events that are triggered. You may observe this bug if the trade history continues to update with transactions from "lingering" orders, even if the order is not rendered within the list of open orders.

The rules above for when an order can or cannot be created are a great place to use Backbone's model validation system! Make sure to include tests for those validations as well.

## Trading Vocabulary
| Term | Definition |
|:-----|:-----------|
| Market Order | An order to purchase or sell a particular stock at the "market" price. [More details here.](https://www.investopedia.com/terms/m/marketorder.asp) |
| Limit Order | An order to purchase or sell a particular stock at a trader-specified "target" price. [More details here.](https://www.investopedia.com/terms/l/limitorder.asp) |
| Market Price | The **current** price for a stock, listed with its symbol in the quote ticker. This price will change over time. |
| Target Price | The desired price for a limit order to execute. This price is higher than "market" price if the order is to sell, and it is lower than the "market" price if the order is to buy. This price is fixed for a given order. |
| Trade Price | The price that a stock was traded at (either buy or sell) for a given trade. This price is fixed because it represents an historical event. |
211 changes: 109 additions & 102 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -1,120 +1,127 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ada Trader</title>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed|Rubik+Mono+One">
</head>
<body>
<main id="application" class="content">
<header class="row">
<h1 class="logo">Ada Trader</h1>
</header>

<div class="workspace row">

<div class="columns large-8 small-12">

<div id="quotes-container" class="quotes-container columns small-10 small-offset-1 end">
<h2>Quotes</h2>
<div class="quotes-list-container">
<ul id="quotes" class="quotes">
</ul>
</div>
<head>
<title>Ada Trader</title>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed|Rubik+Mono+One">
</head>
<body>
<main id="application" class="content">
<header class="row">
<h1 class="logo">Crypto Trader</h1>
</header>

<div class="workspace row">

<div class="columns large-8 small-12">

<div id="quotes-container" class="quotes-container columns small-10 small-offset-1 end">
<h2>Quotes</h2>
<div class="quotes-list-container">
<ul id="quotes" class="quotes">
</ul>
</div>

</div>

<div class="columns large-4 small-12 trade-column">
</div>

<div id="trades-container" class="trades-container columns small-10 small-offset-1">
<h2>Trade History</h2>
<div class="trades-list-container">
<ul id="trades" class="trades">
</ul>
</div>
</div>
<div class="columns large-4 small-12 trade-column">

<div id="trades-container" class="trades-container columns small-10 small-offset-1">
<h2>Trade History</h2>
<div class="trades-list-container">
<ul id="trades" class="trades">
</ul>
</div>
</div>

</div>
</div>

<hr />

<hr />

<div id="order-workspace" class="order-workspace row">

<div class="columns large-8 small-12">
<div class="orders-container columns large-10 large-offset-1">
<h2>Open Orders</h2>
<div class="orders-list-container">
<ul id="orders" class="orders">
</ul>
</div>
</div>
</div>

<div class="columns large-4 small-12 trade-column">
<div class="order-entry-form columns small-10 small-offset-1">
<h3>Order Entry Form</h3>
<form>
<label for="symbol">Symbol</label>
<select name="symbol">
<!-- Option entries should be added here using JavaScript -->
</select>
<label for="price-target">Price</label>
<input type="number" name="price-target" step="0.10" min="0.00" placeholder="100.00" />
<label>Action</label>
<button class="btn-buy alert button">Buy</button>
<button class="btn-sell success button">Sell</button>
</form>
<div class="form-errors">
</div>
</div>

</div>
<div id="order-workspace" class="order-workspace row">

<div class="columns large-8 small-12">
<div class="orders-container columns large-10 large-offset-1">
<h2>Open Orders</h2>
<div class="orders-list-container">
<ul id="orders" class="orders">
</ul>
</div>
</div>
</div>
</main>
<footer>
<div class="columns small-12 medium-11 medium-offset-1">
<p class="footer-copy">&copy; 2017, Ada Developers Academy</p>
</div>
</footer>

<script type="text/template" id="quote-template">
<!-- The provided styles assume that you will insert this template
within an element with the class "quote" applied -->
<!-- <li class="quote"> -->
<div class="row small-12 columns">
<h3 class="symbol"><%- symbol %></h3>
<h3 class="price">$<%- price.toFixed(2) %></h3>
<div class="quote-actions">
<button class="btn-buy alert button">Buy</button>
<button class="btn-sell success button">Sell</button>

<div class="columns large-4 small-12 trade-column">
<div class="order-entry-form columns small-10 small-offset-1">
<ul id="status-messages" class="callout primary status-messages columns small-12">

</ul>
<h3>Order Entry Form</h3>
<form id='create-order'>
<label for="symbol">Symbol</label>
<select id= 'dropdown' name="symbol">
<!-- Option entries should be added here using JavaScript -->
</select>
<label for="price-target">Price</label>
<input type="number" name="price-target" step="0.10" min="0.00" placeholder="100.00" />
<label>Action</label>
<button class="btn-buy alert button">Buy</button>
<button class="btn-sell success button">Sell</button>
</form>
<div class="form-errors">
</div>
</div>

</div>
<!-- </li> -->
</script>

<script type="text/template" id="trade-template">
<li class="trade">
<span>
You <%- buy ? 'bought' : 'sold' %> <%- symbol %> at $<%- price.toFixed(2) %>
</span>
</li>
</script>

<script type="text/template" id="order-template">

</div>
</main>
<footer>
<div class="columns small-12 medium-11 medium-offset-1">
<p class="footer-copy">&copy; 2017, Ada Developers Academy</p>
</div>
</footer>

<script type="text/template" id="quote-template">
<!-- The provided styles assume that you will insert this template
within an element with the class "quote" applied -->
<!-- <li class="quote"> -->
<div class="row small-12 columns">
<h3 class="symbol"><%- symbol %></h3>
<div class="detail">
<span class="action"><%- buy ? 'buy' : 'sell' %></span>
at
<span class="price">$<%- targetPrice.toFixed(2) %></span>
<h3 class="price">$<%- price.toFixed(2) %></h3>
<div class="quote-actions">
<button class="btn-buy alert button">Buy</button>
<button class="btn-sell success button">Sell</button>
</div>
<button class="btn-cancel button secondary">Cancel</button>
</script>
</div>
<!-- </li> -->
</script>

<script type="text/template" id="trade-template">
<li class="trade">
<span>
You <%- buy ? 'bought' : 'sold' %> <%- symbol %> at $<%- price.toFixed(2) %>
</span>
</li>
</script>

<script type="text/template" id="order-template">
<h3 class="symbol"><%- symbol %></h3>
<div class="detail">
<span class="action"><%- buy ? 'buy' : 'sell' %></span>
at
<span class="price">$<%- targetPrice.toFixed(2) %></span>
</div>
<button class="btn-cancel button secondary">Cancel</button>
</script>

<script type="text/template" id="dropdown-symbol">
<option class="options" > <%- symbol %></option>
</script>

<script src="/app.bundle.js" charset="utf-8"></script>
</body>
<script src="/app.bundle.js" charset="utf-8"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions spec/collections/market_order_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import MarketOrder from 'collections/market_order';

describe('MarketOrder spec', () => {
let marketOrder;
beforeEach(() => {
marketOrder = new MarketOrder({ });
});

describe('Instantiation', () => {
it('can be instantiated', () => {

expect(marketOrder).toBeTruthy;
expect(marketOrder).toBeDefined;
});
it('must have a model', () =>{
expect(marketOrder.get('model')).toBeDefined;
// expect(marketOrder.get('model')).toEqual(Trade);
});
// it('must be a type of MarketOrder', () =>{
// expect(marketOrder).
// });
});

});
24 changes: 24 additions & 0 deletions spec/collections/quote_list_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import QuoteList from 'collections/quote_list';

describe('QuoteList spec', () => {
let quoteList;
beforeEach(() => {
quoteList = new QuoteList({ });
});

describe('Instantiation', () => {
it('can be instantiated', () => {

expect(quoteList).toBeTruthy;
expect(quoteList).toBeDefined;
});
it('must have a model', () =>{
expect(quoteList.get('model')).toBeDefined;
// expect(marketOrder.get('model')).toEqual(Trade);
});
// it('must be a type of MarketOrder', () =>{
// expect(marketOrder).
// });
});

});
24 changes: 24 additions & 0 deletions spec/models/trade_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Trade from 'models/trade';

describe('Trade spec', () => {
let trade;
beforeEach(() => {
trade = new Trade({

});
});

describe('defaults', () => {
it('has a default buy', () => {
expect(trade.get('buy')).toBeTruthy;
});
it('has a default price', () => {
expect(trade.get('buy')).toBeTruthy;
});
it('has a default symbol', () => {
expect(trade.get('buy')).toBeTruthy;
});
});


});
Loading