connect Matlab to Binance API

18 ビュー (過去 30 日間)
Abolfazl Nejatian
Abolfazl Nejatian 2021 年 5 月 25 日
回答済み: Asghar Moeini 2022 年 7 月 21 日
Hey everyone,
i am seeking for a solution to put an order with Binance API.
if anyone has experience in this field or has knowledge of posting a request please let me know.
here is my code
% Set up authentication:
APIKey = '12a2fff338b41101ed886dd1c0ef4f35e96fe0233d23616daed4f2dbd1389526';
APISecret = '3d52b16aa7a0c6cd12fd11e09a955967cfeb839fd729357a0ca272351da75873';
symbol = 'BTCUSDT';
type = 'limit'; % or 'market'
side = 'sell'; % or 'buy'
amount = 1.0;
price = 60540; % or None
options = weboptions('RequestMethod',apiMethod, 'MediaType','application/json');
Body = struct('symbol', symbol, ...
'type', type, ...
'side', side, ...
'amount', char(num2str(amount)), ...
'price', char(num2str(price)), ...
'APIKey', APIKey,...
'APISecret', APISecret);
webaddress = '';
response = webwrite(webaddress, Body, options);
kind regrads,
  2 件のコメント
Turlough Hughes
Turlough Hughes 2021 年 7 月 9 日
Assuming you've deactivated your keys?


回答 (2 件)

Turlough Hughes
Turlough Hughes 2021 年 7 月 8 日
Try my recent submission to the file exchange: MATLAB-Binance-API
Then placing a limit order is simply:
obj = spot.newOrder('limit');
response = obj.send;
or with the syntax that came in R2020a (which I'm a big fan of) you could also write:
response = obj.send;
Note: this order sells 0.001 btc from your spot account (not testnet) and assumes you have 0.001 BTC on your books.
  4 件のコメント
Turlough Hughes
Turlough Hughes 2021 年 7 月 9 日
No, I haven't tried anything similar tbh. Most of my interest has been on arbitrage and backtesting other strategies.


Asghar Moeini
Asghar Moeini 2022 年 7 月 21 日
I would be grateful if you share your code for futures trade.

Community Treasure Hunt

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

Start Hunting!

Translated by