This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<td> <span class="badge badge-inverse"><%=st%></span></td> | |
<td><a class="btn btn-primary btn-mini trade-button"><strong><div id="<%=st%>b5p"><%=b5p%></div></strong><div id="<%=st%>b5v"><%=b5v%></div></a></td> | |
<td><a class="btn btn-primary btn-mini trade-button"><strong><div id="<%=st%>b4p"><%=b4p%></div></strong><div id="<%=st%>b4v"><%=b4v%></div></a></td> | |
<td><a class="btn btn-primary btn-mini trade-button"><strong><div id="<%=st%>b3p"><%=b3p%></div></strong><div id="<%=st%>b3v"><%=b3v%></div></a></td> | |
<td><a class="btn btn-primary btn-mini trade-button"><strong><div id="<%=st%>b2p"><%=b2p%></div></strong><div id="<%=st%>b2v"><%=b2v%></div></a></td> | |
<td><a class="btn btn-primary btn-mini trade-button"><strong><div id="<%=st%>b1p"><%=b1p%></div></strong><div id="<%=st%>b1v"><%=b1v%></div></a></td> | |
<td><a class="btn btn-success btn-mini trade-button"><strong><div id="<%=st%>tp"><%=tp%> </div></strong><div id="<%=st%>tv"><%=tv%></div></a></td> | |
<td><a class="btn btn-danger btn-mini trade-button"><strong><div id= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table class="table table-bordered table-condensed"> | |
<thead> | |
<tr> | |
<th>Stock</th> | |
<th>BID5</th> | |
<th>BID4</th> | |
<th>BID3</th> | |
<th>BID2</th> | |
<th>BID1</th> | |
<th>Trade</th> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> | |
<script src="http://code.highcharts.com/stock/highstock.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
$(function() { | |
$.getJSON('/api/trades', function(data) { | |
// create the chart | |
chart = new Highcharts.StockChart({ | |
chart : { | |
renderTo : 'container' | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getDisplay: function(exchangeData) { | |
var options = {max: true}; | |
var buyPrices = createBinaryHeap(options); | |
var sellPrices = createBinaryHeap(options); | |
var buys = exchangeData.buys; | |
var sells = exchangeData.sells; | |
if (sells) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var exchange = require('./exchange'); | |
module.exports = BinaryHeap; | |
function BinaryHeap(scoreFunction, options){ | |
this.content = []; | |
if (options) | |
this.options = options; | |
else | |
this.options = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createExchange(exchangeData) { | |
function init(exchange, orderType) { | |
if (!exchange[orderType]) { | |
exchange[orderType] = {}; | |
exchange[orderType].volumes = {}; | |
exchange[orderType].prices = createBinaryHeap(); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var $ = require('jquery') | |
, BinaryHeap = require('./BinaryHeap'); | |
var BUY = "buys", SELL = "sells"; | |
function createBinaryHeap() { | |
return new BinaryHeap(function(x){return x;}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = BinaryHeap; | |
function BinaryHeap(scoreFunction){ | |
this.content = []; | |
this.scoreFunction = scoreFunction; | |
} | |
BinaryHeap.prototype = { | |
peek: function() { |