Bybit API Cliente V5

· Componentes

The ByBit Client API foi upgraded para V5 version. The following Protocols são suportados:



Propriedades 

Você pode configure como propriedades um seguir no Bybit property.

Conexão 

When o cliente successfully connects para Bybit servers, o evento OnConnect é disparado. After o evento OnConnect é disparado, then você pode iniciar para send and receber mensagens to/from Bybit servers. Se você é connecting para o private websocket channel, você deve wait till OnBybitAuthentication event é disparado e check if o success parameter is true, before inscreva-se em any channel.

O cliente suporta several APIs, so use um propriedade BybitClient para definir which API you want para usar:


Veja abaixo um exemplo de connecting para WebSocket Spot Private API.

oClient := TsgcWebSocketClient.Create(nil);
oBybit := TsgcWSAPI_Bybit.Create(nil);
oBybit.Client := oClient;
oBybit.Bybit.ApiKey := 'alsdjk23kandfnasbdfdkjhsdf';
oBybit.Bybit.ApiSecret := 'aldskjfk3jkadknfajndsjfj23j';
oBybit.BybitClient := bybSpot;
oClient.Active := True;
procedure OnConnect(Connection: TsgcWSConnection);
begin
  DoLog('#Bybit Connected');
end; 

After um bem-sucedido conexão para o Spot servidor WebSocket, você pode iniciar para inscreva-se em WebSocket channels, just access o REST_API property e then call any do subscribe/unsubscribe métodos available 

Inscreva-se em WebSocket Channels 

Veja abaixo um exemplo de subscribing para o Private Spot Websocket Channels after um bem-sucedido autenticação.

oClient := TsgcWebSocketClient.Create(nil);
oBybit := TsgcWSAPI_Bybit.Create(nil);
oBybit.Client := oClient;
oBybit.Bybit.ApiKey := 'alsdjk23kandfnasbdfdkjhsdf';
oBybit.Bybit.ApiSecret := 'aldskjfk3jkadknfajndsjfj23j';
oBybit.BybitClient := bybSpot;
oClient.Active := True;
procedure OnBybitAuthentication(Sender: TObject; aSuccess: Boolean; const aError, aRawMessage: string)
begin
  if aSuccess then
  begin
    oClient.SubscribeOrderBook('BTCUSDT');
    oClient.SubscribeTrade('BTCUSDT');
  end;
end; 

Colocar Ordens 

Veja abaixo um exemplo de Placing um Market Order

oClient := TsgcWebSocketClient.Create(nil);
oBybit := TsgcWSAPI_Bybit.Create(nil);
oBybit.Client := oClient;
oBybit.Bybit.ApiKey := 'alsdjk23kandfnasbdfdkjhsdf';
oBybit.Bybit.ApiSecret := 'aldskjfk3jkadknfajndsjfj23j';
oBybit.BybitClient := bybSpot;
oBybit.REST_API.PlaceMarketOrder('BTCUSDT', bbosBuy, 1); 

Compiled Windows Bybit Demo

Download um compiled Bybit Client API Demo para Windows that shows o main features do sgcWebSockets Bybit API Client. https://www.esegece.com/download/protocols/sgcBybit.zip