{% load portfolio_tags %}
{% load mathfilters %}
<style>
.fixed {
    width: 700px;
}
</style>
<p>Please find bellow the rebalancing summary that the system automatically detected</p>
</br>
<p>We detected {{map_rebalancing|length}} rebalanced equity that day.</p>
{% for equity_repr, report_dict in map_rebalancing.items %}
<p><b>{{ equity_repr }}</b></p>
<table style="width: 100%; border-collapse: collapse; table-layout: fixed;">
    <colgroup>
        <col span="1" style="width: 85%;text-align: left;">
        <col span="1" style="width: 15%;">
    </colgroup>
    <tr>
        <th style="text-align: left;">Product</th>
        <th>Weight Δ</th>
    </tr>
    {% for product_repr, value in report_dict.items %}
    <tr>
        {% if value|abs <= rebalancing_threshold %}
        <td style="background-color: rgb(241, 72, 50)">{{ product_repr }}</td>
        <td style="background-color: rgb(241, 72, 50)">{{ value|percent_filter:3 }}</td>
        {% else %}
        <td style="background-color: rgb(110, 207, 20)">{{ product_repr }}</td>
        <td style="background-color: rgb(110, 207, 20)">{{ value|percent_filter:3 }}</td>
        {% endif %}
    </tr>
    {% endfor %}
</table>
{% endfor %}
