Back

7 Dec, 2022 | Tutorial

How to deploy a currency alerting pipeline with Quix and CoinAPI

How to build a powerful currency alerting pipeline in a few minutes with Quix and CoinAPI.

Tomas Neubauer
Words by
Tomáš Neubauer, CTO & Co-Founder
Coin API blog feature image

How to Deploy a Simple Currency Alerting Pipeline that uses CoinAPI

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 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. (That's Quix, in case you were wondering 😉) 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.

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 have build their on 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, 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 short code for the currency that you want to track (e.g. BTC),

  • The short codes 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.

  • 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 a “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.

Learn more about deploying currency alerts in the Quix platform

We hope this walkthrough gave you a first taste about 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 post has been reposted on the CoinAPI blog here: https://www.coinapi.io/blog/2022/12/deploy-real-time-currency-alerting-pipeline/

share

Try Quix for yourself for free (no credit card, no time limit).

Start for free
Tomas Neubauer
words by
Tomáš Neubauer, CTO & Co-Founder

Tomas Neubauer is Co-Founder and CTO at Quix, responsible for the direction of the company across the full technical stack, and working as a technical authority for the engineering team. He was previously Technical Lead at McLaren, where he led architecture uplift for Formula One racing real-time telemetry acquisition. He later led platform development outside motorsport, reusing the knowhow he gained from racing.

Previous Post Next Post

Related content

View all
Tabular time series data Kafka Python
Tutorial | 10 Jan, 2023
How to send tabular time series data to Apache Kafka with Python and Pandas
Use Python to process time series data and send it to Apache Kafka. You'll use a large sample data set from an online-retailer and send the records in batches with Pandas and the kafka-python library.
Tomas Neubauer
words by
Tomáš Neubauer, CTO & Co-Founder
119 feature image
Tutorial | 29 Oct, 2021
Build and deploy a data science project (no developer required)
An in-depth tutorial on how one data scientist created a real-time predictor of bike availability — a use case you can apply to any fleet or mobility solution.
Javier Blanco
words by
Javier Blanco, Senior Data Scientist
116 feature image
Tutorial | 26 Oct, 2021
Your 15-minute guide to real-time machine learning
Take a machine learning project using streaming data from idea to production deployment. It takes just 15 minutes with this step-by-step blog and video tutorial.
Steve Rosam
words by
Steve Rosam, Full-stack developer

The Stream

Updates to your inbox

Get the data stream processing community's newsletter. It's for sharing insights, events and community-driven projects.

Background image