manage bookmarks, bugfixes
[smr.git] / gui / app / views / portrait / _security_quote.html.erb
blobb7f1cfc250ab16332d5392c19c247f6f70869a80
3 <%
4  ##
5  # provide locals: :security [ :smr_position ]
6  smr_position = false unless smr_position
7  type = if security.has_type_model? then security.get_type else false end
9  quote_date = if smr_position then
10     smr_position.date
11  elsif smr_browse_date
12     smr_browse_date
13  else Time.now end
15  last_trade = security.last_quote quote_date
17  # yields
18  cy_s = security.current_yield(last_trade)
19  cy_p = if smr_position then
20     security.current_yield(Quote.new :last=>smr_position.cost_price, :date_last=>smr_position.date.to_i)
21  else false end
23  ytc_s = security.yield_to_call(last_trade)
24  ytc_p = if smr_position then
25     security.yield_to_call(Quote.new :last=>smr_position.cost_price, :date_last=>smr_position.date.to_i)
26  else false end
28  ytm_s = security.yield_to_maturity(last_trade)
29  ytm_p = if smr_position then
30     security.yield_to_maturity(Quote.new :last=>smr_position.cost_price, :date_last=>smr_position.date.to_i)
31  else false end
34 <div class="overview_container">
35 <table id="security_quote">
36   <thead>
37     <tr><th colspan="2">Last Trade</th></tr>
38   </thead>
39   <tbody>
40     <tr>
41         <td>Price</td>
42         <td><%= last_trade.last %> <span><%= smr_humanize last_trade.time_last, :date_with_time=>true %></span></td></tr>
43     </tr>
45     <% if last_trade.volume.to_i.abs != 0 %><tr><td>Volume</td><td><%= smr_humanize last_trade.volume, :shortword=>true %></td></tr><% end %>
46     <% if last_trade.low.to_i.abs != 0 %><tr><td>Day Low</td><td><%= last_trade.low %></td></tr><% end %>
47     <% if last_trade.high.to_i.abs != 0 %><tr><td>Day High</td><td><%= last_trade.high %></td></tr><% end %>
49     <tr><td>Exchange</td><td><%= last_trade.exchange %></td></tr>
50     <tr><td>Accrued Interest</td><td><%= smr_humanize security.accrued_interest %></td></tr>
51     <tr><td>Dirty Price</td><td><%= smr_humanize(last_trade.last + security.accrued_interest.to_f) %></td></tr>
52     <tr>
53         <td>
54          <%= case security.type
55              when :stock then 'Dividend Yield'
56              when :fund  then 'Distribution Yield'
57              else 'Current Yield'
58          end %>
59         </td>
60         <td>
61           <div>on security <span><%=smr_humanize cy_s, :scale=>2 %></span></div>
62          <% if cy_p %>
63           <div>on position <span><%=smr_humanize cy_p, :scale=>2 %></span></div>
64          <% end %>
65        </td>
66     </tr>
67     <tr style="<%= unless ytc_s or ytc_p then 'display:none' else '' end %>">
68         <td>Yield to Call</td>
69         <td>
70           <div>on security <span><%=smr_humanize ytc_s, :scale=>2 %></span></div>
71          <% if ytc_p %>
72           <div>on position <span><%=smr_humanize ytc_p, :scale=>2 %></span></div>
73          <% end %>
74         </td>
75     </tr>
76     <tr style="<%= unless ytm_s or ytm_p then 'display:none' else '' end %>">
77         <td>Yield to Maturity</td>
78         <td>
79           <div>on security <span><%=smr_humanize ytm_s, :scale=>2 %></span></div>
80          <% if smr_position %>
81           <div>on position <span><%=smr_humanize ytm_p, :scale=>2 %></span></div>
82          <% end %>
83         </td>
84     </tr>
85   </tbody>
86 </table>
87 </div>