This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
13 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"pair": "ETH/USD" | ||
"pair": "ETH-USD", | ||
"interval": 21600 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import numpy as np | ||
from requests import get | ||
|
||
def get_prices(pair, interval=15): | ||
ohlc = get(f'https://api.kraken.com/0/public/OHLC?pair={pair}&interval={interval}').json() | ||
ticker = get(f'https://api.kraken.com/0/public/Ticker?pair={pair}').json() | ||
# {60 300 900 3600 21600 86400} | ||
# 1m 5m 15m 1h 6h 1d | ||
# 5h 25h 3d3h 12d12h 2mo15d 10mo | ||
def get_prices(pair, interval=21600): | ||
ohlc = get(f'https://api.exchange.coinbase.com/products/{pair}/candles?granularity={interval}').json() | ||
ticker = get(f'https://api.exchange.coinbase.com/products/{pair}/ticker').json() | ||
|
||
current = float(list(ticker['result'].values())[0]['c'][0]) | ||
prices = [float(point[4]) for point in list(ohlc['result'].values())[0]] | ||
current = float(ticker['price']) | ||
prices = [point[4] for point in ohlc] | ||
|
||
return np.array([*prices, current]) | ||
return np.flip([current, *prices]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters