Question

I want to create a homepage that shows live stock charts. I also want to install a screener function for some indicators. Therefore I need to have live stock data of about some thousand companies. The data I want to obtain should be received in a really short time period (something like 5 sec). And the harsh part is that I want to receive them all at one in that short time period and save them in table for some other functions. I just found some ways to get CSV data from yahoo or something like that. But this method is to slow for the time period presuppose.

I don't know exactly if there is a general term for this method, but I would be really happy for getting some information about some ways to get the solution for this problem.

Was it helpful?

Solution

At least for the front-end, you'll need to implement an ajax routine that pulls stock data and populates your page accordingly - you would stick this ajax routine in a setInterval javascript call (set for every 5s). That way you'll get real-time updates without having to refresh the page.

As for the back-end - I'm not up to date with stock-quote websites, but I wouldn't be surprised if one of the bigger ones had a free API you can access via. a server-side language with PHP - however I'm not sure as to the minimum interval they would provide for free - anyway, this is the script your javascript/ajax routine would be calling.

OTHER TIPS

You need to implement web socket server or user web socket api to fetch data. There are several api which provide stock exchange data. Here is my suggestion.

  1. NodeJS server with Socket.io
  2. Socket client with either iOS, android, javascript, Angular, java.

On NodeJS server you can retrieve stocks data from api check this link for example. Once you have data you cam emit it via socket and on client side you can listen for events.

Use case using bittrex and NodeJS server.

bittrex.websockets.client(function() {
 console.log('Websocket connected');
   bittrex.websockets.subscribe(['BTC-ETH'], function(data) {
     if (data.M === 'updateExchangeState') {
       data.A.forEach(function(data_for) {
         console.log('Market Update for '+ data_for.MarketName, data_for);
      });
    }
  });
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top