FillDataForward = False

Back

import pandas as pd

qb = QuantBook()
symbol = qb.AddEquity("gsus",fillDataForward = False).Symbol

# Fetch history
history = qb.History([symbol], 75, Resolution.Daily)

# Fetch price
total_price = history.loc[symbol].low


pd.set_option('display.max_rows', total_price.shape[0]+1)
print (total_price.shape[0])
print (total_price)

 

No data is available on 5-6 Aug but fillDataForward = False returns the same results as fillDataForward = True, any reason for that?

Noticed that for both fillDataForward = True/False, OHLC of NaN data will return the following:

Close = Previous Close

Open = Previous Open

High = Max (Open, Close)

Low = Min (Open, Close)

 

I wish to get the fillforward below instead, can advise? Thanks.

Close = Previous Close

Open = Previous Close

High = Max (Open, Close)

Low = Min (Open, Close)

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.


anyone can help?

0

Hi Zc,

The reason fillDataForward=True and fillDataForward=False give us the same results is because Lean doesn't support named arguments (sorry coming soon!). Instead of typing out the method with all of the arguments, we can instead address this using the built-in pandas DataFrame fillna or dropna (if you wanted to delete the rows altogether) methods: 

import pandas as pd

qb = QuantBook()
symbol = qb.AddEquity("gsus", fillforward=True).Symbol

# Fetch history
history = qb.History([symbol], 75, Resolution.Daily)
history = history.fillna(method='ffill')
# history = history.dropna() # alternative

history.isna().any()

For the method that uses the full method constructor:

qb = QuantBook()
symbol = qb.AddEquity("gsus", Resolution.Daily, Market.USA, True, 1, False).Symbol
history = qb.History([symbol], 75, Resolution.Daily)

history.isna().any()

Please see the attached notebook for reference.

Best,
Shile Wen

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