Python SDK
The public Python SDK package is layr0-IMC and the import package is layr0_imc.
pip install layr0-IMC
import layr0_imc
client = layr0_imc.api(
api_key="YOUR_API_KEY",
host="http://127.0.0.1:5000",
)
PositionsOpen
Use positionsopen for strategy exposure reconciliation.
result = client.positionsopen(
strategy="Test Strategy",
symbol="SBIN",
exchange="NSE",
product="CNC",
expected_mode="live",
expected_balance_type="live",
expected_mode_version=7,
request_id="positionsopen-001",
)
There is no legacy open-position method in the IMC SDK.
Close Reconciliation
close_result = client.closeposition(
strategy="Test Strategy",
expected_mode="live",
expected_balance_type="live",
expected_mode_version=7,
request_id="close-001",
)
verify = client.positionsopen(
strategy="Test Strategy",
symbol="SBIN",
exchange="NSE",
product="CNC",
expected_mode="live",
expected_balance_type="live",
expected_mode_version=7,
request_id="close-verify-001",
)
verify["quantity"] == 0 means the strategy is flat for the submitted symbol/product.
WebSocket Reliability
The SDK uses a shared HTTP client for REST calls and can reconnect WebSocket feeds automatically:
client = layr0_imc.api(
api_key="YOUR_API_KEY",
ws_url="ws://127.0.0.1:8765",
auto_reconnect=True,
)
When reconnect succeeds, active LTP, quote, and depth subscriptions are replayed.