如何在我的网站中集成交易视图图表库
How to integrate trading view charting library in my website
我正在建立一个比特币交易网站。我想使用交易视图 charting library 我将其提取到我的工作区中。我想知道如何提供我自己的数据馈送。数据馈送文件应采用哪种格式(如 php、js、json)?
var _datafeed = new Datafeeds.UDFCompatibleDatafeed("http://localhost/workspace/charting");
//var _datafeed = new Datafeeds.UDFCompatibleDatafeed("https://demo_feed.tradingview.com");
TradingView.onready(function () {
var widget = window.tvWidget = new TradingView.widget({
debug: true, // uncomment this line to see Library errors and warnings in the console
fullscreen: false,
symbol: 'A',
interval: 'D',
timezone: "America/New_York",
container_id: "tv_chart_container",
locale: getParameterByName('lang') || "en",
datafeed: _datafeed,
library_path: "charting_library/",
});
});
在上面的代码中,图表是用演示 link 绘制的。当我将其更改为我的路径时,出现 'invalid symbol' 错误。我在哪里指定 config 和 symbol_info 以及它们的文件格式是什么?我是个新手。请帮忙。
任何以正确方式移动的建议都将受到赞赏。我卡住了!!
Screen shot of error message
您应该在图表库的文件夹中编写一个 php 文件和 .htaccess。 htaccess 应该将对该文件夹的所有请求重写到该 php 文件。然后在那个 php 文件中以 UDF 格式回显结果。
UDF format and required api calls with sample result
更新:交易视图图表库是一个私有存储库。所以你需要同意他们的条款才能访问 github.
上的图书馆和维基页面
根据此页面https://www.tradingview.com/widget/advanced-chart/您不需要添加任何库,只需添加以下引用:
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
两个嵌套 div:
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container" style="top:0px; left: 0px; height:50%; width:50%;">
<div id="tradingview_99b08"></div>
</div>
<!-- TradingView Widget END -->
And set it with a script like this:
<script type="text/javascript">
new TradingView.widget(
{
"autosize": true,
"symbol": "FX:EURUSD",
"interval": "D",
"timezone": "exchange",
"theme": "Light",
"style": "0",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"allow_symbol_change": true,
"container_id": "tradingview_99b08"
}
);
</script>
希望对您有所帮助
此致
为节点 API 尝试这个,它运行良好:
https://github.com/bergusman/tradingview-udf-binance-node
对于前端,您需要 tradingview 的 git 存储库访问权限。
我正在建立一个比特币交易网站。我想使用交易视图 charting library 我将其提取到我的工作区中。我想知道如何提供我自己的数据馈送。数据馈送文件应采用哪种格式(如 php、js、json)?
var _datafeed = new Datafeeds.UDFCompatibleDatafeed("http://localhost/workspace/charting");
//var _datafeed = new Datafeeds.UDFCompatibleDatafeed("https://demo_feed.tradingview.com");
TradingView.onready(function () {
var widget = window.tvWidget = new TradingView.widget({
debug: true, // uncomment this line to see Library errors and warnings in the console
fullscreen: false,
symbol: 'A',
interval: 'D',
timezone: "America/New_York",
container_id: "tv_chart_container",
locale: getParameterByName('lang') || "en",
datafeed: _datafeed,
library_path: "charting_library/",
});
});
在上面的代码中,图表是用演示 link 绘制的。当我将其更改为我的路径时,出现 'invalid symbol' 错误。我在哪里指定 config 和 symbol_info 以及它们的文件格式是什么?我是个新手。请帮忙。
任何以正确方式移动的建议都将受到赞赏。我卡住了!!
Screen shot of error message
您应该在图表库的文件夹中编写一个 php 文件和 .htaccess。 htaccess 应该将对该文件夹的所有请求重写到该 php 文件。然后在那个 php 文件中以 UDF 格式回显结果。
UDF format and required api calls with sample result
更新:交易视图图表库是一个私有存储库。所以你需要同意他们的条款才能访问 github.
上的图书馆和维基页面根据此页面https://www.tradingview.com/widget/advanced-chart/您不需要添加任何库,只需添加以下引用:
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
两个嵌套 div:
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container" style="top:0px; left: 0px; height:50%; width:50%;">
<div id="tradingview_99b08"></div>
</div>
<!-- TradingView Widget END -->
And set it with a script like this:
<script type="text/javascript">
new TradingView.widget(
{
"autosize": true,
"symbol": "FX:EURUSD",
"interval": "D",
"timezone": "exchange",
"theme": "Light",
"style": "0",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"allow_symbol_change": true,
"container_id": "tradingview_99b08"
}
);
</script>
希望对您有所帮助
此致
为节点 API 尝试这个,它运行良好:
https://github.com/bergusman/tradingview-udf-binance-node
对于前端,您需要 tradingview 的 git 存储库访问权限。