forked from destenson/etheropt--etheropt.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
/
market.ejs
34 lines (34 loc) · 2.68 KB
/
market.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<% expiration_pairs = options.map(function(x){return x.expiration+" "+x.fromcur+"/"+x.tocur}).getUnique() %>
<table class="table table-hover">
<% expiration_pairs.forEach(function(expiration_pair) { %>
<tr>
<th>Option</th>
<th>Best bid</th>
<th>Best offer</th>
<th>My position</th>
</tr>
<% filtered_options = options.filter(function(x){return x.expiration+" "+x.fromcur+"/"+x.tocur==expiration_pair}) %>
<tr>
<td><strong><%= expiration_pair %> <br />(margin requirement: <%= filtered_options[0].margin %>)</strong></td>
<td></td>
<td></td>
<td>Cash: <%= bundle.utility.weiToEth(filtered_options[0].cash) %> eth</td>
</tr>
<% filtered_options.forEach(function(option){ %>
<tr>
<td><%= option.strike %> <%= option.kind %></td>
<td>
<%= option.buy_orders && option.buy_orders.length>0 ? bundle.utility.roundTo(option.buy_orders[0].price,4)+" ("+bundle.utility.weiToEth(option.buy_orders[0].size)+" eth)" : "N/A" %>
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#sell_modal" data-price="<%= option.buy_orders && option.buy_orders.length>0 ? bundle.utility.roundTo(option.buy_orders[0].price,4) : "" %>" data-size="<%= option.buy_orders && option.buy_orders.length>0 ? bundle.utility.weiToEth(option.buy_orders[0].size) : "" %>" data-description="<%= option.expiration+" "+option.fromcur+"/"+option.tocur+" "+option.strike+" "+option.kind %>" data-option='<%= JSON.stringify(option) %>' data-order='<%= option.buy_orders && option.buy_orders.length>0 ? JSON.stringify(option.buy_orders[0].order) : '' %>'>Sell</button>
</td>
<td>
<%= option.sell_orders && option.sell_orders.length>0 ? bundle.utility.roundTo(option.sell_orders[0].price,4)+" ("+bundle.utility.weiToEth(option.sell_orders[0].size)+" eth)" : "N/A" %>
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#buy_modal" data-price="<%= option.sell_orders && option.sell_orders.length>0 ? bundle.utility.roundTo(option.sell_orders[0].price,4) : "" %>" data-size="<%= option.sell_orders && option.sell_orders.length>0 ? bundle.utility.weiToEth(option.sell_orders[0].size) : "" %>" data-description="<%= option.expiration+" "+option.fromcur+"/"+option.tocur+" "+option.strike+" "+option.kind %>" data-option='<%= JSON.stringify(option) %>' data-order='<%= option.sell_orders && option.sell_orders.length>0 ? JSON.stringify(option.sell_orders[0].order) : '' %>'>Buy</button>
</td>
<td>
<%= bundle.utility.weiToEth(option.position) %> eth
</td>
</tr>
<% }); %>
<% }); %>
</table>