indmoney
¶
INDmoney (INDstocks) ticks.
INDstocks names an instrument as SEGMENT:TOKEN - NSE:2885, NFO:35001, NIDX:40000001 - with
equity on NSE and BSE, derivatives on NFO and BFO and indices on NIDX and BIDX, and stores
the bare token. No INDstocks token collided across segments on 2026-09-13, but the segment still
narrows the search so that one never silently does.
What INDmoney's values mean, as measured on the feed's full mode against Zerodha's ticks received at
the same moment during the session of 2026-09-15, on TCS, INFY, ICICIBANK, RELIANCE and HDFCBANK:
closeis not the previous close but the last price: HDFCBANK read 722.25 as both, where the previous close was 708.25. It is never used; the previous close comes from an earlier owner's tick the same day instead.- Prices are rupees: last price, open, high and low matched Zerodha's.
- Quantities are units: INFY and ICICIBANK volumes matched Zerodha's exactly.
- Both times are true instants: the last trade time matched Zerodha's to within three seconds and the exchange timestamp to within two, and ticks arrived 0.8 seconds after it.
The feed sends no last quantity, average price or order book quantities, and INDstocks streams no MCX.
Classes:
| Name | Description |
|---|---|
IndmoneyTickNormalizer |
Normalizes INDmoney ticks. |
IndmoneyTickNormalizer
¶
Bases: TickNormalizer
Normalizes INDmoney ticks.
Build the lookup from each INDstocks segment name to the canonical segments it can hold.
The table is worked out once here from SEGMENTS, so feed_key only has to look a tick's segment name up rather than recompute its segments on every call.
Example programs
"""Places INDmoney feed tokens, spelled `SEGMENT:TOKEN`, on the canonical segments they can be in.
An INDstocks token names a segment before a colon: NSE and BSE are shares, NFO and BFO are derivatives, and NIDX and BIDX are indices. A bare token the feed could not place, or a segment INDmoney does not serve such as MCX, prints `None`.
The normalizer only works on the text of each token, so the program needs no Redis, database, network or stand-in of any kind. Each output line shows a token as the feed spells it, then the broker token that `unified.broker_mappings` is searched with, the order symbol when the broker names instruments by symbol, and how many canonical segments the search is limited to, with the first of them. A token the normalizer cannot place prints `None`.
Run it from the project root:
python examples/stock_brokers/instruments/ticks/indmoney/IndmoneyTickNormalizer/example_1_placing_feed_tokens.py
"""
from stock_brokers.instruments.ticks.indmoney import (
IndmoneyTickNormalizer,
)
class PlacingFeedTokensExample:
"""Asks the INDmoney normalizer where each of a few feed tokens belongs.
Attributes:
normalizer (IndmoneyTickNormalizer): The normalizer being shown.
tokens (list): The tokens to place, spelled as the feed spells them.
"""
def __init__(self):
"""Builds the normalizer and the tokens to place.
Returns:
None: This method returns nothing.
"""
self.normalizer = IndmoneyTickNormalizer()
self.tokens = [
'NSE:2885',
'BSE:500325',
'NFO:35003',
'NIDX:13',
'2885',
'MCX:440001',
]
def describe(self, feed_key):
"""Describes a feed key in one line.
Args:
feed_key (FeedKey | None): The key the normalizer returned.
Returns:
str: The description.
"""
if feed_key is None:
return 'None'
segment_count = len(feed_key.segments)
first_segment = feed_key.segments[0]
return f'broker_token={feed_key.broker_token!r} order_symbol={feed_key.order_symbol!r} segments={segment_count} starting with {first_segment}'
def run(self):
"""Prints where each token belongs.
Returns:
None: This method returns nothing.
"""
print(f'Broker: {IndmoneyTickNormalizer.BROKER_NAME}')
for token in self.tokens:
feed_key = self.normalizer.feed_key(token)
print(f'{token!r} -> {self.describe(feed_key)}')
if __name__ == '__main__':
PlacingFeedTokensExample().run()
It prints:
Broker: indmoney
'NSE:2885' -> broker_token='2885' order_symbol=None segments=6 starting with nse_equities
'BSE:500325' -> broker_token='500325' order_symbol=None segments=6 starting with bse_equities
'NFO:35003' -> broker_token='35003' order_symbol=None segments=16 starting with nse_fixed_income_futures
'NIDX:13' -> broker_token='13' order_symbol=None segments=4 starting with nse_equity_indices
'2885' -> None
'MCX:440001' -> None
"""Normalizes one INDmoney tick for a NIFTY future, whose quantities are already in units.
INDmoney reports derivative quantities in units rather than lots, so every multiplier is 1, and a future carries open interest. Its `close` is never the previous session's close, so `reported_close` is None both before and after the session ends.
The plan that `normalize` applies is normally compiled by `TickResolver` from the mapping cache. This program builds it by hand with the same rules, asking the normalizer how it reports each quantity field and when its close may be trusted, so it needs no database. The tick is shaped like the ones the broker's market feed publishes, with fixed times, so the output is the same on every run. The program normalizes the tick twice, once as received before the session's close and once as received after it, which only changes whether `reported_close` is kept. Order book levels are printed as (price, quantity, orders).
Run it from the project root:
python examples/stock_brokers/instruments/ticks/indmoney/IndmoneyTickNormalizer/example_2_a_future_in_units.py
"""
import datetime
import zoneinfo
from stock_brokers.instruments.ticks import base
from stock_brokers.instruments.ticks.base import (
InstrumentPlan,
)
from stock_brokers.instruments.ticks.indmoney import (
IndmoneyTickNormalizer,
)
from stock_brokers.instruments.ticks.utilities import sessions
INDIA = zoneinfo.ZoneInfo('Asia/Kolkata')
class NiftyFutureTickExample:
"""Normalizes one INDmoney tick through a hand-built plan and prints the result.
Attributes:
normalizer (IndmoneyTickNormalizer): The normalizer being shown.
received_at (float): When the tick was received, in epoch seconds.
tick (dict): The tick as the market feed published it.
plan (InstrumentPlan): The plan for the tick's instrument.
"""
def __init__(self):
"""Builds the normalizer, the tick and its plan.
Returns:
None: This method returns nothing.
"""
self.normalizer = IndmoneyTickNormalizer()
received = datetime.datetime(2026, 9, 15, 11, 5, tzinfo=INDIA)
self.received_at = received.timestamp()
self.tick = {
'instrument_token': 'NFO:35003',
'last_price': 25110.5,
'last_quantity': 75,
'average_price': 25096.2,
'volume': 4533075,
'buy_quantity': 312450,
'sell_quantity': 298275,
'ohlc': {
'open': 25060.0,
'high': 25134.9,
'low': 25041.0,
'close': 25080.0,
},
'oi': 14622300,
'oi_day_high': 14801250,
'oi_day_low': 14510025,
'last_trade_time': self.received_at - 2.0,
'exchange_timestamp': self.received_at - 1.0,
'received_at': self.received_at,
'depth': {
'buy': [
{
'price': 25110.0,
'quantity': 225,
'orders': 3,
},
{
'price': 25109.5,
'quantity': 450,
'orders': 5,
},
],
'sell': [
{
'price': 25110.5,
'quantity': 150,
'orders': 2,
},
{
'price': 25111.0,
'quantity': 375,
'orders': 4,
},
],
},
}
self.plan = self.build_plan()
def build_plan(self):
"""Compiles the plan for the tick's instrument the way the resolver would.
Returns:
InstrumentPlan: The plan.
"""
exchange = 'nse'
segment = 'nse_equity_index_futures'
lot_size = 75
broker_lot_size = 75
multipliers = {}
for field in base.QUANTITY_FIELDS:
basis = self.normalizer.quantity_basis(exchange, field)
if basis == base.BASIS_LOTS:
multipliers[field] = lot_size
elif basis == base.BASIS_BROKER_LOTS:
multipliers[field] = lot_size // broker_lot_size
else:
multipliers[field] = 1
identity = {
'exchange': 'nse',
'segment': 'nse_equity_index_futures',
'shape': 'future',
'symbol': 'NIFTY26SEPFUT',
'underlying_symbol': 'NIFTY',
'expiry_date': '2026-09-29',
'strike_price': None,
'option_type': None,
}
instrument_id = '11111111-1111-5111-8111-000000000105'
broker_token = '35003'
return InstrumentPlan(
instrument_id=instrument_id,
broker=IndmoneyTickNormalizer.BROKER_NAME,
broker_token=broker_token,
exchange=exchange,
segment=segment,
shape=identity['shape'],
session=sessions.session_for(segment),
lot_size=lot_size,
multipliers=multipliers,
price_decimals=2,
negative_prices=False,
close_policy=self.normalizer.close_policy(exchange),
has_open_interest=identity['shape'] != 'security',
trusts_last_trade_time=IndmoneyTickNormalizer.TRUSTS_LAST_TRADE_TIME,
trusts_exchange_time=IndmoneyTickNormalizer.TRUSTS_EXCHANGE_TIME,
identity_json=base.identity_json(
instrument_id,
IndmoneyTickNormalizer.BROKER_NAME,
broker_token,
identity,
lot_size,
),
)
def run(self):
"""Prints the feed key, the plan's rules and the normalized values.
Returns:
None: This method returns nothing.
"""
token = self.tick['instrument_token']
feed_key = self.normalizer.feed_key(token)
print(f'Token {token!r}: broker_token={feed_key.broker_token!r} order_symbol={feed_key.order_symbol!r}')
volume_basis = self.normalizer.quantity_basis(self.plan.exchange, 'volume')
print(f'Volume on {self.plan.exchange} is reported in {volume_basis}, multiplier {self.plan.multipliers["volume"]}')
print(f'Close policy on {self.plan.exchange}: {self.normalizer.close_policy(self.plan.exchange)}')
before_close = self.normalizer.normalize(self.tick, self.plan, True)
print('Normalized, received before the close:')
for name, value in before_close.items():
print(f' {name}: {value}')
after_close = self.normalizer.normalize(self.tick, self.plan, False)
print(f'reported_close when received after the close: {after_close["reported_close"]}')
if __name__ == '__main__':
NiftyFutureTickExample().run()
It prints:
Token 'NFO:35003': broker_token='35003' order_symbol=None
Volume on nse is reported in units, multiplier 1
Close policy on nse: never
Normalized, received before the close:
last_price: 25110.5
last_quantity: 75
average_price: 25096.2
volume: 4533075
buy_quantity: 312450
sell_quantity: 298275
open: 25060.0
high: 25134.9
low: 25041.0
reported_close: None
oi: 14622300
oi_day_high: 14801250
oi_day_low: 14510025
last_trade_time: 1789450498.0
exchange_time: 1789450499.0
bids: [(25110.0, 225, 3), (25109.5, 450, 5)]
asks: [(25110.5, 150, 2), (25111.0, 375, 4)]
reported_close when received after the close: None
Methods:
| Name | Description |
|---|---|
feed_key |
The broker token and segments for an INDstocks |
tick_spelling |
A subscription-set token spelled the way the feed spells it on ticks. |
quantity_basis |
Whether the broker reports a quantity field in lots or units on an exchange. |
close_policy |
When the broker's |
normalize |
Apply a plan to one tick. |
Source code in stock_brokers/instruments/ticks/indmoney.py
feed_key
¶
The broker token and segments for an INDstocks SEGMENT:TOKEN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument_token
|
str
|
The tick's |
required |
Returns:
| Type | Description |
|---|---|
FeedKey | None
|
The key, or None for a bare token the feed could not place, or an unknown segment. |
Example usage
Source code in stock_brokers/instruments/ticks/indmoney.py
tick_spelling
¶
A subscription-set token spelled the way the feed spells it on ticks.
Plans are filed under the tick's spelling, because that is what the per-tick path looks up. A subscription set holds strings in the spelling the broker's quote feed subscribes with, which is not always the tick's: Kite ticks carry an integer, Dhan ticks a numeric segment code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subscription_token
|
str
|
A member of |
required |
Returns:
| Type | Description |
|---|---|
int | str | None
|
The tick's spelling, or None for a token this normalizer cannot place. |
Example usage
print(f"Tick spelling of 'NSE-2885': {self.normalizer.tick_spelling('NSE-2885')!r}")
Source code in stock_brokers/instruments/ticks/base.py
quantity_basis
¶
Whether the broker reports a quantity field in lots or units on an exchange.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exchange
|
str
|
Canonical exchange. |
required |
field
|
str
|
One of QUANTITY_FIELDS. |
required |
Returns:
| Type | Description |
|---|---|
str
|
BASIS_UNITS, BASIS_LOTS or BASIS_BROKER_LOTS. |
Example usage
Source code in stock_brokers/instruments/ticks/base.py
close_policy
¶
When the broker's close is the previous session's close on an exchange.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exchange
|
str
|
Canonical exchange. |
required |
Returns:
| Type | Description |
|---|---|
str
|
One of the CLOSE_* policies. |
Example usage
print(f'{exchange} close policy: {self.normalizer.close_policy(exchange)}')
return InstrumentPlan(
instrument_id='11111111-1111-5111-8111-000000000102',
broker='imaginary',
broker_token='2885',
exchange=exchange,
segment=segment,
shape=shape,
session=sessions.session_for(segment),
lot_size=lot_size,
multipliers=multipliers,
price_decimals=2,
negative_prices=shape != 'security' and exchange == 'mcx',
close_policy=self.normalizer.close_policy(exchange),
has_open_interest=shape != 'security',
trusts_last_trade_time=True,
trusts_exchange_time=True,
identity_json='"instrument_id":"11111111-1111-5111-8111-000000000102"',
)
Source code in stock_brokers/instruments/ticks/base.py
normalize
¶
Apply a plan to one tick.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tick
|
dict
|
A tick as the broker's market feed published it. |
required |
plan
|
InstrumentPlan
|
The compiled plan for the tick's token. |
required |
before_trading_close
|
bool
|
Whether the tick was received before its session's close, for the close policy. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
The normalized values, or None when the tick carries no usable last price. Keys are last_price, last_quantity, average_price, volume, buy_quantity, sell_quantity, open, high, low, reported_close, oi, oi_day_high, oi_day_low, last_trade_time, exchange_time, bids and asks, where bids and asks are lists of (price, quantity, orders) best first. |
Example usage
values = self.normalizer.normalize(
{
'last_price': -12.5,
'volume': 400,
'oi': 900,
'received_at': self.received_at,
},
future,
True,
)
outcome = self.normalizer.normalize(
{
'last_price': last_price,
'received_at': self.received_at,
},
share,
True,
)
Source code in stock_brokers/instruments/ticks/base.py
_instant
¶
A broker timestamp as a true epoch, or None when it is missing or implausible.
Brokers that stamp times on a shifted clock have that corrected in their market feed; what is left to catch here is a clock nobody has corrected yet, which shows as an instant days away from when the tick arrived.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float | int | None
|
Epoch seconds as the feed published them. |
required |
received_at
|
float
|
When the feed decoded the tick. |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
The instant, or None. |