While it’s easy to write an app that does useful things with crypto market data, it can involve a bit of tedious busy work. For example, once you’ve programmed all the required steps, you’ll need to find a way to securely deploy and host your app. Luckily, there are a few platforms out there that aim to simplify this part of the process.
Today, we’re going to look at a tool that specializes in helping developers and data engineers deploy real-time data apps and pipelines. It’s called Quix, and it’s a pretty handy tool if you’re working with any kind of volatile market data.
To help you understand how it works, let’s look at a very simple use case that leverages CoinAPI market data: an alerting app that sends an SMS when the price of Bitcoin crosses a specific threshold.
How do Quix and CoinAPI deploy a currency alerting pipeline?
To build this simple alerting app, we’ll need to code the following major functions.
1. Check The Bitcoin Price
Poll the CoinAPI market data endpoint for the current Bitcoin price (no less than every 15 mins if you’re on the free plan).
2. Compare The Bitcoin Price With The Threshold
See if the Bitcoin price has moved beyond the target price threshold in either direction.
3. Trigger an external notification
Send a message to let you know that the threshold has been met (for example, using an SMS API like Twilio).
We’re going to break down the steps in a bit more detail and look at how you’d create and run them within the Quix platform. But first, it’s important to clarify that in Quix, you write functions in Python (or C#) that interact with Apache Kafka.
– Why Python? The Quix platform runs on the Quix SDK, which enables you to code in Python yet easily interact with Kafka topics. Up until recently, you’d need to know your way around Java before you could work with Apache Kafka, but Quix has built its own SDK so that you code in Python and C#. It’s designed to make Apache Kafka more accessible to data scientists and engineers who are typically more proficient in Python
– And Why Kafka? To keep it simple, this example uses our REST API, but more advanced apps often use our Websocket endpoint—which is a constant stream of data. Apache Kafka is still the industry standard for working with data streams, which is why the Quix platform also uses Kafka as its foundation.
Ok, so how would you make these functions work together in the Quix platform? Let’s look at the end result first. What you see here are the 3 functions chained together to form a simple pipeline:
We’re going to explore a quick way to build each of these functions. Bear in mind that this is not a full tutorial, but rather an overview of how programs are run and deployed in Quix (we’ll link to a more detailed tutorial after the overview).
1. Polling the Market Data endpoint
Quix has an extensive library of Python code templates to bring in data from many external sources—including CoinAPI. You just need to copy the library to your workspace and give it the environment variables that it expects. These are as follows:
- The API key that you use to access CoinAPI.
- The shortcode for the currency that you want to track (e.g. BTC),
- The shortcodes of the equivalent fiat currencies (USD, GBP).
– You’re free to adapt the code however you’d like, but it’s handy to have some boilerplate to get started.
– This boilerplate code writes the market data to a preconfigured Kafka topic called “coin-data”.
2. Do the comparison
Quix’s template library also contains a handy function for checking thresholds, so you can just enter your desired threshold and connect it to the incoming price data.
- This boilerplate code reads incoming prices from the “coin-data” topic and checks to see if the threshold has been crossed.
- When the threshold is crossed, the function will write a message to the “coin-alerts” topic.
3. Send the notification with Twilio
Naturally, Quix also has boilerplate code for accessing Twilio. In this case, you enter a few variables related to your Twilio account. Sadly, there’s no easy way to automate the Twilio account creation process, but once you have a Twilio developer account, you can just plug your account details into the Quix UI. These are then saved as environment variables.
The Twilio boilerplate code checks for incoming messages from the “coin-alerts” topic and uses the Twilio API to send an SMS to your phone.
4. Deploying the code as serverless functions
After you’ve finished setting up each step, you click the big blue “deploy” button. Each function then runs in the Quix platform as a serverless function.
The kind of architecture that we’ve outlined here is often called “loosely coupled” architecture. It means that the different parts are not highly dependent on each other. For example, if the Twilio service goes down, the alerts will not fail, they will just be delayed. The “coin-alerts” topic will accumulate messages and the Twilio service will process the message backlog once it comes back online.
How Quix and CoinAPI deploy currency alerting pipeline? Learn More About Deploying Currency Alerts In The Quix Platform
We hope this walkthrough gave you a first taste of what the platform can do. Quix is a great match for market data APIs such as CoinAPI. It can handle more complex pipelines and back-end architectures too. You can use Quix’s built-in connectors to bring your data in and send it back out again—to a mobile app, a data warehouse, or an external service. The choice is yours.
For a detailed tutorial on how to build what we just described in this walkthrough, check out this simple video tutorial.
Note that it doesn’t contain the threshold checking step, but you can easily add this step from the Quix library. Happy coding!
This is a guest blog post written by Tomas Neubauer and was originally published on https://www.quix.io/blog/deploy-real-time-currency-alerting-pipeline/