Equity curve · {{ year }}(realized · YTD)
{% if points|length <= 1 %}
No realized activity in {{ year }}.
{% else %} {% set max_v = points|map(attribute='cumulative_realized')|map('float')|max %} {% set min_v = points|map(attribute='cumulative_realized')|map('float')|min %} {# Include the present-day unrealized in the y-extent so the dot fits on screen. #} {% if points[-1].unrealized is not none %} {% set with_unr = (points[-1].cumulative_realized|float + points[-1].unrealized|float) %} {% if with_unr > max_v %}{% set max_v = with_unr %}{% endif %} {% if with_unr < min_v %}{% set min_v = with_unr %}{% endif %} {% endif %} {# Pad the y-extent by 8% so the line/dot don't kiss the edge. Always include zero. #} {% if min_v > 0 %}{% set min_v = 0 %}{% endif %} {% if max_v < 0 %}{% set max_v = 0 %}{% endif %} {% set raw_span = max_v - min_v %} {% if raw_span <= 0 %}{% set raw_span = 1.0 %}{% endif %} {% set pad = raw_span * 0.08 %} {% set y_min = min_v - pad %} {% set y_max = max_v + pad %} {% set y_span = y_max - y_min %} {# SVG geometry. Padding leaves room for axis labels. #} {% set vw = 320 %} {% set vh = 160 %} {% set pl = 44 %}{# left axis label gutter #} {% set pr = 8 %} {% set pt = 8 %} {% set pb = 18 %}{# bottom month-axis gutter #} {% set iw = vw - pl - pr %} {% set ih = vh - pt - pb %} {% set y_ticks = [0, 0.25, 0.5, 0.75, 1.0] %} {# Y gridlines + labels #} {% for t in y_ticks %} {% set yval = y_max - t * y_span %} {% set yp = pt + t * ih %} {% if yval >= 0 %}+{% else %}−{% endif %}${{ "{:,.0f}".format(yval|abs) }} {% endfor %} {# X-axis month ticks: position by day-of-year so partial year is honored. #} {% set last_doy = (points[-1].on - points[-1].on.replace(month=1, day=1)).days %} {% if last_doy < 1 %}{% set last_doy = 1 %}{% endif %} {% set months = [(1, 'Jan'), (2, 'Feb'), (3, 'Mar'), (4, 'Apr'), (5, 'May'), (6, 'Jun'), (7, 'Jul'), (8, 'Aug'), (9, 'Sep'), (10, 'Oct'), (11, 'Nov'), (12, 'Dec')] %} {% for m, lbl in months %} {% set m_doy = ((m - 1) * 30.4)|round(0, 'floor')|int %} {% if m_doy <= last_doy %} {% set xp = pl + (m_doy / last_doy) * iw %} {{ lbl }} {% endif %} {% endfor %} {# Axis baselines #} {# Polyline of cumulative realized #} {# Sell event dots (skip first synthetic Jan-1 zero point) #} {% for p in points %} {% if loop.index0 > 0 and (loop.last == false or points[-1].unrealized is none) %} {% set p_doy = (p.on - p.on.replace(month=1, day=1)).days %} {% set x = pl + (p_doy / last_doy) * iw %} {% set y = pt + ((y_max - p.cumulative_realized|float) / y_span) * ih %} {{ p.on.isoformat() }} · cumulative {% if p.cumulative_realized|float >= 0 %}+{% else %}−{% endif %}${{ "{:,.2f}".format(p.cumulative_realized|float|abs) }} {% endif %} {% endfor %} {# Present-day "+ unrealized" dot #} {% set last = points[-1] %} {% if last.unrealized is not none %} {% set last_doy = (last.on - last.on.replace(month=1, day=1)).days %} {% set last_x = pl + (last_doy / last_doy) * iw %} {% set last_total = last.cumulative_realized|float + last.unrealized|float %} {% set last_y = pt + ((y_max - last_total) / y_span) * ih %} {% set realized_y = pt + ((y_max - last.cumulative_realized|float) / y_span) * ih %} {# Tether line from realized line to the +unrealized dot #} Today · realized {% if last.cumulative_realized|float >= 0 %}+{% else %}−{% endif %}${{ "{:,.2f}".format(last.cumulative_realized|float|abs) }} + unrealized {% if last.unrealized|float >= 0 %}+{% else %}−{% endif %}${{ "{:,.2f}".format(last.unrealized|float|abs) }} = {% if last_total >= 0 %}+{% else %}−{% endif %}${{ "{:,.2f}".format(last_total|abs) }} {% endif %}
Line: cumulative realized · Dot: + present-day unrealized · hover any point
{% endif %}