hived
hived
is the second version of my personal cryptocurrency server:
- hived is currently using redis as its DB because its tiny and fast.
- It sends notifications through telegram.
Currently it has 5 endpoint:
/price
Lets you ask for the price of the currency. You can determine the currency the value is returned in.
/pair
Takes in a pair of currencies and a multiplier. Determines and returns the ratio.
/alert
POST
Takes in a name and a math expression containing the names of the currencies. Checks the expression periodically. Sends a message over telegram when the expression holds true.
The expression's result must be boolean. As an example:
ETH*50>50000.
ETH*60/(DOGE*300000) < 4.
You can have as many parameters as you like. The requests for the crypto prices are all turned into individual goroutines so it's fast.
The expression evaluation is powered by govaluate. So for a set of rules and what you can and cannot do please check the documentation over there.
DELETE
Deletes the key from the DB so you will no longer receive updates.
/ex
Gets the list of currencies that are available to be traded.
You can check under ./test
for some examples of curl commands.
/health
Returns the health status of the service.
How to Run
Before you can run this, you need a telegram bot token and a changelly API key.
The keys are put in files and then given to Docker as secrets.The docker entrypoint script then exports these as environment variables.
TELEGRAM_BOT_TOKEN="my-telegram-bot-api-key"
And
CHANGELLY_API_KEY:"my-changelly-api-key"
And
CHANGELLY_API_SECRET:"my-changelly-api-secret"
If you want to use docker-compose, it's as simple as running docker-compose up
. You just need to provide the files. You can check the file names in the docker-compose file.
Both the server itself and the redis image are alpine-based so they're pretty small.
Gitpod
hived
is gitpod-ready. Gitpod might need to install some go lsp tools once it is loaded. You will get prompted for those.
Docs
You can find the swagger and postman docs under /api
.
TODO
fix travis
- add unit tests
fix hived -help
crashing
- haproxy
- turn the telegram bot into its own microservice
- update openapi3.0 spec and postman
- telegram bot's endpoint should be gRPC