Nubra Python SDK
Nubra API is your gateway to seamless integration with Nubra's trading infrastructure.
Installation
pip install nubra-sdk
Dependencies
-
Python 3.7+
-
pandas
-
websockets
-
requests
Core Features
Market Data
-
Historical Data: Access OHLCV (Open, High, Low, Close, Volume) data with customizable time intervals
-
Market Quotes: Real-time quotes including LTP, LTQ, market depth, and volume
-
Option Chain: Complete option chain data with Greeks, OI, and price information
WebSocket Feeds
-
Ticker Feed: Real-time price updates
-
Market Depth Feed: Live order book updates
-
Option Chain Feed: Real-time option chain updates
Instruments Reference Data
-
Instrument Master: Complete list of tradable instruments
-
Automatic Caching: Daily refresh of instrument data
-
Quick Lookup: Efficient instrument search by various parameters
Example Implementations
Market Data Examples
from nubra_python_sdk.marketdata.market_data import MarketData
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv
# Initialize SDK
nubra = InitNubraSdk(NubraEnv.STAGING)
md = MarketData(nubra)
# Get historical data
historical_data = md.historical_data({
"exchange": "NSE",
"type": "STOCK",
"values": ["HDFCBANK"],
"fields": ["close", "high", "low", "open", "volume"],
"startDate": "2024-01-01T00:00:00.000Z",
"endDate": "2024-01-31T23:59:59.000Z",
"interval": "1d"
})
# Get market quotes
quote = md.quote(ref_id=69353, levels=20)
# Get option chain
option_chain = md.option_chain("NIFTY")
WebSocket Examples
from nubra_python_sdk.ticker.websocketdata import TickerData
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv
# Initialize SDK client
nubra = InitNubraSdk(NubraEnv.STAGING)
ticker_data = TickerData(nubra)
# Subscribe to price ticker
for msg in ticker_data.on_index_data("NIFTY"):
print(f"Symbol: {msg.indexname}")
print(f"Price: {msg.index_value}")
print(f"Volume: {msg.volume}")
print(f"Change: {msg.changepercent}%")
# Subscribe to option chain
for msg in ticker_data.on_optionchain_data("AARTIIND", "20250529"):
print(f"Asset: {msg.asset}")
print(f"Current Price: {msg.currentprice}")
print(f"ATM Strike: {msg.atm}")
# Access call options
for ce in msg.ce:
print(f"CE Strike: {ce.sp}, LTP: {ce.ltpchg}")
print(f"Greeks - Delta: {ce.delta}, Gamma: {ce.gamma}")
# Access put options
for pe in msg.pe:
print(f"PE Strike: {pe.sp}, LTP: {pe.ltpchg}")
print(f"Greeks - Delta: {pe.delta}, Gamma: {pe.gamma}")
# Subscribe to market depth
for msg in ticker_data.on_orderbook_data(351672):
print(f"LTP: {msg.ltp}, Volume: {msg.volume}")
# Access bid orders
for bid in msg.bids:
print(f"Bid - Price: {bid.price}, Quantity: {bid.quantity}")
# Access ask orders
for ask in msg.asks:
print(f"Ask - Price: {ask.price}, Quantity: {ask.quantity}")
Instrument Data Examples
from nubra_python_sdk.refdata.instruments import InstrumentData
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv
# Initialize the Nubra SDK client
nubra = InitNubraSdk(NubraEnv.STAGING)
# Initialize instruments master data with the client
instruments = InstrumentData(nubra)
# Get all instruments as a pandas DataFrame
instruments_df = instruments.get_instruments_dataframe()
# Get instrument by reference ID. Internal Reference ID from Nubra.
instrument = instruments.get_instrument_by_ref_id(69694)
# Get instrument by instrument trading symbol eg: HDFCBANK25MAY2380CE, TATAMOTORS, NIFTY2550822400PE
instrument = instruments.get_instrument_by_symbol("HDFCBANK")
# Get instrument by nubra defined name of instrument eg: STOCK_HDFCBANK.NSECM
instrument = instruments.get_instrument_by_nubra_name("STOCK_HDFCBANK.NSECM")
# Fetch multiple instruments matching the pattern passed
instruments = instruments.get_instruments_by_pattern([{
"exchange": "NSE",
"asset": "NIFTY",
"derivative_type": "OPT",
"expiry":"20250522",
"strike_price": "24000",
"option_type": "CE",
"asset_type": "INDEX_FO"
}]
)
Portfolio Data
from nubra_python_sdk.portfolio.portfolio_data import NubraPortfolio
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv
# Initialize the Nubra SDK client
nubra = InitNubraSdk(NubraEnv.STAGING)
#Initialize the portfolio
portfolio= NubraPortfolio(nubra)
#Get the Positions of Portfolio
portfolio.positions()
#Get the holding of Portfolio
portfolio.holdings()
#Get the funds of your Portfolio
portfolio.funds()
Reports
from nubra_python_sdk.reports.reports_data import NubraReports
from nubra_python_sdk.reports.reports_enum import ReportActionType, ReportExportFormat
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv
# Initialize the Nubra SDK client
nubra = InitNubraSdk(NubraEnv.STAGING)
#Initialize the reports class
reports = NubraReports(nubra)
#Which reports can this client generate, and over what dates
for option in reports.report_options().res.reports:
print(option.type, option.downloadFileTypes, option.minDate, "..", option.maxDate)
#Read a report as JSON — sections are returned as sent, read them with model_dump()
ledger = reports.financial_ledger("2025-04-01", "2025-06-30", action_type=ReportActionType.VIEW)
payload = ledger.model_dump(by_alias=True, exclude_none=True)
print(list(payload)) # ['AccountMaster', 'LedgerDetail']
print(payload["LedgerDetail"]) # List[dict] — feed to pandas if you want
#Download a report (PDF/XLSX) and save it
pdf = reports.financial_ledger("2025-04-01", "2025-06-30",
export_format=ReportExportFormat.PDF, save_to="./reports")
print(pdf.saved_path)
#Email a report to the registered address
reports.profit_loss("2025-04-01", "2025-06-30", action_type=ReportActionType.EMAIL)
#Tax and trade reports
reports.dividend("2025-04-01", "2026-03-31", action_type=ReportActionType.VIEW)
reports.tradebook("2025-04-01", "2025-04-30", save_to="./reports")
reports.trader_diary("2025-04-01", "2025-04-30", save_to="./reports")
reports.portfolio_snapshot(save_to="./reports")
#Mutual fund reports
reports.mf_transactions("2025-04-01", "2025-06-30", action_type=ReportActionType.VIEW)
reports.mf_holdings("2025-07-28", action_type=ReportActionType.VIEW)
reports.mf_capital_gains("2025-04-01", "2025-06-30", save_to="./reports")
Making Trades Through API Call
from nubra_python_sdk.trading.trading_data import NubraTrader
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv
#Initialize the Nubra Sdk Client
nubra = InitNubraSdk(NubraEnv.STAGING)
#Initialize the Nubra Tradong Class
trade= NubraTrader(nubra)
#Create Order
result_create_order= trade.create_order({
"ref_id": 70075,
"request_type": "ORDER_REQUEST_NEW",
"order_type": "ORDER_TYPE_LIMIT",
"order_qty": 1,
"order_price": 720,
"order_side": "ORDER_SIDE_BUY",
"order_delivery_type":"ORDER_DELIVERY_TYPE_IDAY",
"execution_type": "STRATEGY_TYPE_MARKET"
})
#Basket Order
result_basket_order= trade.basket_order([{
"ref_id": 70075,
"request_type": "ORDER_REQUEST_NEW",
"order_type": "ORDER_TYPE_LIMIT",
"order_qty": 1,
"order_price": 720,
"order_side": "ORDER_SIDE_BUY",
"order_delivery_type":"ORDER_DELIVERY_TYPE_IDAY",
"execution_type": "STRATEGY_TYPE_MARKET"
},
{
"ref_id": 70075,
"request_type": "ORDER_REQUEST_NEW",
"order_type": "ORDER_TYPE_LIMIT",
"order_qty": 1,
"order_price": 715,
"order_side": "ORDER_SIDE_BUY",
"order_delivery_type":"ORDER_DELIVERY_TYPE_IDAY",
"execution_type": "STRATEGY_TYPE_MARKET"
}
])
#Modify order
trade.modify_order(order_id=999, order_qty=1, order_price= 1300)
#Get All order
all_orders= trade.orders()
#Get Order by order Id
get_order_by_id= trade.get_order(795)
#Cancel Order
cancel_order= trade.cancel_orders([794, 797])
#Cancel Order by Id
cancel_order_by_id= trade.cancel_order_by_id(999)
Support
If you encounter any issues or have questions, please reach out to Nubra Support at support@nubra.io
Metadata
Release files for nubra-sdk 0.5.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nubra_sdk-0.5.5-py3-none-any.whl | Python 3 | none | any | Details for nubra_sdk-0.5.5-py3-none-any.whl |
Release files / nubra_sdk-0.5.5-py3-none-any.whl
| Download URL | nubra_sdk-0.5.5-py3-none-any.whl |
|---|---|
| Size | 89.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e765cabc1b2ae919856492d12126b5d6640fe0e1a819bc135c83e19c4dc68c4
|
|
BLAKE2b-256 checksum How to use checksums |
d1fe550f5d3cc3c471fd0e5d4b9fe73e2ef69eba2cd043a9a57e4df553728f6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Security for nubra-sdk 0.5.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.