CryptoHopper

CryptoHopper

 

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.

 

Hoppers

 

Manage Basic Hopper Operations.

 

Method Arguments Description
GetHoppers   Get Hoppers of users.
CreateHopper aBody: configuration json text. Create a new Hopper.
GetHopper aId: hopper id Retrieve Hopper
DeleteHopper aId: hopper id Delete Hopper
UpdateHopper aId: hopper id aBody: configuration json text. Update Hopper

 

 

Orders

 

Manage the Orders of your Hopper.

 

Method Arguments Description
GetOpenOrders aId: hopper id Retrieve all of the open orders of the hopper.
CreateNewOrder aId: hopper id aOrder: instance of TsgcHTTPCTHOrder Create new buy or sell order. For sell, rather use the sell endpoint.
PlaceMarketOrder aId: hopper id aOrderSide: cthosBuy or cthosSell. aCoin: coin name, example: EOS aAmount: order size. Place a Market Order.
PlaceLimitOrder aId: hopper id aOrderSide: cthosBuy or cthosSell. aCoin: coin name, example: EOS aAmount: order size.

aPrice: limit price.

Place a Limit Order
DeleteOrder aId: hopper id aOrderId: order id Deletes order for selected hopper.
DeleteAllOrders aId: hopper id Deletes all open order for selected hopper.
GetOpenOrder aId: hopper id aOrderId: order id Get open order in hopper by id.
CancelOrder aId: hopper id aOrderId: order id Cancel an open order.

 

 

Position

 

Manage the Positions of your Hopper.

 

Method Arguments Description
GetPosition aId: hopper id Get open positions of hopper.

 

 

Trade

 

Trade History from your Hopper.

 

Method Arguments Description
GetTradeHistory   Get the trade history of the hopper.
GetTradeHistoryById aId: hopper id aTradeId: trade id Get a trade by id of the hopper.

 

 

Exchange

 

Get Information from available exchanges on CryptoHopper

 

Method Arguments Description
GetExchange   Get all available exchanges on Cryptohopper.
GetAllTickers aExchange: exchange name Get ticker for all pairs
GetMarketTicker aExchange: exchange name aPair: pair name Get ticker from market pair.
GetOrderBook aExchange: exchange name aPair: pair name

aDepth: order book depth

Gets the orderbook for the selected exchange, market and orderbook depth.

 

 

Webhooks

 

Trade History from your Hopper.

 

Method Arguments Description
CreateWebhook aURL: webhook url aMessageTypes: message types sepated by comma. Update or create a Webhook
DeleteWebhook aURL: webhook url Delete an existing Webhook.

 

 

Signals

 

Send Signals to CryptoHopper API.

 

Method Arguments Description
SendSignal aSignal: is the class with all the fields required to send a signal. Sends a Signal
SendTestSignal aSignal: is the class with all the fields required to send a signal. Sends a Test Signal
GetSignalStats aSignalId: id of the signal. aExchange: optional, name of the exchange. Retrieve some of the signal statistics.

 

How Update Cryptohopper Config

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;