1

how can I make a print to change to the input value?

import cryptowatch as cw
time = input("Time:") #15m, 1h , 1d
x = cw.markets.get("KRAKEN:ATOMEUR", ohlc = True, periods = [time])
print(x.of_15m[1][4]))

for example:

time = input("Time:") #1h
print(x.of_1h[1][4])

or:

time = input("Time:") #1d
print(x.of_1d[1][4])

EDIT: I leave more information

cryptowatch-sdk

https://github.com/cryptowatch/cw-sdk-python

Module file where the functions are:(line 255)

https://github.com/cryptowatch/cw-sdk-python/blob/master/cryptowatch/resources/markets.py

Bog.Alx
  • 13
  • 3

1 Answers1

0

I couldn't really test this properly since I don't have cryptowatch installed, but I think it would work. It uses the user's input to determine the name of an x object attribute, and then uses getattr() to retrieve its current value.

import cryptowatch as cw

time = input("Time:")
x = cw.markets.get("KRAKEN:ATOMEUR", ohlc=True, periods=[time])

interval = getattr(x, 'of_'+time, None)
if interval is not None:
    print(interval[1][4])
else:
    print('Error: unknown time', time)
martineau
  • 119,623
  • 25
  • 170
  • 301