From sgcWebSockets 2022.6.0 OKX Crypto Broker is supported, OKX, formerly known as OKEx, is one of the largest crypto spot and derivatives trading exchanges. OKX is a Seychelles-based cryptocurrency exchange that provides a platform for trading various instruments such as spot and derivative. Some of the exchange's core features include spot and derivative trading.
sgcWebSockets supports the WebSocket API including the Public and Private Channels. Placing orders is also supported.
WebSocket channels are divided into two categories: public and private channels.
You can configure the following properties in the OKS property.
When the client successfully connects to OKX servers, the event OnOKXConnect is fired. If there is any error while trying to connect, the event OnOKXError will be fired with the error details.
After the event OnOKXConnect is fired, then you can start to send and receive messages from OKX servers.
oClient := TsgcWebSocketClient.Create(nil); oOKX := TsgcWSAPI_OKX.Create(nil); oOKX.Client := oClient; oOKX.OKX.ApiKey := 'alsdjk23kandfnasbdfdkjhsdf'; oOKX.OKX.ApiSecret := 'aldskjfk3jkadknfajndsjfj23j'; oOKX.OKX.Passphrase := 'secret_passphrase'; oClient.Active := True; procedure OnOKXConnect(Sender: TObject; aMessage, aCode, aRawMessage: string); begin DoLog('#OKX Connected'); end; procedure OnOKXError(Sender: TObject; aCode, aMessage, aRawMessage: string); begin DoLog('#error: ' + aMessage); end;
The websocket feed provides real-time market data updates for orders and trades. The websocket feed has some public channels like ticker, trades...
oClient := TsgcWebSocketClient.Create(nil); oOKX := TsgcWSAPI_OKX.Create(nil); oOKX.Client := oClient; oOKX.OKX.ApiKey := 'alsdjk23kandfnasbdfdkjhsdf'; oOKX.OKX.ApiSecret := 'aldskjfk3jkadknfajndsjfj23j'; oOKX.OKX.Passphrase := 'secret_passphrase'; oClient.Active := True; procedure OnOKXConnect(Sender: TObject; aMessage, aCode, aRawMessage: string); begin oOKX.SubscribeInstruments(okxitFutures); end;
You can place an order only if you have sufficient funds.
// Place Martket Order TsgcWSAPI_OKX1.PlaceMarketOrder(okxosBuy, 'ETH-BTC', 1); // Place Limit Order TsgcWSAPI_OKX1.PlaceLimitOrder(okxosBuy, 'ETH-BTC', 1, 0.25);
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.