为网站显示提供MCX实时数据的网站?

时间:2013-03-28 10:16:28

标签: web datafeed real-time-data

搜索了很长时间,找到任何提供mcx实时数据的人在我们的网站上显示。我找不到合适的数据提供者。建议我是否有任何网站提供数据直接在网站上显示。

我搜索过的所有网站都准备好向Amibroker等软件和图表平台提供数据。但我们只需要在我们的网站上显示数据..

1 个答案:

答案 0 :(得分:2)

用于网站和移动应用显示的证券交易所实时MCX数据流

  

⚠️ALERT:DEPOSITORYDEPRICATED⚠️

     

注意:本文档引用了您可以在此处找到的完整示例源代码:https://github.com/pubnub/javascript/blob/master/examples/stock-ticker-mcx/stock.html

测试股票代码MCX数据流示例

  

注意:立即测试实时版本! - http://pubnub-demo.s3.amazonaws.com/stock-ticker-mcx/stock.html

当您为印度证券交易所或其他证券交易所寻求实时套接字流解决方案的数据网络提供商时,您需要考虑适合MCX股票广播性质的不同网络流模式。一个有意义的模式是publishsubscribe框架,您可以在自定义数据模式中使用这些模式,通常使用JSON。

最终,虽然我们不会在此帖子中回答这个问题,但您也可以实时创建折线图! - 请参阅下面的图片。

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

因为您正在谈论网站和网络应用,所以您会对WebSockets和全球分布式网络提供商这两项内容感兴趣,这些内容将允许您流式传输股票行情/代码的数据。最好的数据链接显示提供商将为您提供最强大,最强大的解决方案。第一步是在您的网络应用程序/网站中打开套接字流连接,然后发送以下是您的Web应用程序的起点:

打开浏览器TCP套接字流

<!-- 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>

上面的代码将打开一个套接字流,用于在网站上接收Stock Ticker更新。接下来,我们将使用MCX-SX提供程序提取服务器上的数据。从您的服务器,您将向MCX-SX服务器发出请求,以提取将要推送到您网站的数据。这是他们的数据方案URL接口:

<!-- 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>

使用上面的URL接口并发出curl命令。以下是一个示例网址:

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

输出响应结果:

{"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}

您可以使用以下命令将此结果JSON值和Publish带到Ticker Symbol:

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"

最好在查看这些步骤后查看现场演示: https://github.com/pubnub/javascript/blob/master/examples/stock-ticker-mcx/stock.html

源代码在这里: https://github.com/pubnub/javascript/blob/master/examples/stock-ticker-mcx/stock.html

乌拉!