manage bookmarks, bugfixes
[smr.git] / gui / app / views / watchlist / index.html.erb
blobfd0893da40c58a463cc6afec7b81aa142a0af7ef
2 <h1>Watchlist</h1>
4 <% if @quote %>
5     <%= render :partial=>'asset/quote_form', locals: { :quote=>@quote, :securities=>@securities  } %>
6 <% end %>
8 <%= search_form_for @watchlist.query, :url=>{:controller=>:watchlist, :action=>:index}, :class=>'filter_form, watchlist_filter', :id=>:controller_filter do |f| %>
9 <div>
10     <%= f.search_field :symbol_or_brief_or_Organization_name_cont_any, :placeholder=>'Pattern' %>
11     <%= f.submit :filter %>
13  <table>
14     <tr><th colspan="2">Generic Filters</th></tr>
15     <tr><td><%= check_box_tag :exclude_securities, true, @opt_exclude_securities %></td><td><%= f.label :exclude_held_securities %></td></tr>
17     <tr><td><%= check_box_tag :provides_collateral, true, @opt_provides_collateral %></td><td><%= f.label :provides_collateral %></td></tr>
19     <tr><td><%= check_box_tag :provides_cashflow, true, @opt_provides_cashflow %></td><td><%= f.label :provides_cashflow_this_year %></td></tr>
21     <tr><td><%= check_box_tag :provides_huge_coupon, true, @opt_provides_huge_coupon %></td><td><%= f.label :provides_huge_coupon %></td></tr>
23     <tr><td><%= check_box_tag :provides_subannual_payments, true, @opt_provides_subannual_payments %></td><td><%= f.label :provides_subannual_payments %></td></tr>
25     <tr><td><%= check_box_tag :matures_within_year, true, @opt_matures_within_year %></td><td><%= f.label :matures_within_year %></td></tr>
27     <tr><th colspan="2">Type of Security</th></tr>
28     <% Security.types.each do |t|
29        type_id_column = ('id_security_%s_gt' % t).to_sym
30        %>
31        <tr><td><%= check_box_tag 'q[%s]' % type_id_column,
32               0,
33               (if params[:q] and params[:q][type_id_column] then true else false end)
34        %></td><td>
35        <%= label_tag 'q[%s][]' % type_id_column, Security.describe_type(t) %></td></tr>
36     <% end %>
38     <tr><th colspan="2">Bond Properties</th></tr>
39     <% SecurityBond.types.each do |t| %>
40        <tr><td><%= check_box_tag 'q[SecurityBond_type_eq_any][]',
41               t.second,
42               (if params[:q] and params[:q][:SecurityBond_type_eq_any] and params[:q][:SecurityBond_type_eq_any].include?(t.second.to_s) then true else false end)
43        %></td><td>
44        <%= label_tag 'q[SecurityBond_type_eq_any][]', SecurityBond.describe_type(t.first) %></td></tr>
45     <% end %>
47     <tr><th colspan="2">Stock Properties</th></tr>
48     <% SecurityStock.types.each do |t| %>
49        <tr><td><%= check_box_tag 'q[SecurityStock_type_eq_any][]',
50               t.second,
51               (if params[:q] and params[:q][:SecurityStock_type_eq_any] and params[:q][:SecurityStock_type_eq_any].include?(t.second.to_s) then true else false end)
52        %></td><td>
53        <%= label_tag 'q[SecurityStock_type_eq_any][]', SecurityStock.describe_type(t.first) %></td></tr>
54     <% end %>
55  </table>
56 </div>
57 <% end %>
59 <div id='watchlist_overview' class="overview_counters">
60   <ul>
61     <li>Items Found: <span><%= @watchlist.count %></span></li>
62   </ul>
63 </div>
65 <table id='watchlist'>
66   <thead>
67     <tr>
68     </tr>
69     <tr>
70         <th></th>
71         <th>Exchange</th>
72         <th>Low / High</th>
73         <th>Volume</th>
74         <th>Last Trade</th>
75         <th><%= sort_link @watchlist.query, :current_yield, 'CY', default_order: :desc %></th>
76         <th><%= sort_link @watchlist.query, :yield_to_maturity, 'YTM', default_order: :desc %></th>
77         <th><%= sort_link @watchlist.query, :yield_to_call, 'YTC', default_order: :desc %></th>
78         <th><%= sort_link @watchlist.query, :cashflow_this_year, 'Cashflow this Year', default_order: :desc %></th>
79         <th><%= sort_link @watchlist.query, :collateral_coverage_ratio, 'Collateral Provided', default_order: :desc %></th>
80     </tr>
81   </thead>
82   <tbody>
83   <% @watchlist.each do |i| %>
84     <tr class="separaterows">
85       <td>
86         <%= link_to '+', watchlist_index_path(:intraday_data=>i.id, :anchor=>"watchlist_id#{i.id}"), :id=>"watchlist_id#{i.id}" %>
87         <%= link_to '...', i.security.link.to_url %>
88         <%= i.security %>
89         <span class="symbol"><%=i.security.symbol%></span>
90       </td>
91       <td><%= i.quote.exchange %></td>
92           <td>
93             <% if i.quote.low or i.quote.high %>
94                 <%= smr_humanize(i.quote.low) %> / <%= smr_humanize(i.quote.high) %>
95             <% end %>
96           </td>
97       <td><%= smr_humanize(i.quote.volume, :shortword=>true)%></td>
98       <td><%= smr_humanize i.quote.last %> <span class="<%= i.quote.css_class(smr_browse_date(:keep_current_time=>true), :intraday=>true) %>">&bull;</span></td>
99       <td><%= smr_humanize(i.security.current_yield(i.quote), :scale=>2)%></td>
100       <td><%= smr_humanize(i.security.yield_to_maturity(i.quote), :scale=>2)%></td>
101       <td><%= smr_humanize(i.security.yield_to_call(i.quote), :scale=>2)%></td>
102       <td><%= smr_humanize(i.security.cashflow_this_year smr_browse_date)%></td>
103       <td><%= smr_humanize i.security.collateral_coverage_ratio %></td>
104     </tr>
105    <% if @have_intraday_data == i.id %>
106      <%
107       _have_shown_cashflow = false
108       @intraday_data.each do |q| %>
109        <tr class="have_intraday_data">
110           <td><%= smr_humanize(q.time, :date_time_only=>true) %></td>
111           <td><%= q.exchange %></td>
112           <td>
113             <% if q.low or q.high %>
114                 <%= smr_humanize(q.low) %> / <%= smr_humanize(q.high) %>
115             <% end %>
116           </td>
117           <td><%= smr_humanize q.volume, :shortword=>true %></td>
118           <td><%= smr_humanize q.last %>&nbsp;&nbsp;</td>
119           <td><%= smr_humanize i.security.current_yield(q), :scale=>2 %></td>
120           <td><%= smr_humanize i.security.yield_to_maturity(q),:scale=>2 %></td>
121         <% unless _have_shown_cashflow %>
122           <td rowspan="<%= @intraday_data.count  %>">
123             <div class="overview_container">
124             <table id="overview_cashflow">
125              <tbody>
126               <% i.security.cashflow(:start_date=>smr_browse_date).each  do |c| %>
127                 <tr>
128                     <td><%= smr_humanize c.date %></td>
129                     <td><%= smr_humanize c.total, :scale=>2 %>
130                        <% unless [0, 1.0].include? c.poolfactor %><span>pf=<%= smr_humanize c.poolfactor, :scale=>3 %></span><% end %>
131                     </td>
132                 </tr>
133               <% _have_shown_cashflow = true
134                end %>
135              </tbody>
136             </table>
137             </div>
138           </td>
139         <% end %>
140        </tr>
141      <% end %>
142    <% end %>
143   <% end %>
144   </tbody>
145 </table>