Back

RateOfChangePercent Python documentation

Hello,

 

I'm trying to use the RateOfChangePercent indicator in a python notebook against a series and it seems it's implemtation differs from the c# one but I can not find a working example of how to use it.

 

The two commented out lines throw errors as invalid constructors and it's not clear what to do with `ROCP` since I can't pass in `btc.close`

```

btc = h1.loc["BTCUSD"]
#rocp = RateOfChangePercent("BTCUSD", 1, Resolution.Daily)
#btc['daily_return'] = qb.Indicator(rocp, "BTCUSD", 360, Resolution.Daily)
ROCP = RateOfChangePercent(1)
btc_history = btc.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.


Hi Barry,

Thank you for your post. Here I will attach a code snippet for you on how to use RateOfChangePercent Indicator in Research Environment. 

qb.AddCrypto("BTCUSD")
# Get the data of BTCUSD for the last 100 days
btc = qb.History(["BTCUSD"], 100, Resolution.Daily)
# Set up Indicator
rocp = RateOfChangePercent(1)
# ROCP for the last 10 days
df_rocp = qb.Indicator(rocp, "BTCUSD", 10, Resolution.Daily)
df_rocp

Generally speaking, we should first add specific Crypto and request historical data, then claim the Indicator we need and finally transform it in the way Research requires. Please note that the days of historical data should be no shorter than the days for the indicator, or it will cause bug due to insufficient data. Hope it helps! 

1

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