Skip to content

Asset classes

An instrument in this library is an object whose class says what kind of contract it is. There is a class for a share, one for a share future, one for an option on an index, and so on, 27 classes in all, spread over six family modules under src/tradingmachine/assets/. You pick the class, give it the few fields that identify one contract, and the constructor asks UBI which instrument that is. You never type a segment name such as nse_equity_index_options yourself, because the class already knows it.

The classes look alike, but what works on each one does not. UBI has live quotes for some segments and not others, stores candles for only a few, and cannot send an order for several kinds of instrument even though the class inherits the order methods. This page puts all of that in one place, and each family page explains the reasons.

How the classes fit together

Every class inherits from one of two base classes. A class whose contracts can be traded inherits TradeableInstrument, which adds the order book, orders, positions and the price wrappers. The sixteen futures and option classes reach it through a layer of derivative base classes, Futures, Option, IndexFutures and IndexOption on a shared Derivative, which add the expiry, underlying, basis and greeks members and the discovery class methods. An index inherits NonTradeableInstrument, which refuses anything that is not an index and adds only the constituents property described below. Both inherit Instrument, which holds the identity fields, the candles and the quote, and which itself inherits the fourteen analysis classes described in Analysis.

The animated diagram below shows the six family modules feeding their classes up through the derivative base classes and the two tradeable and non-tradeable classes into Instrument. The instrument model shows every class by name.

How the six asset-class modules inherit from the instrument classes Six family modules sit at the bottom. Their cash classes and the funds inherit TradeableInstrument directly, their sixteen futures and option classes inherit the derivative base classes, which inherit TradeableInstrument, and their four index classes inherit NonTradeableInstrument. Both of those inherit Instrument, which also inherits the fourteen analysis classes. Dots travel upward along each inheritance line. Instrument identity, prices, quote, last_price, ohlc 14 analysis classes 209 methods on prices() TradeableInstrument order book, orders, positions: 23 classes NonTradeableInstrument indices only: 4 classes Derivative Futures, Option, IndexFutures, IndexOption: 16 equities.py 6 classes, 4 derivatives fixed_income.py 6 classes, 4 derivatives commodities.py 6 classes, 4 derivatives currencies.py 6 classes, 4 derivatives funds.py 2 classes mutual_funds.py 1 class the six asset-class modules under src/tradingmachine/assets/
Orange dots follow the cash classes and the funds straight up to TradeableInstrument, green dots follow the sixteen futures and option classes up through the derivative base classes, and blue dots follow the four index classes up to NonTradeableInstrument. The orange dots entering Instrument from the right are the fourteen analysis classes it inherits.

The funds module has only two classes and the mutual funds module only one, because UBI carries no futures or options on a fund, a trust or a mutual fund. The four families with derivatives each have six classes, following the same pattern: a cash instrument, its futures and its options, and an index, its futures and its options. The instrument model explains the base classes in more depth.

The whole matrix

The table below lists all 27 classes. "Named by" gives the constructor's arguments, every one of which is required. The last five columns say whether UBI serves a live quote, whether it stores candles, whether an order for the class can actually be placed, whether the class carries the holdings members, and which discovery class methods it offers.

means yes, means no, and means the segment holds no instruments at all in UBI, so the class resolves nothing today.

