Downloading historical trading pair data on BINANCE using Matlab.

조회 수: 5 (최근 30일)
Jan-Hendrik Smith
Jan-Hendrik Smith 2021년 4월 5일
답변: Satyam 2025년 2월 10일
Hi. I need to download the historical funding data for each of the crypto pairs from the Binance website https://www.binance.com/en/futures/funding-history/1 The trading pairs can be selected on the website, and then a download button already exists that allows for downloading the .csv file. I know this will probably be easier in python but I am not familiar with python. I basically just want to write a Matlab script that automatically selects one pair after another and then downloads the default amount of data similar to when you will manually click on the download button.
Any ideas would be appreciated.
  댓글 수: 1
Abolfazl Nejatian
Abolfazl Nejatian 2021년 5월 25일
dear Jan,
did you find a way to put order in binance from the matlab platform?

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

답변 (1개)

Satyam
Satyam 2025년 2월 10일
Hi there,
To download historical funding data using MATLAB, you can start by identifying the URL, request body, and options for the API call. Once you have those details, you can use the webwrite function in MATLAB to specify the HTTP URL and the content as name-value pairs. For more information on how to use webwrite, you can check out the following MathWorks documentation https://www.mathworks.com/help/releases/R2021a/matlab/ref/webwrite.html
Additionally, you might need to include HTTP request options, which can be specified using the weboptions object and passing it as an argument to the webwritefunction call. API calls often require the request body in JSON format, so you can use jsonencodeobject to convert your data into JSON. More details on jsonencode can be found: https://www.mathworks.com/help/releases/R2021a/matlab/ref/jsonencode.html
Here's a sample code snippet to help you get started with downloading the historical funding data using a MATLAB script:
httpsUrl = '<YOUR-API-URL>';
options = weboptions("RequestMethod", "post", 'ContentType', 'json', 'MediaType', 'application/json');
pair = '<CRYPTO-PAIR>';
requestBody = struct("symbol", pair, "page", 1, "rows", 10000);
jsonRequest = jsonencode(requestBody);
data = webwrite(httpsUrl, jsonRequest, options);
fundingTable = struct2table(data.data);
writetable(fundingTable, "Funding_Rates_" + pair + ".csv");
Feel free to adjust the script according to your specific requirements.
I hope this helps!

카테고리

Help CenterFile Exchange에서 Downloads에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by