0

I'm a beginner in python, trying to calculate the basis for futures of spot price of BTC using quandl. When I try to plot the basis ((futures/spot-1)*100), I receive the error shown in the title

import matplotlib.pyplot as plt
import numpy as np
import quandl

futures = quandl.get("BITFINEX/BTCUSD.3")
spot = quandl.get("BITSTAMP/USD.2")
basis = (futures/spot+1)*100

plt.subplot(2,1,1)
plt.plot(futures)
plt.title('Main window')

plt.subplot(2,1,2)
plt.plot(basis)
plt.title('Basis')

plt.show()

error is : ValueError: view limit minimum -0.001 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units

  • Probably some silent datetime conversion did not work well ; I wonder if these two links would shed any light on the problem: [this mentions pandas <-> matplotlib converters](https://nextjournal.com/fb-prophet/business-analytics-environment?change-id=CWf53xybRqD8wvSLhmbimB&node-id=bab9f562-df84-4d17-9df0-d2b0a87cb385) and [a similar SO question on related matter](https://stackoverflow.com/questions/57874226/valueerror-view-limit-minimum-35738-3640567-is-less-than-1-and-is-an-invalid-m) – ジョージ Apr 14 '20 at 07:41
  • Try to temporarily remove the fragment that plots the basis and change `plt.plot(futures)` to `plt.plot(futures.values)` ; if that works, then pandas arithmetic operations must be a separate question. ( Ref: https://github.com/sunpy/drms/issues/34 ) – ジョージ Apr 14 '20 at 07:52
  • I experimented with plotting the basis as: plt.plot(basis.values) - interestingly both the X and Y axis for basis appear as numeric values, almost as if I need to stipulate that I want to perform the basis calculation separately for each daily value? – Mitchell Pa Apr 15 '20 at 02:02

0 Answers0