Frage

Searching for some long time to find anybody providing the mcx real time data to display in our website. I couldn't find an appropriate data provider. Suggest me if there any sites providing data to direct display in website.

All the sites i searched are ready to provide the data to software and charting platforms like Amibroker. But we need only the data to display in our website only..

War es hilfreich?

Lösung

Stock Exchange Real-time MCX Data Stream for Website and Mobile App Display

⚠️ ALERT: REPOSITORY DEPRICATED ⚠️

Note: This document is referencing a fully completed example source code you may find here: https://github.com/pubnub/javascript/blob/master/examples/stock-ticker-mcx/stock.html

Test the Stock Ticker MCX Data Stream Example

Note: Test the live version now! - http://pubnub-demo.s3.amazonaws.com/stock-ticker-mcx/stock.html

When you are seeking a Data Network provider for Real-time socket streaming solutions for Indian Stock Exchange or other Stock Exchanges, you'll want to consider different network streaming patterns that fit the MCX stock broadcast nature. One pattern that makes sense is publish and subscribe frameworks that will be available to you in customized Data Schemas, typically in JSON.

Eventually, though we will not cover this in this posting answer, you can create Line Graphs in Real-time too! - See this images below.

Stock Exchange Real-time MCX Data Stream for Website and Mobile App Display

Because you are talking about websites and web-apps you will be interested in two things such as WebSockets and a Globally Distributed Network Provider that will allow you to stream the data for Stock Quotes/Tickers. The best data link display provider will provide you the most powerful and robust solution. Step one is opening a socket streaming connection in your web-app/website, followed by sending Below is a starting point for your Web App:

Open Browser TCP Socket Stream

<!-- Stock Ticker Update DIV -->
<div id="ticker">1,552.80</div>

<!-- Ticker Stream Interafce Code -->
<script src="http://cdn.pubnub.com/pubnub-3.4.3.min.js"></script>
<script>(function(){

    // Init MCX Stream
    var stream = PUBNUB.init({ subscribe_key : 'demo' });
    var ticker = "TCS";

    // Update Interface
    function quote_update(quote) {
        stream.$("ticker").innerHTML = JSON.stringify(quote);
    }

    // Open Socket To Receive Streaming Ticker Updates
    // Bind inbound data to our quote_update() function.
    stream.subscribe({
        channel : ticker,
        message : quote_update
    })

})();</script>

This code above will open a socket stream for receiving Stock Ticker updates on the website. Next we will use the MCX-SX provider to pull the data on your server. From your Server you will make requests to the MCX-SX servers to pull the data that is going to be pushed to your website. Here is their Data Scheme URL interfaces:

<!-- Interface Display Update DIV -->
<!-- curl http://services.mcx-sx.com/srvlnk.xml -->

<root>
    <url key="currencyurl">
        <value>http://services.mcx-sx.com/chartservice.svc/cd/{charttype}/{symbol}/{series}/{expiry}/{instrumenttype}/{optiontype}/{strikeprice}</value>
    </url>
    <url key="equityurl">
        <value>http://services.mcx-sx.com/chartservice.svc/eq/line/{symbol}/{series}/{expiry}/2/xx/0</value>
    </url>
    <url key="equitypreopenurl">
        <value>http://services.mcx-sx.com/chartservice.svc/eq/preo/{symbol}/{series}/{expiry}/2</value>
    </url>
    <url key="equityindexurl">
        <value>http://services.mcx-sx.com/chartservice.svc/eq/idx/{symbol}/nm</value>
    </url>
    <url key="equitypreopenindexurl">
        <value>http://services.mcx-sx.com/chartservice.svc/eq/idx/{symbol}/po</value>
    </url>
    <url key="equityderivativesurl">
        <value>http://services.mcx-sx.com/chartservice.svc/eds/{charttype}/{symbol}/{series}/{expiry}/{instrumenttype}/{optiontype}/{strikeprice}</value>
    </url>
    <url key="currencyhistoricalurl">
        <value>http://services.mcx-sx.com/chartservice.svc/cd/{charttype}/{symbol}/{series}/{expiry}/{instrumentname}/{optiontype}/{strikeprice}/{startdate}/{enddate}</value>
    </url>
</root>

Take the URL interfaces above and issue curl commands. Here is an example URL:

curl http://services.mcx-sx.com/chartservice.svc/eq/line/TCS/EQ/1577836800/2/xx/0

And the output response result:

{"Expiry":null,"InstrumentName":null,"OptionType":null,"StrikePrice":0,"cmonth":"JAN2020","comparison":null,"date":1364860800,"hline":null,"line":[{"c":"1551.80","t":34008,"v":250},{"c":"1551.90","t":34064,"v":500},{"c":"1547.85","t":34160,"v":250},{"c":"1551.00","t":34255,"v":250},{"c":"1550.65","t":34550,"v":250},{"c":"1549.30","t":34684,"v":250},{"c":"1544.20","t":35272,"v":250},{"c":"1544.60","t":35328,"v":253},{"c":"1546.00","t":35858,"v":250}],"ohlcv":null,"oi":null,"pcp":1553.4,"rbi":0,"secdesc":"TATA CONSULTANCY SERV LTD","series":"EQ ","symbol":"TCS","vol":null}

You would take this result JSON value and Publish to the Ticker Symbol with the following commands:

curl "http://pubsub.pubnub.com/publish/demo/demo/0/TCS/0/%7B%22Expiry%22%3Anull%2C%22InstrumentName%22%3Anull%2C%22OptionType%22%3Anull%2C%22StrikePrice%22%3A0%2C%22cmonth%22%3A%22JAN2020%22%2C%22comparison%22%3Anull%2C%22date%22%3A1364860800%2C%22hline%22%3Anull%2C%22line%22%3A%5B%7B%22c%22%3A%221551.80%22%2C%22t%22%3A34008%2C%22v%22%3A250%7D%2C%7B%22c%22%3A%221551.90%22%2C%22t%22%3A34064%2C%22v%22%3A500%7D%2C%7B%22c%22%3A%221547.85%22%2C%22t%22%3A34160%2C%22v%22%3A250%7D%2C%7B%22c%22%3A%221551.00%22%2C%22t%22%3A34255%2C%22v%22%3A250%7D%2C%7B%22c%22%3A%221550.65%22%2C%22t%22%3A34550%2C%22v%22%3A250%7D%2C%7B%22c%22%3A%221549.30%22%2C%22t%22%3A34684%2C%22v%22%3A250%7D%2C%7B%22c%22%3A%221544.20%22%2C%22t%22%3A35272%2C%22v%22%3A250%7D%2C%7B%22c%22%3A%221544.60%22%2C%22t%22%3A35328%2C%22v%22%3A253%7D%2C%7B%22c%22%3A%221546.00%22%2C%22t%22%3A35858%2C%22v%22%3A250%7D%5D%2C%22ohlcv%22%3Anull%2C%22oi%22%3Anull%2C%22pcp%22%3A1553.4%2C%22rbi%22%3A0%2C%22secdesc%22%3A%22TATA%20CONSULTANCY%20SERV%20LTD%22%2C%22series%22%3A%22EQ%20%22%2C%22symbol%22%3A%22TCS%22%2C%22vol%22%3Anull%7D"

It is best after reviewing these steps to checkout the live demo here: https://github.com/pubnub/javascript/blob/master/examples/stock-ticker-mcx/stock.html

And the source code is here: https://github.com/pubnub/javascript/blob/master/examples/stock-ticker-mcx/stock.html

Hurray!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top