Versión final scripts BitGET
This commit is contained in:
30
get-usdt-eur-range.sh
Executable file
30
get-usdt-eur-range.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# === Configuración ===
|
||||
COIN_ID="tether"
|
||||
VS_CURRENCY="eur"
|
||||
OUTPUT="usdt-eur-2025.csv"
|
||||
|
||||
# Timestamps: 2025-01-01 00:00:00 a 2026-01-01 00:00:00 (en segundos UTC)
|
||||
FROM_TIMESTAMP=$(date -j -f "%Y-%m-%d" "2025-01-01" +"%s") # macOS
|
||||
TO_TIMESTAMP=$(date -j -f "%Y-%m-%d" "2026-01-01" +"%s")
|
||||
|
||||
# === Llamada API CoinGecko ===
|
||||
URL="https://api.coingecko.com/api/v3/coins/$COIN_ID/market_chart/range?vs_currency=$VS_CURRENCY&from=$FROM_TIMESTAMP&to=$TO_TIMESTAMP"
|
||||
|
||||
echo "📡 Consultando CoinGecko..."
|
||||
RESPONSE=$(curl -s "$URL")
|
||||
|
||||
# === Procesar respuesta ===
|
||||
echo "date,usdt_eur" > "$OUTPUT"
|
||||
|
||||
echo "$RESPONSE" | jq -c '.prices[]' | while read -r entry; do
|
||||
ts=$(echo "$entry" | jq '.[0]')
|
||||
price=$(echo "$entry" | jq '.[1]')
|
||||
|
||||
# Convertir timestamp ms → fecha UTC
|
||||
date=$(date -j -u -r "$((ts/1000))" +"%Y-%m-%d")
|
||||
echo "$date,$price"
|
||||
done | sort | uniq -f0 >> "$OUTPUT"
|
||||
|
||||
echo "✅ Guardado en $OUTPUT"
|
||||
Reference in New Issue
Block a user