Class Module UBI segment Base Named by Quotes Candles Orders Holdings Discovery
Equity equities equities Tradeable exchange, symbol search
EquityFutures equities equity_futures Tradeable exchange, underlying, expiry not checked expiries, contracts
EquityOption equities equity_options Tradeable exchange, underlying, expiry, strike, option type not checked expiries, strikes, chain
EquityIndex equities equity_indices NonTradeable exchange, symbol search
EquityIndexFutures equities equity_index_futures Tradeable exchange, underlying, expiry not checked expiries, contracts
EquityIndexOption equities equity_index_options Tradeable exchange, underlying, expiry, strike, option type not checked expiries, strikes, chain
FixedIncome fixed_income fixed_income Tradeable exchange, symbol (an ISIN) search
FixedIncomeFutures fixed_income fixed_income_futures Tradeable exchange, underlying, expiry expiries, contracts
FixedIncomeOption fixed_income fixed_income_options Tradeable exchange, underlying, expiry, strike, option type expiries, strikes, chain
FixedIncomeIndex fixed_income fixed_income_indices NonTradeable exchange, symbol search
FixedIncomeIndexFutures fixed_income fixed_income_index_futures Tradeable exchange, underlying, expiry expiries, contracts
FixedIncomeIndexOption fixed_income fixed_income_index_options Tradeable exchange, underlying, expiry, strike, option type expiries, strikes, chain
Commodity commodities commodities Tradeable exchange, symbol search
CommodityFutures commodities commodity_futures Tradeable exchange, underlying, expiry expiries, contracts
CommodityOption commodities commodity_options Tradeable exchange, underlying, expiry, strike, option type expiries, strikes, chain
CommodityIndex commodities commodity_indices NonTradeable exchange, symbol search
CommodityIndexFutures commodities commodity_index_futures Tradeable exchange, underlying, expiry expiries, contracts
CommodityIndexOption commodities commodity_index_options Tradeable exchange, underlying, expiry, strike, option type expiries, strikes, chain
Currency currencies currencies Tradeable exchange, symbol search
CurrencyFutures currencies currency_futures Tradeable exchange, underlying, expiry nse only expiries, contracts
CurrencyOption currencies currency_options Tradeable exchange, underlying, expiry, strike, option type nse only expiries, strikes, chain
CurrencyIndex currencies currency_indices NonTradeable exchange, symbol search
CurrencyIndexFutures currencies currency_index_futures Tradeable exchange, underlying, expiry expiries, contracts
CurrencyIndexOption currencies currency_index_options Tradeable exchange, underlying, expiry, strike, option type expiries, strikes, chain
ExchangeTradedFund funds exchange_traded_funds Tradeable exchange, symbol search
InvestmentTrust funds investment_trusts Tradeable exchange, symbol search
MutualFund mutual_funds mutual_funds Tradeable exchange, symbol (a scheme code) limit price only search

A few cells need a word of explanation, because the short form hides a condition.

  • Candles on equity derivatives are marked "not checked". UBI's own documentation says no derivative bars are stored, but the commodity derivatives were measured on 2026-09-20 and do have candles, so that statement is out of date. Nobody has run prices on an equity future or option from this library, so the four cells are left unverified rather than guessed. Equity and EquityIndex do have candles: RELIANCE's are captured on the Equities page, and NIFTY's were used for the beta check on 2026-09-14.
  • "Orders" means an order can actually be placed. Every class built on TradeableInstrument has place_order and the thirty-two price wrappers, including Commodity, Currency and FixedIncome. For Commodity and Currency, UBI refuses the order. For FixedIncome, the only broker carrying cash bonds has no order symbol for them, so there is no broker to send the order to; this was read from the instrument data rather than tested. The cells therefore say no, and the family pages give the reasons.
  • The fixed income derivatives are marked as orderable, with a caution. UBI appears to route them to the wrong venue. This was read from UBI's source and has never been tested with a real order, as the Fixed income page explains.
  • A mutual fund order is an ordinary cnc order. It has no quote, so it needs a limit price, and whether a broker treats it as a subscription has not been tested.

Coverage by family

The chart below counts, for each family, how many of its classes have each capability. The first bar in each group is the number of classes that resolve any instrument at all, so it shows how many of the family's classes are more than placeholders today. Candles on the four equity derivative classes are not counted, because they have not been checked.

