Delphi CryptoHopper Client

From sgcWebSockets 4.5.1 CryptoHopper API is partially supported. CryptoHopper it's an automated crypto trading bot that allows to automate trading and portfolio management for Bitcoin, Ethereum, Litecoin and more.

Configuration 

Requires a Developer Account and once you have been approved you can start to create a new App. The API uses OAuth2 to authenticate, so you can retrieve the client_id and client_secret from your App.

oCryptoHopper := TsgcHTTP_Cryptohopper.Create(nil);
oCryptoHopper.CryptoHopperOptions.OAuth2.ClientId := 'client_id';
oCryptoHopper.CryptoHopperOptions.OAuth2.ClientSecret := 'client_secret';
oCryptoHopper.CryptoHopperOptions.OAuth2.LocalIP := '127.0.0.1';
oCryptoHopper.CryptoHopperOptions.OAuth2.LocalPort := 8080;
oCryptoHopper.CryptoHopperOptions.OAuth2.Scope.Text := "read,notifications,manage,trade"; 

Methods 

CryptoHopper uses HTTPs as the protocol to send Requests to the API. Some methods requires authentication (place orders, retrieve user data...) and some others are public (get exchange data for example).

The functions returns the CryptoHopper response and if there is any error an exception will be raised.

Some of the methods supported are the following:

  • GetOpenOrders
  • CreateNewOrder
  • DeleteOrder
  • GetPosition
  • GetTradeHistory
  • GetMarketTicker
  • GetOrderBook


How update Hopper Configuration 

Use the UpdateHopper method to update the Hopper Configuration. The method is overloaded so you can pass the JSON string or use the object TsgcHTTPCTHopper and use the properties to enable or disable the Hopper Properties.

function EnableHopper: string;
var
  oHopper: TsgcHTTPCTHopper;
begin
  oHopper := TsgcHTTPCTHopper.Create;
  Try
    if Cryptohopper.GetHopper('1234', oHopper) then
    begin 
      oHopper.Enabled := 1;
      result := Cryptohopper.UpdateHopper('1234', oHopper);
    end;
  Finally
    FreeAndNil(oHopper);
  End;
end; 

How configure Webhook 

Webhook allows to receive notifications when something happens in a hopper. Webhooks require a public HTTPs Server which will listen in a URL address all messages sent by cryptohopper. The public server needs to be protected with a SSL certificate (self-signed certificates are not allowed).

First you must create a webhook, so configure the Webhook property of Cryptohopper client setting the Host and Port when the server will be listening. Then configure the certificate in SSLOptions property.

Example: The public IP address will be 1.1.1.1 and the listening port will be 443. The certificate is stored as PEM file with sgc.pem filename and without password.

/* OAuth2 */
cryptohopper.CryptohopperOptions.OAuth2.ClientId = 'client_id';
cryptohopper.CryptohopperOptions.OAuth2.ClientSecret := 'client_secret';
cryptohopper.CryptohopperOptions.OAuth2.LocalIP := '127.0.0.1';
cryptohopper.CryptohopperOptions.OAuth2.LocalPort := 8080;

/* Webhook */
cryptohopper.CryptohopperOptions.Webhook.Enabled := True;
cryptohopper.CryptohopperOptions.Webhook.Host := '1.1.1.1';
cryptohopper.CryptohopperOptions.Webhook.Port := 443;
cryptohopper.CryptohopperOptions.Webhook.ValidationCode := '1234';
cryptohopper.CryptohopperOptions.Webhook.SSLOptions.CertFile := 'sgc.pem';
cryptohopper.CryptohopperOptions.Webhook.SSLOptions.KeyFile := 'sgc.pem';
cryptohopper.CryptohopperOptions.Webhook.SSLOptions.RootCertFile := 'sgc.pem';
cryptohopper.CryptohopperOptions.Webhook.SSLOptions.Password := '';

cryptohopper.StartWebhook; 
×
Stay Informed

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.

sgcWebSockets 4.5.1
Delphi RCON Client

Related Posts