Issue
I am trying to retrieve the most recent data from the below results.
The code I am running is:
import datetime
from Historic_Crypto import HistoricalData
# Time Setup
now_bsc = datetime.datetime.now()
now = (now_bsc.strftime("%Y-%m-%d-%H-%M"))
start_bsc = (datetime.datetime.now() - datetime.timedelta(minutes=10))
start = (start_bsc.strftime("%Y-%m-%d-%H-%M"))
"""print(start)
print(now)"""
# Pull OHLC Crypto
new = HistoricalData('BTC-USD', 60, start, now).retrieve_data()
print(new)
This is the result
Checking input parameters are in the correct format...
Formatting Dates...
Checking if ticker supplied is available on the CoinBase Pro API...
Connected to the CoinBase Pro API...
Ticker 'BTC-USD' found at the CoinBase Pro API, continuing to extraction...
Data Extracted from API...
low high open close volume
time
2021-05-12 21:18:00 54577.75 54641.08 54637.08 54582.91 14.041055
2021-05-12 21:19:00 54572.71 54610.19 54582.91 54599.86 3.327732
2021-05-12 21:20:00 54599.86 54691.49 54599.86 54678.31 17.552511
2021-05-12 21:21:00 54677.93 54725.75 54677.93 54711.22 5.963198
2021-05-12 21:22:00 54703.62 54756.39 54710.24 54753.88 11.564766
2021-05-12 21:23:00 54750.42 54800.47 54753.88 54768.64 13.601058
2021-05-12 21:24:00 54707.11 54768.64 54768.64 54738.99 11.131357
2021-05-12 21:25:00 54499.99 54739.49 54738.89 54669.53 37.366287
2021-05-12 21:26:00 54665.96 54748.10 54665.97 54743.89 7.932319
2021-05-12 21:27:00 54719.23 54752.19 54736.09 54734.70 9.654189
2021-05-12 21:28:00 54719.97 54749.00 54725.91 54748.99 6.386556
Process finished with exit code 0
How do I retrieve the data "low" and "high" for 2021-05-12 21:28:000?
Solution
The answer to this ended up being retrieving the items through index location as the columns were not identified. this is done by using .iloc
instead of .loc
.
low = new.iloc[10, 0]
high = new.iloc[10, 1]
Answered By - Anthony Reifel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.