Binance | Trade Spot

Binance allows to trade with spot using his REST API.

 

Configuration

First you must create an API Key in your binance account and add privileges to trading with Spot.

Once this is done, you can start spot trading.

First, set your ApiKey and your ApiSecret in the Binance Client Component, this will be used to sign the requests sent to Binance server.

 

Place an Order

To place a new order, just call to method REST_API.NewOrder of Binance Client Component.

 

Depending of the type of the order (market, limit...) the API requires more or less fields.

 

Mandatory Fields

 

 

Additional Mandatory Fields based on Type

 

 

When you send an order, there are 2 possibilities:

 

1. Successful: the function NewOrder returns the message sent by binance server.

2. Error: the exception is returned in the event OnBinanceHTTPException.

 

 

Place Market Order 1 BNBBTC


oBinance := TsgcWSAPI_Binance.Create(nil);
oBinance.Binance.ApiKey := '<api key>';
oBinance.Binance.ApiSecret := '<api secret>';
ShowMessage(oBinance.REST_API.NewOrder('BNBBTC', 'BUY', 'MARKET', '', 1));

 

Place Limit Order 1 BNBBTC at 0.009260


oBinance := TsgcWSAPI_Binance.Create(nil);
oBinance.Binance.ApiKey := '<api key>';
oBinance.Binance.ApiSecret := '<api secret>';
ShowMessage(oBinance.REST_API.NewOrder('BNBBTC', 'BUY', 'LIMIT', 'GTC', 1, 0, 0.009260));