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.
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
priceson an equity future or option from this library, so the four cells are left unverified rather than guessed.EquityandEquityIndexdo 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
TradeableInstrumenthasplace_orderand the thirty-two price wrappers, includingCommodity,CurrencyandFixedIncome. ForCommodityandCurrency, UBI refuses the order. ForFixedIncome, 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
cncorder. 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.
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.
Indices and funds link to what they hold¶
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.
-
Fixed income
Bonds named by ISIN, rate indices, and interest rate futures and options. No candles, and no quote for a cash bond.
-
Commodities
MCX, NCDEX and NSE commodity derivatives, ordered in whole lots of quotation units. The derivatives have candles.
-
Currencies
Seven currency pairs and the bse's over-the-counter variants. Half the family is empty, and
lot_sizeis a trap. -
Funds and trusts
Exchange traded funds and investment trusts, which trade and are held exactly like shares.
-
Mutual funds
Schemes named by exchange code, held rather than traded, with no quote and no candles.
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.