Back

Wrong Datetime produced by pandas?

from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Research")
AddReference("QuantConnect.Indicators")
from System import *
from QuantConnect import *
from QuantConnect.Data.Market import TradeBar, QuoteBar
from QuantConnect.Research import *
from QuantConnect.Indicators import *
from datetime import datetime, timedelta
import matplotlib.pyplot as plt
import pandas as pd

# Create an instance
qb = QuantBook()

Cryptolst = ["BTCUSD"]

for currency in Cryptolst:
qb.AddCrypto(currency)

start_time = datetime(2019, 5, 1) # start datetime for history call
end_time = datetime(2019, 6, 1) # end datetime for history call

history = qb.History(qb.Securities.Keys, start_time, end_time, Resolution.Hour)

#plt.plot(figsize = (12,10))
history.loc[Cryptolst[0]]['close'].plot(figsize = (12,10))

keys = list(history.loc[Cryptolst[0]]['close'].index)[::72]
values = list(history.loc[Cryptolst[0]]["close"])[::72]

data_sets = dict(zip(keys, values))

data_sets

plt.figure(figsize = (12,10))
plt.plot(keys,values)
print(keys)

plt.figure(figsize = (12,10))
#history.loc[Cryptolst[0]]['close'].plot()
history.loc[Cryptolst[0]]["close"][::48].plot()

Hi so is anybody getting the same issue I am; my plots get thrown into like 1900 years into the future... for basically no reason.. in the jupyter notebook

any help would be appreciated 

 

 

 

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Hemanto,

This is an issue with the matplotlib library. Note that `[::24]` is selecting every 24th row in the history DataFrame, not the first 24 rows.

Best,
Derek Melchin

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed