How to access streaming data and store it?

조회 수: 1 (최근 30일)
Francisco
Francisco 2016년 5월 20일
댓글: pedro galan feliubadalo 2018년 3월 23일
Hello, I'm a newbie in MATLAB and I want to retrieve financial streaming data and using it with MATLAB.
I know how to get this data using curl:
C:\>curl -k -H "Authorization: Bearer 137529d301a65re3a32b00ee2c94b8f3-72ffdf45bb72dacy72w40fc67b6b9fbfa" "https://stream-fxpractice.oanda.com/v1/prices?accountId=1234567&instruments=AUD_CAD%2CAUD_CHF"
And the data looks like this:
{"tick":{"instrument":"AUD_CAD","time":"2016-05-20T08:31:03.770867Z","bid":0.94756,"ask":0.94784}}
{"tick":{"instrument":"AUD_CHF","time":"2016-05-20T08:30:58.241559Z","bid":0.71726,"ask":0.71753}}
{"heartbeat":{"time":"2016-05-20T08:31:05.298930Z"}}
{"tick":{"instrument":"AUD_CAD","time":"2016-05-20T08:31:07.084095Z","bid":0.94756,"ask":0.94783}}
{"tick":{"instrument":"AUD_CAD","time":"2016-05-20T08:31:07.595119Z","bid":0.94756,"ask":0.94781}}
{"heartbeat":{"time":"2016-05-20T08:31:07.770028Z"}}
{"tick":{"instrument":"AUD_CAD","time":"2016-05-20T08:31:08.326162Z","bid":0.94756,"ask":0.9478}}
{"tick":{"instrument":"AUD_CAD","time":"2016-05-20T08:31:09.211011Z","bid":0.94756,"ask":0.94781}}
{"tick":{"instrument":"AUD_CAD","time":"2016-05-20T08:31:09.580424Z","bid":0.94756,"ask":0.94784}}
{"heartbeat":{"time":"2016-05-20T08:31:10.258639Z"}}
{"heartbeat":{"time":"2016-05-20T08:31:12.770908Z"}}
JSON Response Fields:
tick:
instrument: Name of the instrument.
time: Time in a valid datetime format.
bid: Bid price
ask: Ask price
heartbeat:
time: Time in a valid datetime format.
How can I retrieve this streaming data using MATLAB?
Cheers.
Francisco

채택된 답변

Guillaume
Guillaume 2016년 5월 20일
The equivalent would probably be:
queryoptions = weboptions('KeyName', 'Authorization', ...
'KeyValue', 'Bearer 137529d301a65re3a32b00ee2c94b8f3-72ffdf45bb72dacy72w40fc67b6b9fbfa', ...
'ContentType', 'json');
jsondata = webread('https://stream-fxpractice.oanda.com/v1/prices', ...
'accountId', 1234567, ...
'instruments', 'AUD_CAD''CAUD_CHF#', ...
queryoptions)
However, I don't think there's a way to tell matlab to ignore certificate errors (your -k option in curl), so if the website certificate is not valid (why?) then you may need to install that invalid certificate on your machine or degrade to http connection.
  댓글 수: 4
Francisco
Francisco 2016년 5월 29일
Thanks a lot!
pedro galan feliubadalo
pedro galan feliubadalo 2018년 3월 23일
Hi Francisco,
How did you manage to make it work?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Web Services from MATLAB Using HTTP에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by