In order to make API functions independent, we hide the implementation details of each broker from our API users. In other words, our API users use functions that do not contain anything broker specific. The API implementation which is provided by us, internally checks for the trading platform from trading account settings. Once a trading platform is identified, that specific implementation is used. It can be best explained with an example.
The detailed documentation for each of the API function is here.
Broker Independent API Function
placeOrder("PSEUDO_ACC_ID", "NSE", "BANKNIFTY_28-MAY-2020_CE_25000", "BUY", "LIMIT", "INTRADAY", 20, 230.55, 0);
If you look at above function, it does not use anything which is broker specific. It is obvious that the code above is going to place an order as per the parameters passed. Some parameters mentioned below may appear to be broker specific, but they are not. See details below,
- “PSEUDO_ACC_ID” – It is not the id of actual trading account. It is more of a dummy or pseudo account, which is internally mapped in settings to the actual trading account. If you want to change stock broker, simply map it to another trading account. More details of broker independent accounts are provided in next chapter.
- “BANKNIFTY_28-MAY-2020_CE_25000” – The symbols differ across brokers mainly for derivative contracts. This symbol is also not specific to a broker. It is a broker independent symbol, which the system automatically maps to the broker specific symbol when placing an order. Using this independent format means, even if you change the trading account from one broker to another; there is no need to change symbols in your strategy code. More details of broker independent symbols/instruments are provided in next chapter.