Skip to content

Instantly share code, notes, and snippets.

@mvanduijker
Last active Apr 30, 2021
Embed
What would you like to do?
Dollar averaging buy 10 bitcoin in euro with kraken api and it's cli
#!/bin/bash
set -e
# Install kraken cli (https://support.kraken.com/hc/en-us/articles/360025180232-Kraken-REST-API-command-line-client) and put this script in same path
# Make sure the following tools are installed: bc, jq
# To make a daily trade add this script in your cron
# Use offical pair, check them with ./krakenapi.py AssetPairs | jq
PAIR=XXBTZEUR
# Price to buy in your currency
BUY_PRICE=10
CURRENT_PRICE=$(./krakenapi.py Ticker pair=$PAIR | jq .result.$PAIR.a[0] | bc -l)
VOLUME=$(echo "$BUY_PRICE / $CURRENT_PRICE" | bc -l)
./krakenapi.py AddOrder pair=$PAIR type=buy ordertype=market volume=$VOLUME
@mvanduijker
Copy link
Author

mvanduijker commented Apr 30, 2021

add validate=true to last command to dry run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment