How can I post an order request via API?

6 ビュー (過去 30 日間)
Fabio Barbosa
Fabio Barbosa 2018 年 4 月 6 日
回答済み: Brendan Hamm 2018 年 4 月 16 日
I'm having this issue with posting order requests to an exchange API.
In python the request would be:
import requests
orderData = {'symbol':'ethbtc', 'side': 'sell', 'quantity': '0.063', 'type': 'market', 'timeInForce': 'GTC'}
r ='', data = orderData, auth=('ff20f250a7b3a414781d1abe11cd8cee', 'fb453577d11294359058a9ae13c94713'))
And in cURL:
curl -X POST "" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "symbol=ethbtc&side=sell&type=market&timeInForce=GTC&quantity=0.063"
I've already figured out the authentication process, but I can't seem to specify the request body. In python it is the orderData dictionary, but what about MatLab?
Thanks in advance!
  2 件のコメント
Fabio Barbosa
Fabio Barbosa 2018 年 4 月 6 日
Sorry not to make it clear before but those are NOT my keys. They're generic keys from the code provided by the exchange's API git.


回答 (1 件)

Brendan Hamm
Brendan Hamm 2018 年 4 月 16 日

Hi Fabio,

Without a pair of keys myself I cannot duplicate the auth portion of this. I suspect this woudl be done with the username and password inputs of weboption For the remainder, all of the API is just using GET and POST methods. These can be accomplished with the webread function. As an example consider the API interface for returning the candles info (GET method):

r = webread('','limit',200,'period','M1')

The above returns a structure with the 1 minute interval high, low, open, close, etc. for the ETHBTC pair. As you can see each of the fields is a different input to the webread command. The webread command defaults to GET method, whereas the webwrite function uses POST method, although there are option sin the weboptions as well. Again, without the keys I cannot exactly produce the desired resutls, but you should have something similar to:

r = webwrite('',...
     'quantity', 0.063,...


Community Treasure Hunt

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

Start Hunting!

Translated by