Class: Mosaic::Sdk::Models::Nav

Inherits:
Base
  • Object
show all
Includes:
Searchable
Defined in:
lib/mosaic/sdk/models/nav.rb

Overview

Represents the NAV (Net Asset Value) collection from the Mosaic API.

NAVs can be accessed in two ways:

  1. Top-level (code-addressed): use Mosaic::Sdk.Nav to call #list with codes:. This POSTs to /v2/navs/search and returns raw nav arrays keyed by code. create is NOT available at the top level.

  2. Nested under a clone: use clone.navs (a collection scoped to /v2/clones/:clone_id/navs) to call #list, #create, #latest, or #for_date.

Examples:

Batch-fetch latest NAVs by code (top-level)

# body: { filters: { codes:, date: { since: Date.today }, latest: nil }, view: 'with_documents' }
Mosaic::Sdk.Nav.list(codes: %w[LU0012345 LU0067890], to: Date.today, view: 'with_documents')

Batch-fetch NAV history by code (top-level)

# body: { filters: { codes:, date: { from: '2026-01-01', to: '2026-06-01' } } }
Mosaic::Sdk.Nav.list(codes: %w[LU0012345], from: '2026-01-01', to: '2026-06-01')

Get the latest NAV for a clone (nested)

dna = Mosaic::Sdk.Dna(42)
clone = dna.clones(7)
clone.navs.latest.data

List all NAVs for a clone (nested)

clone.navs.list

Create a NAV under a clone (nested)

clone.navs.create(date: '2025-01-15', value: 100.0)

Get the NAV for a specific date (nested)

clone.navs.for_date(Date.new(2025, 1, 15)).data
clone.navs.for_date('2025-01-15').data

Defined Under Namespace

Classes: Instance

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Mosaic::Sdk::Models::Base

Instance Method Details

#create(price:, unit:, date:, pricing_method:, bank_id:, source: nil, user: nil, currency: nil) ⇒ Instance

Creates a new NAV for the parent clone.

Parameters:

  • price (Float)

    the NAV price

  • unit (String)

    the price format: 'percentage' (%) or 'price' (P) (mapped to market_price_kind)

  • date (Date, String)

    the NAV date

  • pricing_method (String)

    the pricing method (mapped to market_price_type). One of: net_asset_value_final, last_paid_price, mid_price, pair, estimate_valuation, adjusted_price_after_sec_event, settlement, proxy_price, nav_valuation

  • bank_id (Integer)

    the associated bank ID

  • source (String, nil) (defaults to: nil)

    the NAV source name (e.g. the provider establishment); folded into a Source record server-side

  • user (String, nil) (defaults to: nil)

    the identifier recorded as the NAV author

  • currency (String, nil) (defaults to: nil)

    the price's denomination (3-letter code, e.g. USD); stored server-side as the NAV's base currency_amount, the authoritative source the other currencies are converted from

Returns:

  • (Instance)

    the created NAV instance

Raises:

  • (NotImplementedError)

#for_date(date) ⇒ Instance

Returns the NAV for a specific date.

Parameters:

  • date (Date, String)

    the date to look up, either as a Date object or a string in 'YYYY-MM-DD' format

Returns:

  • (Instance)

    the NAV instance for the given date

#latest(historical: false) ⇒ Instance

Returns the latest NAV for the parent clone.

Returns:

  • (Instance)

    the latest NAV instance

#list(codes: [], from: nil, to: nil, on: nil, historical: false, sources: nil, view: nil, currencies: nil) ⇒ Array<Instance>, Hash{String=>Array}

Lists NAVs: nested under a clone it returns that clone's NAVs (GET); at the top level it runs a code-addressed batch search (POST /search).

Parameters:

  • codes (Array<String>) (defaults to: [])

    external codes to resolve; used only by the top-level batch search (ignored when nested under a clone)

  • from (Date, String, nil) (defaults to: nil)

    range start ('YYYY-MM-DD' or Date)

  • to (Date, String, nil) (defaults to: nil)

    range end, or the valuation ceiling when from is omitted (latest-on-or-before mode)

  • on (Array<Date, String>, nil) (defaults to: nil)

    exact dates to keep — for fetching the NAVs at a few specific dates rather than spanning a range

  • historical (Boolean) (defaults to: false)

    include historical NAVs

  • sources (Array<String>, nil) (defaults to: nil)

    source names to filter

  • view (String, nil) (defaults to: nil)

    payload view: 'with_justification' or 'with_documents' (nil/'base' for the base view)

  • currencies (Array<String>, nil) (defaults to: nil)

    ISO codes to also value the NAV in; echoed under each nav's currency_conversions (backfilled server-side)

Returns:

  • (Array<Instance>)

    nested: the clone's NAV instances

  • (Hash{String=>Array})

    top-level: raw nav arrays keyed by code