我正在尝试将交易视图图表库实施到我的有角项目中,并使用来自Crypto Compare槽式Web套接字的数据。
我仔细阅读了文档,发现它有点混乱。
我需要创建自己的自定义Datafeed对象吗?如果可以,那么怎么办?
一般来说,如果有人举了一个例子,那就太好了。
提前Tnx!
修改
我正在添加我的窗口小部件配置对象,我想了解为了从CryptoCompare获取数据我应该更改什么:
const widgetOptions: ChartingLibraryWidgetOptions = {
symbol: this._symbol,
datafeed: new (window as any).Datafeeds.UDFCompatibleDatafeed(this._datafeedUrl),
interval: this._interval,
container_id: this._containerId,
library_path: this._libraryPath,
locale: 'en',
disabled_features: ['use_localstorage_for_settings'],
enabled_features: ['study_templates'],
charts_storage_url: this._chartsStorageUrl,
charts_storage_api_version: this._chartsStorageApiVersion,
client_id: this._clientId,
user_id: this._userId,
fullscreen: this._fullscreen,
autosize: this._autosize,
};
我应该更改哪些参数才能访问加密比较数据?
Tnx
答案 0 :(得分:1)
使用JS Api tradingview,在subscribeBars中,您可以使用onRealtimeCallback实现websocket
this.subscribeBars = function (symbolInfo, resolution, onRealtimeCallback, subscribeUID, onResetCacheNeededCallback) {
$scope.$on('handleBroadcastDfn', function () {
if (symbolInfo.id === dfnData.message.symbol) {
onRealtimeCallback(
{
time: lastData.time,
close: dfnData.message.ask,
open: lastData.open,
low: lastData.low,
high: lastData.high, volume: 0
});
}
});
}