Giter Site home page Giter Site logo

kraken-scheduler's Introduction

Kraken Scheduler

drawing

Build status:

build status

Tired of manually buying crypto every month? Every week? Every day?!

This application creates automated buy orders for cryptocurrencies on Kraken based on your configuration, with email alerts on order placements and status (currently requires GMail).

Disclaimer: this application isn't affiliated with Kraken in any way, and I take no responsibility for incorrectly placed orders.

Prerequisites

Installation from binaries

Check the releases, and download the binary relating to your operating system.

Building

  1. Ensure you have go installed (at least version 1.18)
  2. Run make build
  3. Executable is created in ./target/kraken-scheduler

Installation from source (Linux / OSX only)

  1. Run make install (binary is copied to /usr/local/bin)

Schedule configuration

The application needs a JSON configuration file to run.

Create config.json in the directory of your choice (eg. $HOME/.kraken-scheduler/config.json).

Example configuration:

{
  "key": "your kraken API key",
  "secret": "your kraken API secret",
  "schedules": [
    {
      "cron":  "00 12 * * 1",
      "pair": "XXBTZEUR",
      "amount": 100.00
    },
    {
      "cron":  "00 12 1 * *",
      "pair": "ADAEUR",
      "amount": 50.00
    }
  ]
}

This example will order €100 of bitcoin every week, and €50 of ADA every month.

Here is a detailed explanation of each schedule parameter:

Parameter Description Valid Values
cron A crontab configuration describing when to create orders for this schedule (use crontab.guru for help) A valid crontab string
pair Crypto & fiat pair to purchase, eg. XXBTZEUR to purchase bitcoin in euros, ADAEUR to purchase ADA in USD.ADAUSD Check here for all supported pairs
amount Amount of crypto to purchase, in fiat. This depends on the pair - if XXBTZEUR for example, amount will be in euros, if XXBTZUSD, amount will be in USD Any float (check kraken minimum order amounts - if the amount is too small your order will fail)

Running

Run with:

kraken-scheduler --config CONFIG [--email-credentials CREDENTIALS] [--telegram-credentials] [--live]

Note that by default the application runs in test mode, and doesn't create real orders.

This is useful to validate that you've configured things correctly, and the purchase amounts are correct.

To place real orders, you must pass --live when running.

Run kraken-scheduler --help for a description of all arguments.

Running with Docker

Kraken Scheduler is published to DockerHub.

It's also cross-compiled to support running on different hardware, such as Raspberry Pis.

To run using docker, simply create a directory to contain your config files (assumed to be called "config" in the examples), and create docker-compose.yaml like the following:

version: "3.8"
services:
  kraken-scheduler:
    image: jackpfarrelly/kraken-scheduler:latest
    volumes:
    - ./config:/config
    environment:
    - TZ=Europe/Berlin # Replace with your timezone
    expose:
    - 2112 # Prometheus metrics port
    ports:
    - 2112:2112 # Prometheus metrics port
    entrypoint: >
      kraken-scheduler
        --config ${CONFIG:-"/config/config.json"}
        --telegram-credentials ${TELEGRAM_CREDENTIALS:-""}
        --email-credentials ${EMAIL_CREDENTIALS:-""}
        --live
    restart: on-failure

Then run with docker compose up.

To set the telegram credentials argument for example (assuming the telegram-credentials.json file exists in your ./config directory):

TELEGRAM_CREDENTIALS=/config/telegram-credentials.json docker compose up.

Notes on logs

In order to not get a full replay of the logs (where it looks like the timer is counting down super quick), make sure to use --tail 0 when tailing logs.

E.g. docker logs --tail 0 -f <container_id>.

Important Notes for Raspberry Pi

Due to a bug in libseccomp2, docker containers don't have the correct date on the Raspberry Pi. This causes scheduling not to work, and buys will happen at incorrect times.

To fix, I had to run the following:

sudo sh -c 'echo "\ndeb http://raspbian.raspberrypi.org/raspbian/ testing main" >> /etc/apt/sources.list'
sudo apt update && sudo apt install -y libseccomp2/testing

It's advised to run in test mode (without --live) first to make sure things work correctly.

Telegram Notifications

To recieve telegram notifications every time there is an order, follow these steps:

  1. Register your bot in Telegram by sending the @BotFather user a /newbot command.
  2. You will get a Token back, save it in a safe place.
  3. Check that the bot creation worked by running:
TELEGRAM_TOKEN="my-secret-token"
curl https://api.telegram.org/bot$TELEGRAM_TOKEN/getMe
  1. Create a new telegram group and invite your recently created bot.
  2. Get the id of your group by running:
TELEGRAM_TOKEN="my-secret-token"
https://api.telegram.org/bot<YourBOTToken>/getUpdates
  1. Create a json file with the following format:
{
    "token": "my-secret-token",
    "chatId": 1234567
}
  1. Pass the json file as absolute path to the flag --telegram-credentials.

kraken-scheduler's People

Contributors

jackpf avatar matiasvillaverde avatar

Stargazers

 avatar

Watchers

 avatar

kraken-scheduler's Issues

Feature request: add strategies for advanced DCA

Advanced DCA Strategy

We can improve the performance of your dollar cost averaging strategy by making use of some simple tools.

For example it would be great to use simple technical analysis tools to get a signal, instead of a fixed time interval.

Some examples of signals that traders can use for better timing entries include buying when Crypto approaches a high time frame moving average (like the 200 DMA), looking for unusually oversold conditions (RSI or MACD), or using a valuation tool like the bitcoin stock to flow model.

Feature request: output stats of how much was the price of DCA

What is the expected behavior?

It would be useful to have stats about the price of the crypto bought at a given period. We can calculate it with the following formula:

Dollar-Cost Averaging Formula

The formula for calculating the dollar cost average over 3 purchase periods looks like this.

Dollar-Cost Average = ((P * T) + (P * T) + (P * T)) ÷ ∑ T

P = Crypto Price
T = Number of tokens Purchased.

or an even simpler formula for calculating the Dollar Cost Average.

Dollar-Cost Average = Total $ Amount Invested ÷ Total Number of token Owned.

Feature request: specify amounts of an order in crypto

What is the current behavior?

Now is only possible to specify the amount in Fiat.

What is the expected behavior?

New entry to specify the amount in Crypto. For example:

{
  "schedules": [
    {
      "cron":  "00 12 * * 1",
      "pair": "XXBTZEUR",
      "amount-in-fiat": 100.00
    },
    {
      "cron":  "00 12 1 * *",
      "pair": "ADAEUR",
      "amount-in-crypto": 5.00
    }
  ]
}

What is the motivation / use case for changing the behavior?

Kraken API has a minimum order size (volume) for trading in crypto. You can find more information here Therefore, when setting up a price in Fiat, it can be lower than the minimum order size.

By setting a amount-in-crypto we can ensure that the order will be above the minimum order size.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.