2021年2月7日星期日

range, if then, statement to print output based on data

I would like to have the value return a response based on the output of the value within the specified range.

import requests  import json  import time  url = 'https://api.gdax.com/products/BTC-USD/trades'  res = requests.get(url)  json_res = json.loads(res.text)      print('val ', json_res[0]['price'])    buy = range(32000, 36000)  sell = range(39000, 50000)    if json_res in buy:      print('Low')    elif json_res in sell:      print('Too High')    

This is an example of the output I'm looking for

val 38000.00002545  Too High  
https://stackoverflow.com/questions/66095356/range-if-then-statement-to-print-output-based-on-data February 08, 2021 at 10:55AM

没有评论:

发表评论