Binance allows to trade with spot using his REST API.
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.
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
Symbol: the product id symbol, example: BNBBTC
Side: BUY or SELL
type: the order type
LIMIT
MARKET
STOP_LOSS
STOP_LOSS_LIMIT
TAKE_PROFIT
TAKE_PROFIT_LIMIT
LIMIT_MAKER
Additional Mandatory Fields based on Type
LIMIT: timeInForce, quantity, price
MARKET: quantity or quoteOrderQty
STOP_LOSS / TAKE_PROFIT: quantity, stopPrice
STOP_LOSS_LIMIT / TAKE_PROFIT_LIMIT: timeInForce, quantity, price, stopPrice
LIMIT_MAKER: quantity, price
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));