How to Build a Cryptocurrency Trading Bot With the Coygo API
Continue reading for the original guide.
Building a cryptocurrency bot can be challenging. You need access to real-time information without latency from a number of different exchange websocket APIs, you need to manage orders with REST APIs to each exchange, and a number of other things that require a lot of work and coding. Today I’ll be demonstrating how the Coygo API, a node.js package provided by Coygo, makes this process very easy and let’s developers focus on what matters most.
Here’s a quick summary of the Coygo API, we’ll go into more details below:
This is the same API that powers the Coygo application. Real-time cryptocurrency price feeds & order books, transferring between exchanges, submitting and manage trade orders, portfolio tracking, everything you see in the Coygo app is available via our API.
Coygo application screenshot
What is the Coygo API?
The Coygo API is a node.js package for building cryptocurrency trading bots, but it can do so much more.
The Coygo API connects your machine directly to each exchange for zero-latency access, Coygo’s servers don’t act as a middleman. That means that order book data is stored in memory on your machine, and all trades and API interactions are submitted directly from your device.
You import the library into your node.js codebase and use it however you see fit for developing systems such as trading bots, dashboards, real-time analytics systems, and more. You decide where and how to store your API keys, our servers never touch your API keys or your accounts.
Why the Coygo API?
The Coygo API provides a standardized way to interact with every supported exchange, you get to focus on what’s important and we simplify the rest. No middelman means no latency, and all data is available with real-time websockets when possible. As is standard with all Coygo products, our server’s **never **have access to your API keys or accounts.
Code walk through
Let’s go through a few examples of how to use the API.
Setting up your exchange clients
First you’ll need to set up a client to interact with an exchange, or a number of exchanges. In this example we’ll set up Kraken, Coinbase Pro, and Bittrex with our API keys and then create a client to interact with Kraken.
Create real-time trade stream listener for the BTC-USD market
Say we want to analyze trades as they happen in real-time, so that we can detect price changes as part of our strategy. We can register a real-time listener that gets updates for each trade as they happen, as well as the recent trading history that’s occurred on the market.
Listen for real-time order book updates as well
Analyzing order book data can be helpful for a number of reasons. You can inspect each order to figure out the true cost of a potential order, or you can gauge how much overall interest there is in a market by how much money is locked up in orders. Let’s listen for order book updates in real-time with a fully replicated order book in local memory.
Submit a trade
Alright, now let’s assume that you like the current state of the order book sand current trading trend and you want to place an order, this time on the BTC-ETH market. We can do that easily, and it’s the same API when trading on every exchange.
Transfer between exchanges
Sometimes you need to transfer a coin between exchanges. Maybe you need access to a market that isn’t available on some exchanges, or maybe you’ve found an arbitrage spread you want to try to profit from. In this example we’ll get exchange clients for both the sending and the receiving exchanges, get the deposit address from the receiving exchange, and then submit the transfer to the sending exchange.
What if you wanted to build a dashboard that tracks your wallet balances for each exchange? We’ve got that covered too.
That’s just the start
The Coygo API can do a TON of cool stuff. This was just a brief introduction of the basics. You can also access derived calculations like order book superiority, listen for real-time arbitrage spreads across exchanges, and a number of other interesting things.
If you’d like to experience what the Coygo API has to offer, you can download the Coygo app today and try it for yourself.
If you’re interested in signing up for early access, you can learn more and sign up at coygo.app.