initial save of my chatGPT coding
This commit is contained in:
16
btc_tracker/fetch_data.py
Executable file
16
btc_tracker/fetch_data.py
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/python3
|
||||
import json, time
|
||||
|
||||
# Load the JSON file
|
||||
with open('sources.json', 'r') as f:
|
||||
data = json.load(f)
|
||||
|
||||
# Iterate over the exchanges
|
||||
for exchange in data['exchanges']:
|
||||
# Print the name and URL of the exchange
|
||||
if exchange['name'] == "Kraken":
|
||||
current_time = int(time.time()) - 300
|
||||
exchange['url'] += f"&since={current_time}"
|
||||
print(exchange['name'], exchange['url'])
|
||||
else:
|
||||
print(exchange['name'], exchange['url'])
|
24
btc_tracker/sources.json
Normal file
24
btc_tracker/sources.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"exchanges": [
|
||||
{
|
||||
"name": "Bitstamp",
|
||||
"url": "https://www.bitstamp.net/api/v2/ohlc/btcusd/?step=300&limit=1",
|
||||
"freq": "5"
|
||||
},
|
||||
{
|
||||
"name": "Kraken",
|
||||
"url": "https://api.kraken.com/0/public/OHLC?pair=XBTUSD&interval=240",
|
||||
"freq": "5"
|
||||
},
|
||||
{
|
||||
"name": "Bitfinex",
|
||||
"url": "https://api-pub.bitfinex.com/v2/candles/trade:5m:tBTCUSD/last",
|
||||
"freq": "5"
|
||||
},
|
||||
{
|
||||
"name": "Gemini",
|
||||
"url": "https://api.gemini.com/v2/candles/btcusd/5m",
|
||||
"freg": "5"
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user