2

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

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

4

1 回答 1

2

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

⚠️ 警告:仓库已被销毁⚠️

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

测试 Stock Ticker MCX 数据流示例

注意:现在测试现场版本!- http://pubnub-demo.s3.amazonaws.com/stock-ticker-mcx/stock.html

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

最终,尽管我们不会在此发布答案中介绍这一点,但您也可以实时创建线图!- 请参阅下面的图片。

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

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

打开浏览器 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>

上面的代码将打开一个套接字流,用于在网站上接收股票代码更新。接下来,我们将使用 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}

Publish您可以使用以下命令将此结果 JSON 值和股票代码:

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

欢呼!

于 2013-04-02T03:49:06.830 回答