50 lines
2.6 KiB
Bash
50 lines
2.6 KiB
Bash
function get_bitpanda_api_transactions {
|
|
|
|
g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
|
|
|
|
# Check for Bitpanda API Key - If there get data from Bitpanda API
|
|
if [ -s /dabo/.bitpanda-secrets ]
|
|
then
|
|
source /dabo/.bitpanda-secrets
|
|
g_echo "Bitpanda API-Key found. Getting data from Bitpanda API"
|
|
curl -s -X GET "https://api.bitpanda.com/v1/wallets/transactions?page_size=999999" -H "X-Api-Key: ${BITPANDA_API_KEY}" >BITPANDA_wallets_transactions.csv.tmp \
|
|
&& mv BITPANDA_wallets_transactions.csv.tmp BITPANDA_wallets_transactions.json
|
|
curl -s -X GET "https://api.bitpanda.com/v1/fiatwallets/transactions?page_size=999999" -H "X-Api-Key: ${BITPANDA_API_KEY}" >BITPANDA_fiatwallets_transactions.csv.tmp \
|
|
&& mv BITPANDA_fiatwallets_transactions.csv.tmp BITPANDA_fiatwallets_transactions.json
|
|
curl -s -X GET "https://api.bitpanda.com/v1/trades?page_size=999999" -H "X-Api-Key: ${BITPANDA_API_KEY}" >BITPANDA_trades.csv.tmp \
|
|
&& mv BITPANDA_trades.csv.tmp BITPANDA_trades.json
|
|
unset BITPANDA_API_KEY
|
|
# Trades
|
|
jq -r '
|
|
.data[].attributes |
|
|
select(.status=="finished") |
|
|
select(.type=="sell" or .type=="buy") |
|
|
select(.cryptocoin_symbol!= null) |
|
|
.time.date_iso8601 + "," + .type + "," + .cryptocoin_symbol + "," + .amount + ",EUR," + .amount_eur_incl_fee + ",Bitpanda"
|
|
' BITPANDA_wallets_transactions.json >BITPANDA.csv.tmp
|
|
# Giveaways
|
|
jq -r '
|
|
.data[].attributes |
|
|
select(.status=="finished") |
|
|
select(.type=="transfer") |
|
|
select(.cryptocoin_symbol!= null) |
|
|
.time.date_iso8601 + "," + .tags[].attributes.short_name + "," + .cryptocoin_symbol + "," + .amount + ",EUR," + .amount_eur_incl_fee + ",Bitpanda"
|
|
' BITPANDA_wallets_transactions.json | sed 's/,reward,/,giveaway,/' >>BITPANDA.csv.tmp
|
|
# Leverage-Trades
|
|
jq -r '
|
|
.data[].attributes |
|
|
select(.status=="finished") |
|
|
select(.type=="sell" or .type=="buy") |
|
|
select(.effective_leverage!= null) |
|
|
.time.date_iso8601 + ",leverage-" + .type + "," + .cryptocoin_symbol + "," + .amount_cryptocoin + ",EUR," + .amount_fiat + ",Bitpanda"
|
|
' BITPANDA_trades.json >>BITPANDA.csv.tmp
|
|
# Workaround fpr staking-rewards (not availabpe per API yet (https://help.blockpit.io/hc/de-at/articles/360011790820-Wie-importiere-ich-Daten-mittels-Bitpanda-API-Key)
|
|
[ -s bitpanda-export.csv ] && cat bitpanda-export.csv | grep reward,incoming | awk -F, '{print $2",reward-staking,"$8","$7",EUR,"$5",Bitpanda"}' >>BITPANDA.csv.tmp
|
|
|
|
cat BITPANDA.csv.tmp | grep -v ",reward.best," | sort >TRANSACTIONS-BITPANDA.csv
|
|
rm -f BITPANDA.csv.tmp
|
|
fi
|
|
|
|
}
|
|
|