Crypto-ML offers API access as part of the Crypto-ML Pro Solutions.

API Overview

Crypto-ML provides a WebSocket API. Once connected, you will receive output from our machine learning models.

The WebSocket connection is designed to stay open until your client terminates the connection. That means a ping or “keep-alive” mechanism is not required from the client in order to keep the connection up.

Using this method, each end client receives notifications immediately.

Crypto-ML API WebSocket Diagram - Multi-Connection

Account Provisioning

After registering for an API account, your organization will receive an API Key. This key will allow for a defined number of concurrent sessions.

API Details

Following are technical details for using the API.

API Access URL

 wss://api.crypto-ml.com?apiKey=YOUR_API_KEY

Sample Payloads

Market Index

Every 24 hours, the client receives updated Market Index data, including the current value and the 7-day trend.

Market Index samples:

{"bullBear":"BULL 13.56","_7dayTrend":"Bull market weakening."}
{"bullBear":"BULL 19.62","_7dayTrend":"Bull market strengthening."}
{"bullBear":"BEAR -0.55","_7dayTrend":"Bear market strengthening."}
{"bullBear":"BEAR -6.07","_7dayTrend":"Bear market weakening."}

Trade Alerts

As real-time trade alerts are issued, the data will be instantly streamed.

Long trade samples:

{"side":"sell", "productCode":"BTC-USD", "price":"9543.01", "time":"2020-02-24T18:38:01.6484377Z"}
{"side":"sell", "productCode":"ETH-USD", "price":"267.32", "time":"2020-02-24T09:23:25.7622456Z"}
{"side":"buy", "productCode":"BTC-USD", "price":"9891.77","time":"2020-02-23T05:37:39.2429824Z", "trailingStop": "-0.0391574244145524", "buyTrigger":"1.93027140343837", "tslAdjust":"-0.008", "nnValue":"2.28368686168124"}
{"side":"buy", "productCode":"ETH-USD", "price":"264.56", "time":"2020-02-22T01:22:42.2901814Z", "trailingStop":"-0.0397119140625", "buyTrigger":"3.07325747536978", "tslAdjust":"-0.00591409301757813", "nnValue":"5.20176589036058"}

Details as follows:

  • side: denotes the “open long” or “close long” trigger event as buy or sell
  • productCode: denotes the product pair the trigger is for as BTC-USD, ETH-USD, or BCH-USD.
  • price: the USD value at which the trigger was generated.
  • time: the time in UTC (Zulu) at which the trigger was generated.
  • trailingStop: the initial value of the Trailing Stop as set by Crypto-ML optimizers. If the value is -0.0397, then the Trailing Stop is 3.97% lower than the price. On the Crypto-ML backend, the Trailing Stop follows price up but never goes down.
  • buyTrigger: in order to trigger a buy signal, the Neural Network prediction must be higher than the buyTrigger. The buyTrigger is set by Crypto-ML optimizers. Additionally, once a position’s profit crosses the buyTrigger level, the trailingStop tightens (see tslAdjust) on the Crypto-ML backend.
  • tslAdjust: as open trades move into a sufficiently profitable position, the Trailing Stop will tighten in order to better protect profit. On the Crypto-ML backend, once the trade’s profit is greater than buyTrigger (expressed as a percentage), the trailingStop will be reduced by the value of the tslAdjust as set by the Crypto-ML optimizers.
  • nnValue: the price prediction from the Crypto-ML Neural Network at the time the trigger was generated. On the Crypto-ML backend, this value is the profit target. If the position’s profit hits this value, the trade will be closed.

Price Prediction

At established intervals (hourly), the client receives the latest price prediction notification. This predicts price change 24 hours from now.

{"crypto":"BCH","prediction":"-1.11818200055202"}
{"crypto":"ETH","prediction":"2.0081892310937706"}
{"crypto":"BTC","prediction":"3.1410159507567874"}
{"crypto":"USD-BTC","prediction":"-1.1088362598972528"}

JavaScript Client Sample

The following code creates a simple JavaScript client that opens the WebSocket connection and receives updates from Crypto-ML’s Streaming API.

Similar clients can be written in other languages.

It is recommended to write your WebSocket client so that if it disconnects for any reason, re-connection logic will initiate. The retry logic should keep running until the connection is reestablished.

<head>
<script>
socket = new WebSocket("wss://api.crypto-ml.com?apiKey=YOUR_API_KEY");
socket.onopen = function(e) {
  console.log("Connection established");  
};
socket.onmessage = function(event) {
  console.log("Data received from server:"+ event.data);
};
socket.onclose = function(event) {
  if (event.wasClean) {
    console.log("Connection closed cleanly, code="+event.code+",reason="+event.reason);
  } else {  
    console.log("Connection died");
  }
};
socket.onerror = function(error) {
  console.log("error:"+ error.message);
};
</script>
</head>

Ready to Get Started?

Learn more and sign up now at Crypto-ML Pro Solutions.