2 <h1><%= @position.stock.name %> </h1>
4 <% if @position.is_closed? %>
5 <p><%= @position.comment %></p>
7 <%= form_tag :patch_position, :method=>:POST do %>
8 <%= hidden_field_tag :id, @position.id %>
9 <%= text_field_tag :comment, @position.comment, :size=>50, :placeholder=>'Whats the point of holding it? Until when?' %>
10 <% if @position.comment %>
11 <%= submit_tag 'Update Comment' %>
13 <%= submit_tag 'Set Comment' %>
19 <% if @position.is_closed? and not @position.is_viewed_before_closure? %>
20 <p>Position has been settled on <%= @position.time_closed %>.</p>
23 <tr><td>Purchased Volume</td><td><%= smr_humanize(@position.purchase_volume) %></td></tr>
24 <tr><td>Settled Volume</td><td><%= smr_humanize(@position.settled_volume) %></td></tr>
25 <tr><td>= Profit/Loss</td><td><%= smr_humanize(@position.profit_loss) %> <em><%= percentage_change(@position.purchase_volume, @position.settled_volume)%></em></td></tr>
26 <tr><td>Dividend</td><td><%= smr_humanize(@position.dividend.received) %></td></tr>
27 <tr><td>Charges</td><td><%= smr_humanize(@position.charges) %></td></tr>
28 <tr><td>= Gain</td><td><%= smr_humanize(@position.gain) %> <em><%= percentage_of(@position.purchase_volume, @position.gain) %> </em></td></tr>
30 <% elsif @position.is_new? %>
31 <p>This position is new. You may order something or just close it.</p>
34 Position <% if @position.shares<0 %> is short by <% else %> holds <% end %> <%= smr_humanize(@position.shares) %> shares
35 which are valued at <%= @position.last_quote %> a share.
37 <% if @position.is_closed? %>
38 It will be closed as of <%= @position.time_closed %>.
43 <tr><td>Invested Money</td><td><%= smr_humanize(@position.invested) %></td></tr>
44 <tr><td>Market Value</td><td><%= smr_humanize(@position.market_value) %></td></tr>
45 <tr><td>= Profit/Loss</td><td><%= smr_humanize(@position.profit_loss) %> <em><%= percentage_change(@position.invested, @position.market_value)%></em></td></tr>
46 <tr><td>Dividend</td><td><%= smr_humanize(@position.dividend.received) %></td></tr>
47 <tr><td>Charges</td><td><%= smr_humanize(@position.charges) %></td></tr>
48 <tr><td>= Gain</td><td><%= smr_humanize(@position.gain) %> <em><%= percentage_change(@position.invested, @position.dirty_value) %> </em></td></tr>
52 <% if @position.has_pending_orders? %>
53 <h2>Pending Orders</h2>
59 <th>Issued / Expires</th>
65 <% @position.pending_orders.reverse.each do |o| %>
68 <td><%=o.exchange%></td>
69 <td><%=o.time_issued%> / <%=o.time_expire%></td>
70 <td><%=o.type%> <%= smr_humanize(o.shares) %> shares at <%=o.limit%></td>
72 <%= label_tag 'execute_quote', 'execute at quote:' %>
73 <%= form_tag(controller: 'positions', action: 'execute_order', method: "post") do %>
74 <%= hidden_field_tag 'id_order', o.id %>
75 <%= number_field_tag 'execute_quote', o.limit, {step: 0.0001} %> <%= submit_tag 'Do' %>
77 <%= form_tag(controller: 'positions', action: 'cancel_order', method: "post") do %>
78 <%= hidden_field_tag 'id_order', o.id %>
79 <%= submit_tag 'Cancel this order' %>
88 <% if not @position.is_new? %>
89 <h2>Executed Orders</h2>
94 <th>Exchange / Broker</th>
95 <th colspan="3">Ordered</th>
96 <th>Volume Traded</th>
97 <th>Stock after Trade</th>
98 <th>Profit/Loss by Lot</th>
102 <% @position.revisions.reverse.each do |pr| %>
103 <% next if pr.id_order==0 # skip old-style first emtpy revision %>
105 <td>#<%= pr.id_order %></td>
106 <td><% if not pr.Order.exchange.nil? %><%=pr.Order.exchange%> via <% end %><%=@position.portfolio.name%></td>
107 <td><%=smr_humanize(pr.time) %></td>
108 <td><%=pr.Order.type%> <%=smr_humanize(pr.Order.shares)%> shares at <%=pr.Order.quote%></td>
109 <td><%=pr.Order.status%></td>
110 <td><%=smr_humanize(revision_volume(pr.Order.shares, pr.Order.quote)) %></td>
111 <td><%=smr_humanize(pr.shares) %></td>
112 <td><%=smr_humanize(revision_profitloss(@position.last_quote, pr.Order.shares, pr.Order.quote)) %></td>
119 <% if not @position.is_new? and not @position.dividend.empty? %>
120 <h2>Dividend Log</h2>
130 <% @position.dividend.payments.reverse.each do |d| %>
132 <td><%= smr_humanize(d[:time]) %></td>
133 <td><%= smr_humanize(d[:received]) %> on <%= smr_humanize(d[:shares]) %> shares</td>
134 <td><%= smr_humanize(d[:total]) %></td>