7. Market Order
Quick execution at current market price (MP)
Objective
Place market orders for quick execution at current market price, without specifying a price.
Flow
Quick Trade → Trading Matching Engine (via API) → PortfolioSample Code — Sync
from ssi_sdk import Auth, Trading, Config
from ssi_sdk.enums import OrderSide
from auth_helper import ensure_auth
from helpers import enum_value
config = Config(
client_id="<your_client_id>",
api_key="<your_api_key>",
api_secret="<your_api_secret>",
private_key="<your_private_key>",
)
ACCOUNT_NO = "<your_account_no>"
with Auth(config) as auth:
ensure_auth(auth, otp="<your_otp>")
with Trading(auth) as trading:
max_bs = trading.trading.get_max_buy_sell_at_market_price(ACCOUNT_NO, "SSI")
result = trading.trading.place_market_order(
account_no=ACCOUNT_NO, symbol="SSI",
side=OrderSide.BUY, quantity=100,
)
orders = trading.portfolio.get_today_orders(ACCOUNT_NO)
for order in orders[-3:]:
print(
f" {order.order_id} | {order.symbol} {enum_value(order.side)} "
f"| Filled: {order.filled_quantity} | Status: {enum_value(order.status)}"
)
balance = trading.portfolio.get_equity_balance(ACCOUNT_NO)
print(f" Available cash: {balance.account_balance:,.0f}")Sample Code — Async
import asyncio
from ssi_sdk import AsyncAuth, AsyncTrading, Config
from ssi_sdk.enums import OrderSide
from auth_helper import ensure_auth_async
config = Config(...)
ACCOUNT_NO = "<your_account_no>"
async def main():
async with AsyncAuth(config) as auth:
await ensure_auth_async(auth, otp="<your_otp>")
async with AsyncTrading(auth) as trading:
result = await trading.trading.place_market_order(
account_no=ACCOUNT_NO, symbol="SSI",
side=OrderSide.BUY, quantity=100,
)
orders, balance, positions = await asyncio.gather(
trading.portfolio.get_today_orders(ACCOUNT_NO),
trading.portfolio.get_equity_balance(ACCOUNT_NO),
trading.portfolio.get_equity_positions(ACCOUNT_NO),
)
asyncio.run(main())Limit vs Market Comparison
| Limit Order | Market Order | |
|---|---|---|
| Price | Specified price | Current market price |
| Execution speed | Waits for liquidity | Immediate if liquidity exists |
| Risk | May not execute | May execute at unfavorable price |
| Method | place_limit_order(price=...) | place_market_order() |