fork download
  1. import urllib.request
  2. import json
  3. import bokeh.plotting
  4. import datetime
  5.  
  6. def priceHistoryMinute(symbol, comparisonSymbol, limit, aggregate, exchange = ""):# limit = number of time intervals to return, values lower than 1 are treated as 1
  7. url = "https://m...content-available-to-author-only...e.com/data/histominute?fsym={}&tsym={}&limit={}&aggregate={}".format(symbol.upper(), comparisonSymbol.upper(), limit, aggregate)
  8. if exchange:
  9. url += "&e={}".format(exchange)
  10. response = urllib.request.urlopen(url)
  11. data = json.load(response)["Data"]
  12.  
  13. return data
  14.  
  15. data1 = priceHistoryMinute("BTC", "USD", 2000, 1, "Coinbase")
  16. closingPrices1 = [i["close"] for i in data1]
  17. times1 = [datetime.datetime.fromtimestamp(int(i["time"])) for i in data1]
  18.  
  19. data2 = priceHistoryMinute("LTC", "USD", 2000, 1, "Coinbase")
  20. closingPrices2 = [j["close"] for j in data2]
  21. times2 = [datetime.datetime.fromtimestamp(int(j["time"])) for j in data2]
  22.  
  23. graph = bokeh.plotting.figure(plot_width = 700, plot_height = 300)
  24. graph.line(times1, closingPrices1, line_width = 2)
  25. graph.line(times2, closingPrices2, line_width = 2, line_color = "orange")
  26.  
  27. bokeh.plotting.show(graph)
Runtime error #stdin #stdout #stderr 0.12s 16432KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 3, in <module>
ImportError: No module named 'bokeh'