Bitmex API
Bitmex WebSocket and REST client — public market data plus authenticated trading and position streams.
Bitmex WebSocket and REST client — public market data plus authenticated trading and position streams.
Bitmex is a cryptocurrency exchange and derivative trading platform.
TsgcWSAPI_Bitmex| Standards & specs | Bitmex API explorer |
| Component class | TsgcWSAPI_Bitmex (unit sgcWebSocket_API_Bitmex) |
| Frameworks | VCL, FireMonkey, Lazarus / FPC, .NET |
| Platforms | Windows, macOS, Linux, iOS, Android |
The principal published / public properties used to configure and drive the component. Consult the online help for the full list.
Client | Published or public property used to configure or query the component. |
OnBitmexSubscribed | Published or public property used to configure or query the component. |
OnBitmexUnsubscribed | Published or public property used to configure or query the component. |
OnBitmexAuthenticated | Published or public property used to configure or query the component. |
OnConnect | Published or public property used to configure or query the component. |
OnBitmexConnect | Published or public property used to configure or query the component. |
OnBitmexMessage | Published or public property used to configure or query the component. |
OnBitmexError | Published or public property used to configure or query the component. |
OnDisconnect | Published or public property used to configure or query the component. |
OnBitmexHTTPException | Published or public property used to configure or query the component. |
The principal public methods exposed by the component.
Subscribe() | Public procedure exposed by the component. |
Unsubscribe() | Public procedure exposed by the component. |
Authenticate() | Public procedure exposed by the component. |
CancelAllAfter() | Public procedure exposed by the component. |
Drop the component on a form, configure the properties below and activate it. The snippet that follows shows the typical Bitmex | Connect WebSocket API configuration sourced from the online help.
oClient := TsgcWebSocketClient.Create(nil); oBitmex := TsgcWSAPI_Bitmex.Create(nil); oBitmex .Client := oClient; oClient.Active := True;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex(); oBitmex->Client = oClient; oClient->Active = true;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex(); oBitmex.Client = oClient; oClient.Active = true;
The following scenarios are lifted verbatim from the online help. Each shows the configuration and method calls needed to drive the component through a specific real-world flow.
Bitmex offers a variety of channels where you can subscribe to get real-time updates of market data, orders... Find below a sample of how subscribe to a Trade Channel:
oClient := TsgcWebSocketClient.Create(nil); oBitmex := TsgcWSAPI_Bitmex.Create(nil); oBitmex.Client := oClient; oBitmex.Subscribe(btmTrade, 'XBTUSD'); procedure OnBitmexMessage(Sender: TObject; const aTopic: TwsBitmexTopics; const aMessage: string); begin // here you will receive the trade updates end;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex(); oBitmex->Client = oClient; oBitmex->Subscribe(btmTrade, "XBTUSD"); void OnBitmexMessage(Sender: TObject; const aTopic: TwsBitmexTopics; const aMessage: string) { // here you will receive the trade updates }
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex(); oBitmex.Client = oClient; oBitmex.Subscribe(btmTrade, "xbtusd"); void OnBitmexMessage(Sender: TObject; const aTopic: TwsBitmexTopics; const aMessage: string) { // here you will receive the tradeupdates }
The Bitmex REST API offer public and private endpoints. The Private endpoints require that messages are signed to increase the security of transactions.
// buy market order BITMEX.REST_API.PlaceMarketOrder(bmosBuy, 'XBTUSD', 100); // sell limit order at 45000 BITMEX.REST_API.PlaceLimitOrder(bmosSell, 'XBTUSD', 100, 45000.00); // stop order at 48000 BITMEX.REST_API.PlaceStopOrder(bmosSell, 'XBTUSD', 100, 48000.00);
// buy market order BITMEX->REST_API->PlaceMarketOrder(bmosBuy, "XBTUSD", 100); // sell limit order at 45000 BITMEX->REST_API->PlaceLimitOrder(bmosSell, "XBTUSD", 100, 45000.00); // stop order at 48000 BITMEX->REST_API->PlaceStopOrder(bmosSell, "XBTUSD", 100, 48000.00);
// buy market order BITMEX.REST_API.PlaceMarketOrder(bmosBuy, "XBTUSD", 100); // sell limit order at 45000 BITMEX.REST_API.PlaceLimitOrder(bmosSell, "XBTUSD", 100, 45000.00); // stop order at 48000 BITMEX.REST_API.PlaceStopOrder(bmosSell, "XBTUSD", 100, 48000.00);
Every external claim links back to a primary source. The online-help references decode the canonical deep-link the company maintains for this component.
Demos\05.Crypto\06.Bitmex
.net\demos\05.Crypto\06.Bitmex