{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "For each asset family, the number of classes that resolve instruments, have quotes, have candles, can be ordered and carry holdings.", "width": "container", "height": 360, "data": { "values": [ {"family": "Equities", "capability": "1. Resolves instruments", "classes": 6}, {"family": "Equities", "capability": "2. Live quotes", "classes": 6}, {"family": "Equities", "capability": "3. Candles", "classes": 2}, {"family": "Equities", "capability": "4. Can be ordered", "classes": 5}, {"family": "Equities", "capability": "5. Holdings", "classes": 1}, {"family": "Fixed income", "capability": "1. Resolves instruments", "classes": 5}, {"family": "Fixed income", "capability": "2. Live quotes", "classes": 3}, {"family": "Fixed income", "capability": "3. Candles", "classes": 0}, {"family": "Fixed income", "capability": "4. Can be ordered", "classes": 3}, {"family": "Fixed income", "capability": "5. Holdings", "classes": 1}, {"family": "Commodities", "capability": "1. Resolves instruments", "classes": 6}, {"family": "Commodities", "capability": "2. Live quotes", "classes": 4}, {"family": "Commodities", "capability": "3. Candles", "classes": 4}, {"family": "Commodities", "capability": "4. Can be ordered", "classes": 4}, {"family": "Commodities", "capability": "5. Holdings", "classes": 0}, {"family": "Currencies", "capability": "1. Resolves instruments", "classes": 3}, {"family": "Currencies", "capability": "2. Live quotes", "classes": 2}, {"family": "Currencies", "capability": "3. Candles", "classes": 0}, {"family": "Currencies", "capability": "4. Can be ordered", "classes": 2}, {"family": "Currencies", "capability": "5. Holdings", "classes": 0}, {"family": "Funds and trusts", "capability": "1. Resolves instruments", "classes": 2}, {"family": "Funds and trusts", "capability": "2. Live quotes", "classes": 2}, {"family": "Funds and trusts", "capability": "3. Candles", "classes": 1}, {"family": "Funds and trusts", "capability": "4. Can be ordered", "classes": 2}, {"family": "Funds and trusts", "capability": "5. Holdings", "classes": 2}, {"family": "Mutual funds", "capability": "1. Resolves instruments", "classes": 1}, {"family": "Mutual funds", "capability": "2. Live quotes", "classes": 0}, {"family": "Mutual funds", "capability": "3. Candles", "classes": 0}, {"family": "Mutual funds", "capability": "4. Can be ordered", "classes": 1}, {"family": "Mutual funds", "capability": "5. Holdings", "classes": 1} ] }, "mark": {"type": "bar", "tooltip": true}, "encoding": { "y": {"field": "family", "type": "nominal", "title": null, "sort": ["Equities", "Fixed income", "Commodities", "Currencies", "Funds and trusts", "Mutual funds"]}, "yOffset": {"field": "capability", "type": "nominal"}, "x": {"field": "classes", "type": "quantitative", "title": "Number of classes", "axis": {"tickMinStep": 1}}, "color": {"field": "capability", "type": "nominal", "title": "Capability", "legend": {"orient": "bottom", "columns": 3}} } }

Three patterns stand out in the chart. Equities are the only family where nearly everything works. Commodities and currencies share a shape, in which only the derivatives are real contracts, but commodity derivatives have candles and currency derivatives do not. And holding is a separate idea from trading: a mutual fund can be held but has no quote, while a commodity future can be traded but never held.

Holdings and positions are different things

A holding is something kept in the demat account overnight and beyond, such as shares bought for delivery. A position is what an order leaves open in a trading day or a derivatives contract, such as a long future. UBI reports holdings only for its cash segments, which are equities, exchange traded funds, investment trusts, mutual funds, fixed income and the catch-all uncategorised, so only the five classes on those segments carry the holdings members. Every class built on TradeableInstrument has the position members. Holdings and Positions describe both sets.

An index, an exchange traded fund and a mutual fund each have two sides: the one official price the exchange or the fund house publishes, and the list of instruments behind that price. UBI stores only the first, so the list is kept in this project's MongoDB as an asset basket and reached through a constituents property. The table below shows which classes have that property and what it returns.

Class Where constituents comes from What it returns
EquityIndex, FixedIncomeIndex, CommodityIndex, CurrencyIndex NonTradeableInstrument, so every index class has it An Index basket, or None when none is stored
ExchangeTradedFund ExchangeTradedFund itself An ExchangeTradedFundConstituents basket, or None when none is stored
MutualFund MutualFund itself A MutualFundConstituents basket, or None when none is stored

The property reads MongoDB and UBI on every access, and the basket's linked_instrument is the instrument again, so the two sides point at each other while the official price stays on the instrument. InvestmentTrust has no constituents. A fund's constituents are not the same thing as its holdings, which are the units of the fund this account owns.

The families

Each family page lists its classes, explains how they are named, and records what UBI does and does not have for them.

  • Equities


    Shares, indices, and the futures and options on each. The one family where quotes, candles, orders and holdings all work.

    Equities

  • Fixed income


    Bonds named by ISIN, rate indices, and interest rate futures and options. No candles, and no quote for a cash bond.

    Fixed income

  • Commodities


    MCX, NCDEX and NSE commodity derivatives, ordered in whole lots of quotation units. The derivatives have candles.

    Commodities

  • Currencies


    Seven currency pairs and the bse's over-the-counter variants. Half the family is empty, and lot_size is a trap.

    Currencies

  • Funds and trusts


    Exchange traded funds and investment trusts, which trade and are held exactly like shares.

    Funds and trusts

  • Mutual funds


    Schemes named by exchange code, held rather than traded, with no quote and no candles.

    Mutual funds

What is not covered

UBI has one more segment, uncategorised, which collects instruments its mapping could not place anywhere else. It has no class here, because UBI does not accept orders for it. Every asset class the old tradingmachine project had is ported, so this is the only gap.