Primary reason for this is that all brokers have “API limits” set. So you cannot fetch position data every single second, doing so will breach the API limits & your broker may even take action like blocking your API or trading account.
PnL calculation is not straightforward especially for overnight positions. This is because the calculation formula changes from broker to broker as they have different formats of position book data.
Hence we avoid calculating live inside user’s browser. The other approach to load reliable and accurate PnL values is to load it from broker in the position book response. However, there is a limit on how many requests we can send to your broker.
The primary reason is safeguard your stock brokers servers from excess load.
We need to limit the number requests being sent to your stock broker. Let us understand it further with an example:
- Let’s assume a user has 10 live accounts in AutoTrader Web
- We set auto-refresh interval to be 5 seconds
- Now every 5 seconds there will be 10 requests sent to the broker
- Although 10 requests per 5 seconds is a small number, but it increases as user adds more accounts
- Now many times, some of these requests are wasting server resource of your broker, because a user might not see the refreshed data every 5 seconds (if he is away from the screen or working on something else)
- Each broker sets a limit on how many requests can be sent to it for a specific time interval (called API limits)
- The manual refresh option helps to take away unnecessary load from your broker’s servers
- Also there is a possibility of auto-refresh interfering with your trading. Say you selected some orders for cancellation & just as you are about to press cancel button auto-refresh happens. All of your selection will go away as the table has been refreshed
- We also give API services for automation, those users are sending repeated requests. Now, if API automation users also start using dashboard; that will result in too many repeated requests if auto-refresh is kept ON on the dashboard
- Hence, we have made sure that the trading dashboard refreshes on two events:
- Whenever a user takes an action (place/modify/cancel/square-off). The dashboard is automatically refreshed
- Otherwise, the user clicks on given a REFRESH button on the top which refreshes the dashboard via AJAX without reloading the entire page