Many a times we / #algotrading folks have had this question in our mind what if we had multiple different strategy running in separate processes (or have multiple strategy python scripts) and we need WebSocket data feed to each one of those strategy process running individually
However, our brokers allow 1-3 WebSocket connection at any given time, So the obvious question lies ahead of us is how to solve this problem.
The Answer to this question isn't straight as we can have multiple way out of this problem, and nothing is the best or worst, every
single solution will come with its own tradeoff, so we need to see which tradeoff is acceptable to us and won't affect us drastically which can have an adverse effect on our strategies.
The Simplest of all with negligible tradeoffs shall be having a
Local WebSocket Mirror & Broadcast Server.
So, You Need To Setup Like This:
- Initiate and Persist a Single WebSocket Connection with the broker with all the required instruments subscribed in FullQuote mode.
- And in your ticker WebSocket on_message method / function
instead of parsing the incoming packet, just forward the received binary / text packets to local WebSocket Server.
- In Your Individual Strategy Scripts, instead of connecting to the broker WebSocket feed, connect to the local WebSocket Mirror & Broadcast Server.
With this method you can share one broker API WebSocket with any number of individual strategy process / scripts without exhausting API resources and making no concessions with the performance or WebSocket data feed speed.
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Market orders offer aggressive fills regardless of price impact, sometimes better than limit orders. Stick with limit orders for passive fills at desired prices, or mix both for strategic execution.
It's a deep topic, and I'm still a rookie with a little experience, so if
@pythontrader999 Thank you for the kind words bhai 🙏. However, I forgot to mention that I have only discussed the NSE. Let me also attach tweets on the BSE LPP Mechanism, which is slightly different from NSE.
While the reference price calculation is almost similar to what NSE does based on the
@pythontrader999 simple average of trade prices in that contract in the last 30 seconds, the LPP calculation mechanism is significantly different from the NSE one.
In BSE, Limit price orders within the Limit Protection Price (LPP) range (higher for buy orders & lower for sell orders) of 60% of
@pythontrader999 the reference price for Option contracts (subject to minimum LPP value of Rs 30) and 3% of reference price for Future Contracts (subject to minimum LPP value of Rs 1.50) shall be accepted by the trading system and orders beyond this price range would get rejected.
@pythontrader999 When you place a SLL (Stop Limit) order, it is initially placed in the exchange's SL Trigger Book. As soon as its trigger point is breached, the exchange will perform a Limit Price Protection (LPP) validation on your SL limit order before moving it from the SL Trigger Book to the
@pythontrader999 RL (Regular Lot) book for matching and fill at the price you defined as the limit price.
It's important to note that when you place a SLL order, LPP validation is conducted. If the order is triggered later, another LPP validation is done. If either of these validations fails,
@pythontrader999 your SLL order will be rejected.
However, if the first LPP validation passes and your SLL order reaches the exchange, sitting in the SLT (Stop Limit Trigger) book waiting to be triggered, and then it is triggered, the exchange will perform another LPP validation before