133 lines
4.7 KiB
Markdown
133 lines
4.7 KiB
Markdown
<!-- Generated from docs_source/business by docs/tools/render_business_docs.py. -->
|
|
|
|
# Valuation, PnL, MTM
|
|
|
|
Status: `partial migration`
|
|
|
|
Language: `en`<br>
|
|
Mirror page: [valuation-pnl-mtm.md](valuation-pnl-mtm.md)
|
|
|
|
## BR-PT-VAL-001 - Valuation covers purchase, sale, and sale-first flows
|
|
|
|
Source: `BR-PT-004`, `BR-PT-006`, `BR-PT-011`
|
|
|
|
### Consultant Rule
|
|
|
|
PnL must exist for purchases and for sales, even when a sale is not yet matched
|
|
to a purchase.
|
|
|
|
### Developer Notes
|
|
|
|
<ul style="margin:0.65rem 0 1rem 1.1rem; padding-left:1rem; list-style-type:disc;">
|
|
<li style="margin:0.38rem 0;">An unmatched <code>sale.line</code> must generate at least <code>sale priced</code>, <code>sale fee</code>, and <code>derivative</code> when applicable.
|
|
</li>
|
|
<li style="margin:0.38rem 0;">A basis sale with no price detail must still produce a zero line or the economic fallback price according to the applicable rule.
|
|
</li>
|
|
<li style="margin:0.38rem 0;">Do not arbitrarily attach a single sale when several sales are matched to the same open balance.
|
|
</li>
|
|
</ul>
|
|
|
|
## BR-PT-VAL-002 - Valuation references
|
|
|
|
Source: `BR-PT-005`
|
|
|
|
### Consultant Rule
|
|
|
|
The PnL reference must describe the nature of the valued line: purchase or sale,
|
|
open or physical.
|
|
|
|
### Developer Notes
|
|
|
|
<ul style="margin:0.65rem 0 1rem 1.1rem; padding-left:1rem; list-style-type:disc;">
|
|
<li style="margin:0.38rem 0;">Allowed references: <code>Purchase/Open</code>, <code>Purchase/Physic</code>, <code>Sale/Open</code>, <code>Sale/Physic</code>.
|
|
</li>
|
|
<li style="margin:0.38rem 0;">A virtual lot must not be output with a physical reference.
|
|
</li>
|
|
</ul>
|
|
|
|
## BR-PT-VAL-003 - MTM excludes fees
|
|
|
|
Source: `BR-PT-007`
|
|
|
|
### Consultant Rule
|
|
|
|
Mark-to-market applies to prices and derivatives, not to fees.
|
|
|
|
### Developer Notes
|
|
|
|
<ul style="margin:0.65rem 0 1rem 1.1rem; padding-left:1rem; list-style-type:disc;">
|
|
<li style="margin:0.38rem 0;">MTM is allowed for <code>pur. priced</code>, <code>sale priced</code>, <code>derivative</code>.
|
|
</li>
|
|
<li style="margin:0.38rem 0;">Fees are outside MTM: <code>pur. fee</code>, <code>sale fee</code>, <code>shipment fee</code>, <code>line fee</code>.
|
|
</li>
|
|
<li style="margin:0.38rem 0;">For fees: <code>mtm_price</code>, <code>mtm</code>, <code>strategy</code> must stay empty.
|
|
</li>
|
|
</ul>
|
|
|
|
## BR-PT-VAL-004 - Current snapshot and economic identity
|
|
|
|
Source: session `2026-05-14`
|
|
|
|
### Consultant Rule
|
|
|
|
`valuation_valuation_line` represents the latest known PnL image.
|
|
It is not a history table.
|
|
|
|
<ul style="margin:0.65rem 0 1rem 1.1rem; padding-left:1rem; list-style-type:disc;">
|
|
<li style="margin:0.38rem 0;">A new generation replaces the previous generation for the same economic reality.
|
|
</li>
|
|
<li style="margin:0.38rem 0;">An unmatched sale owns its own PnL.
|
|
</li>
|
|
<li style="margin:0.38rem 0;">A matched sale is owned by the linked purchase line.
|
|
</li>
|
|
<li style="margin:0.38rem 0;">The PnL of a matched sale must not be generated twice: once from the sale side and once from the purchase side.
|
|
</li>
|
|
</ul>
|
|
|
|
### Developer Notes
|
|
|
|
<ul style="margin:0.65rem 0 1rem 1.1rem; padding-left:1rem; list-style-type:disc;">
|
|
<li style="margin:0.38rem 0;">Before creating rows in <code>valuation.valuation.line</code>, delete the current snapshot with the same economic identity.
|
|
</li>
|
|
<li style="margin:0.38rem 0;">Economic identity:
|
|
<ul style="margin:0.65rem 0 1rem 1.35rem; padding-left:1rem; list-style-type:circle;">
|
|
<li style="margin:0.38rem 0;"><code>sale_line</code> when present, otherwise <code>line</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>lot</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>type</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>reference</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>counterparty</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>product</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>state</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>strategy</code>.
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li style="margin:0.38rem 0;">Do not include in the identity:
|
|
<ul style="margin:0.65rem 0 1rem 1.35rem; padding-left:1rem; list-style-type:circle;">
|
|
<li style="margin:0.38rem 0;"><code>date</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>price</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>quantity</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>amount</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>mtm_price</code>;
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>mtm</code>.
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li style="margin:0.38rem 0;">These fields are recalculated results and must be replaced by the latest generation.
|
|
</li>
|
|
<li style="margin:0.38rem 0;"><code>generate_from_sale_line()</code> does not create a sale snapshot when the <code>sale.line</code> is already matched to a <code>purchase.line</code>; it redirects to the owner purchase line generation.
|
|
</li>
|
|
</ul>
|