Whether you're into Bitcoin, Ethereum, Tether, or any other cryptocurrency, you have to admit that keeping track of highs/lows and overall trends can influence your buy/sell trading strategy. I am a novice in the crypto space and only dabble with small amounts, so please don't take any of this as financial advice. But I was curious whether I could build a bot that would track a given coin's market price and let me know when it exceeds or dips below its 10-day moving average.
I didn't want to settle for any of the off-the-shelf solutions I found for the following reasons:
- I wanted direct control of the data so I can specify the exact comparison criteria and time ranges
- I wanted the flexibility to do more sophisticated calculations
- I want to (eventually) add the ability to make this a crypto trading bot to automate trading via API
Creating a simple crypto price tracking bot
First, you need to obtain a free CoinAPI key, which you will need later in this post.
Once you have your key, sign up for Fusebit:
- Select Slack Crypto Bot when creating a new integration and specify the API key you obtained earlier
- Click the Edit button and then Run once the editor loads
- Finally, you will need to authorize access to a Slack workspace and the bot will then send you a DM with the current price for Bitcoin
If you got this far, then congrats, everything is working! But the fun is just beginning. This bot will only run on demand (when you hit the Run button), so let's learn how to make this a regular check, and how to make other customizations.
Customizing the bot
To get the bot to run regularly on a schedule:
- Select Configuration in the Fusebit Editor
- Add a similar section to the object. (Useful reference for the
"cron": "0 * * * *",
const ticker = 'BTC';
You may want to get data for multiple symbols at once, you can repeat the following lines in the source code to get data and construct a response message.
const range = await get10dayRange(ctx, ticker);
const rate = await getRate(ctx, ticker);
const message = printTickerMessage(ticker, rate, range.high, range.low);
This is just a very basic example and I'm eager to expand what this Fusebit bot can do. In particular, I'm curious if we can enable Node.js-based algorithmic trading.
What other capabilities should we add? Any cool usage examples you're willing to share? Contact us at @fusebitio on Twitter.