Skip to content

Instantly share code, notes, and snippets.

@mvanduijker
Last active April 15, 2023 19:27
Show Gist options
  • Save mvanduijker/79b59ff2a1eb3a91e78ad59d4c8cd113 to your computer and use it in GitHub Desktop.
Save mvanduijker/79b59ff2a1eb3a91e78ad59d4c8cd113 to your computer and use it in GitHub Desktop.
Dollar averaging buy 10 euro of bitcoin 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