Algo Trading Backend: mStock Type A User Integration -- 2

Job ID: 39746601

Budget: ₹12,500 – ₹37,500 INR

Algo Trading Integration: mStock Type A – User Module
Overview

Aapko ek aisa algo-trading backend chahiye jo mStock’s Type A User APIs ka use karke authentication, session management aur user account operations ko seamlessly handle kare.

Requirements
1. Authentication & Session Management

API Key Generation:
mStock account se API key generate karna; ye key sab API calls mein header ke through pass hona chahiye
Trading API
+1
.

Login Flow:
connect/login endpoint pe username + password post kar ke OTP trigger karna, phir OTP accept kar ke access token retrieve karna
Trading API
.

Session Token:
session/token endpoint se API Key, request token aur checksum use karke session token (access_token, refresh_token, enctoken etc.) generate karna
Trading API
.

Logout:
logout endpoint se access_token invalidation karo aur clean session exit ensure karo
Trading API
.

2. User Fund Management

Fund Summary Endpoint:
user/fundsummary GET request se user ka cash, margin, available balance, collateral etc. retrieve karna. Header mein Authorization: token api_key:access_token pass karna zaroori hai
Trading API
.

3. Error Handling & Validation

Handle common error types effectively:

APIKeyException (403): Invalid/expired API Key
Trading API

TokenException (401): Missing or invalid JWT token
Trading API

InputException (400): Bad request / missing parameters
Trading API

MiraeException / GeneralException: Internal server or platform-level errors
Trading API

Technical Details

Headers to Include:

X-Mirae-Version: 1 required in all requests
Trading API
+1
.

Content-Type: Usually application/x-www-form-urlencoded for login/session; application/json elsewhere
Trading API
+1
.

Authorization: token api_key:access_token pattern for protected endpoints
Trading API
+1
.

Security Notes:

API Key must be securely stored—never expose in client code
Trading API
.

Access Token expires by midnight daily, so design daily refresh logic accordingly
Trading API
.

Sample Job Description
**Role:** Algo Trading Backend Developer
**Module:** mStock Type A – User Authentication & Session

**Key Responsibilities:**
- Set up mStock API key generation and secure storage.
- Implement login flow:
- POST to `/connect/login` with username/password to trigger OTP.
- POST to `/session/token` with API key, request token, checksum to receive session tokens.
- Fetch user fund details via `/user/fundsummary` endpoint.
- Logout functionality via `/logout` to invalidate session.
- Handle API errors: APIKeyException, TokenException, InputException, MiraeException, GeneralException.
- Ensure headers (`X-Mirae-Version`, `Content-Type`, `Authorization`) are correctly implemented.
- Schedule daily token refresh since access tokens expire at midnight.
- Ensure API Key and tokens are handled securely—no exposure in client-side code.

**Deliverables:**
- Well-tested Python/Node.js module for User authentication & session management.
- Detailed README with setup instructions, API usage examples (cURL/axios/requests).
- Error handling and automated token refresh implementation.

**Tech Stack:** Python or Node.js, REST API, JWT, secure credential management


Agar aap chaho, toh main is module ke baad Orders, Portfolio ya Market Data bhi isi tarah summarize karke job post mein add kar sakta hoon. Let me know!

References:

Authentication flow & endpoints (login, session, logout, fund summary)
Trading API

Headers, API key/token validity, BOD/EOD notes
Trading API

Error types and handling guidance
Trading API