API Reference
Complete reference documentation for all PyArrow SDK classes, methods, and constants.
ArrowClient
The main client class for interacting with Arrow Trading APIs.
Initialization
| Parameter | Type | Required | Description |
|---|---|---|---|
app_id |
string | ✓ | Your application identifier |
Authentication Methods
login()
Exchange request token for access token.
| Parameter | Type | Required | Description |
|---|---|---|---|
request_token |
string | ✓ | Token from OAuth callback |
api_secret |
string | ✓ | Your application secret |
Returns: Dict[str, str] - User data with access token
auto_login()
Automated login with credentials and TOTP.
response = client.auto_login(
user_id="user_id",
password="password",
api_secret="api_secret",
totp_secret="totp_secret"
)
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id |
string | ✓ | User ID |
password |
string | ✓ | Account password |
api_secret |
string | ✓ | Application secret |
totp_secret |
string | ✓ | Base32 TOTP secret |
Returns: Dict[str, str] - User data with access token
login_url()
Get the OAuth login URL.
Returns: str - Login URL
set_token()
Manually set the access token.
| Parameter | Type | Required | Description |
|---|---|---|---|
token |
string | ✓ | Access token |
Returns: None
get_token()
Get the current access token.
Returns: str - Current access token
invalidate_session()
Clear the current session.
Returns: None
Order Methods
place_order()
Place a new trading order.
order_id = client.place_order(
exchange=Exchange.NSE,
symbol="RELIANCE-EQ",
quantity=1,
disclosed_quantity=0,
product=ProductType.CNC,
order_type=OrderType.LIMIT,
variety=Variety.REGULAR,
transaction_type=TransactionType.BUY,
price=1450.0,
validity=Retention.DAY
)
| Parameter | Type | Required | Description |
|---|---|---|---|
exchange |
Exchange | ✓ | Exchange (NSE, BSE, NFO, BFO) |
symbol |
string | ✓ | Trading symbol |
quantity |
int | ✓ | Order quantity |
disclosed_quantity |
int | ✓ | Disclosed quantity (0 for none) |
product |
ProductType | ✓ | Product type (MIS, CNC, NRML) |
order_type |
OrderType | ✓ | Order type (MKT, LIMIT, SL_LMT, SL_MKT) |
variety |
Variety | ✓ | Order variety (REGULAR, COVER) |
transaction_type |
TransactionType | ✓ | Buy or Sell |
price |
float | ✓ | Order price (0 for market) |
validity |
Retention | ✓ | Order validity (DAY, IOC) |
trigger_price |
float | - | Trigger price for SL orders |
remarks |
string | - | Custom order tag |
Returns: str - Order ID
modify_order()
Modify an existing open order.
message = client.modify_order(
order_id="24012400000321",
exchange=Exchange.NSE,
symbol="RELIANCE-EQ",
quantity=2,
price=1500.0,
disclosed_qty=0,
product=ProductType.CNC,
transaction_type=TransactionType.BUY,
order_type=OrderType.LIMIT,
validity=Retention.DAY,
remarks="Modified"
)
| Parameter | Type | Required | Description |
|---|---|---|---|
order_id |
string | ✓ | Order ID to modify |
exchange |
Exchange | ✓ | Exchange |
symbol |
string | ✓ | Trading symbol |
quantity |
int | ✓ | New quantity |
price |
float | ✓ | New price |
disclosed_qty |
int | ✓ | Disclosed quantity |
product |
ProductType | ✓ | Product type |
transaction_type |
TransactionType | ✓ | Transaction type |
order_type |
OrderType | ✓ | Order type |
validity |
Retention | ✓ | Order validity |
remarks |
string | - | Custom remarks |
Returns: str - Modification message
cancel_order()
Cancel a pending order.
| Parameter | Type | Required | Description |
|---|---|---|---|
order_id |
string | ✓ | Order ID to cancel |
Returns: str - Cancellation message
cancel_all_orders()
Cancel all open/pending orders.
Returns: List[Tuple] - List of (order_id, status, result) tuples
get_order_details()
Get detailed order history.
| Parameter | Type | Required | Description |
|---|---|---|---|
order_id |
string | ✓ | Order ID |
Returns: List[Dict] - Order history with status changes
get_order_book()
Get all orders for the day.
Returns: List[Dict] - All user orders
get_trade_book()
Get all executed trades.
Returns: List[Dict] - All user trades
Portfolio Methods
get_positions()
Get current positions.
Returns: List[Dict] - Current positions
get_holdings()
Get delivery holdings.
Returns: Dict - Holdings data
User Methods
get_user_details()
Get user profile information.
Returns: Dict - User profile data
get_user_limits()
Get margin and trading limits.
Returns: List[Dict] - User limits by segment
Margin Methods
order_margin()
Calculate margin for a single order.
margin = client.order_margin(
exchange=Exchange.NSE,
symbol="RELIANCE-EQ",
quantity=100,
product=ProductType.CNC,
order_type=OrderType.LIMIT,
transaction_type=TransactionType.BUY,
price=1500.0,
include_positions=False
)
| Parameter | Type | Required | Description |
|---|---|---|---|
exchange |
Exchange | ✓ | Exchange |
symbol |
string | ✓ | Trading symbol |
quantity |
int | ✓ | Order quantity |
product |
ProductType | ✓ | Product type |
order_type |
OrderType | ✓ | Order type |
transaction_type |
TransactionType | ✓ | Buy or Sell |
price |
float | ✓ | Order price |
include_positions |
bool | - | Include existing positions |
Returns: Dict - Margin requirement
basket_margin()
Calculate margin for multiple orders.
orders = [
{
"exchange": "NSE",
"symbol": "RELIANCE-EQ",
"quantity": "100",
"product": ProductType.CNC,
"order": OrderType.LIMIT,
"transactionType": TransactionType.BUY,
"price": "1500.00"
}
]
margin = client.basket_margin(orders, include_positions=False)
| Parameter | Type | Required | Description |
|---|---|---|---|
orders |
List[Dict] | ✓ | List of order dictionaries |
include_positions |
bool | - | Include existing positions |
Returns: Dict - Combined margin requirement
Market Data Methods
get_quote()
Get quote for a single instrument.
| Parameter | Type | Required | Description |
|---|---|---|---|
mode |
QuoteMode | ✓ | Quote mode (LTP, OHLCV, FULL) |
symbol |
string | ✓ | Trading symbol |
exchange |
Exchange | ✓ | Exchange |
Returns: Dict - Quote data
get_quotes()
Get quotes for multiple instruments.
quotes = client.get_quotes(
QuoteMode.LTP,
symbols=[("RELIANCE-EQ", Exchange.NSE), ("INFY-EQ", Exchange.NSE)]
)
| Parameter | Type | Required | Description |
|---|---|---|---|
mode |
QuoteMode | ✓ | Quote mode |
symbols |
List[Tuple] | ✓ | List of (symbol, exchange) tuples |
Returns: List[Dict] - Quote data for all symbols
candle_data()
Get historical candle data.
candles = client.candle_data(
exchange=Exchange.NSE,
token="3045",
interval="5min",
from_timestamp="2024-01-15T09:15:00",
to_timestamp="2024-01-15T15:30:00",
oi=False
)
| Parameter | Type | Required | Description |
|---|---|---|---|
exchange |
Exchange | ✓ | Exchange |
token |
string | ✓ | Instrument token |
interval |
string | ✓ | Candle interval |
from_timestamp |
string | ✓ | Start timestamp (ISO format) |
to_timestamp |
string | ✓ | End timestamp (ISO format) |
oi |
bool | - | Include Open Interest |
Intervals: min, 3min, 5min, 15min, 30min, hour, day
Returns: Dict - Candle data
get_instruments()
Get all tradable instruments.
Returns: Any - List of instruments
get_holidays()
Get market holidays.
Returns: Dict - Holiday calendar
get_index_list()
Get available indices.
Returns: List[Dict] - Index listings
get_option_chain_symbols()
Get option chain symbols.
Returns: Any - Option chain symbols
get_expiry_dates()
Get expiry dates for options (static method).
| Parameter | Type | Required | Description |
|---|---|---|---|
symbol |
string | ✓ | Underlying symbol |
year |
int | ✓ | Year |
Returns: Any - Expiry dates
ArrowStreams
WebSocket streaming class for real-time data.
Initialization
from pyarrow import ArrowStreams
streams = ArrowStreams(
appID="your_app_id",
token="your_access_token",
debug=True
)
| Parameter | Type | Required | Description |
|---|---|---|---|
appID |
string | ✓ | Application ID |
token |
string | ✓ | Access token |
debug |
bool | - | Enable debug logging |
Connection Methods
| Method | Description |
|---|---|
connect_order_stream() |
Connect to order updates |
connect_data_stream() |
Connect to market data |
connect_all() |
Connect to both streams |
disconnect_all() |
Disconnect all streams |
get_status() |
Get connection status |
Subscription Methods
| Method | Description |
|---|---|
subscribe_market_data(mode, tokens) |
Subscribe to market data |
unsubscribe_market_data(mode, tokens) |
Unsubscribe from data |
Event Handlers
Data Stream Events
| Event | Parameters | Description |
|---|---|---|
on_ticks |
MarketTick |
Market data received |
on_connect |
None | Connection established |
on_disconnect |
None | Connection lost |
on_error |
Exception |
Error occurred |
on_close |
close_status_code, close_msg |
Connection closed |
on_reconnect |
attempt, delay |
Reconnection attempt |
on_no_reconnect |
None | Max attempts reached |
Order Stream Events
| Event | Parameters | Description |
|---|---|---|
on_order_update |
Dict |
Order status changed |
Constants
Exchange
from pyarrow import Exchange
Exchange.NSE # National Stock Exchange
Exchange.BSE # Bombay Stock Exchange
Exchange.NFO # NSE F&O
Exchange.BFO # BSE F&O
OrderType
from pyarrow import OrderType
OrderType.MKT # Market Order
OrderType.LIMIT # Limit Order
OrderType.SL_LMT # Stop Loss Limit
OrderType.SL_MKT # Stop Loss Market
ProductType
from pyarrow import ProductType
ProductType.MIS # Intraday
ProductType.CNC # Cash and Carry (Delivery)
ProductType.NRML # Normal (F&O)
TransactionType
Variety
Retention
QuoteMode
from pyarrow import QuoteMode
QuoteMode.LTP # Last Traded Price
QuoteMode.OHLCV # OHLC + Volume
QuoteMode.FULL # Full market depth
DataMode
from pyarrow import DataMode
DataMode.LTPC # LTP + Close (17 bytes)
DataMode.QUOTE # Detailed quote (93 bytes)
DataMode.FULL # Full depth (241 bytes)
MarketTick Properties
| Property | Type | Mode | Description |
|---|---|---|---|
token |
int | All | Instrument token |
ltp |
float | All | Last traded price |
mode |
str | All | Data mode |
close |
float | All | Previous close |
net_change |
float | All | % change |
change_flag |
int | All | 43(+), 45(-), 32(=) |
open |
float | Quote+ | Open price |
high |
float | Quote+ | High price |
low |
float | Quote+ | Low price |
volume |
int | Quote+ | Volume |
ltq |
int | Quote+ | Last traded qty |
avg_price |
float | Quote+ | Average price |
total_buy_quantity |
int | Quote+ | Total buy qty |
total_sell_quantity |
int | Quote+ | Total sell qty |
ltt |
datetime | Quote+ | Last trade time |
time |
datetime | Quote+ | Timestamp |
oi |
int | Quote+ | Open interest |
oi_day_high |
int | Quote+ | OI day high |
oi_day_low |
int | Quote+ | OI day low |
upper_limit |
float | Full | Upper circuit |
lower_limit |
float | Full | Lower circuit |
bids |
List | Full | 5 bid levels |
asks |
List | Full | 5 ask levels |
Error Codes
| Code | Description |
|---|---|
INVALID_TOKEN |
Invalid or expired access token |
INVALID_APP_ID |
Invalid application ID |
MARGIN_ERROR |
Insufficient margin |
INVALID_ORDER |
Invalid order parameters |
ORDER_NOT_FOUND |
Order ID not found |
RATE_LIMIT |
API rate limit exceeded |
EXCHANGE_ERROR |
Exchange connectivity issue |