How to take prediction output?

Course Name: Deep Reinforcement Learning in Trading, Section No: 13, Unit No: 6, Unit type: Video



I understand that it buying/selling in the backtest function, but how to see where it has predicted buy/sell. I would like to manually take output trading.            

 

Hi Mahesh,



The "pos" in the backtest is the position being taken. -1 for sell, 1 for buy, 0 for square-off. 



For live trading, the template code shows the action (E.g. "Sell action encountered") taken in the window as can be seen below:







If you don't want to trade, you can comment the line which is taking positions.

 

Hi Gaurav,



Thanks for the reply.



I would like to know taking these predictions is possible row wise (date/time wise) in a data frame to be able to see whether it predicted buy/sell for a particular row.<br />


For example, with a particular conditions of market in a row, what is its prediction buy/sell.

You can construct a new state at each row, and use the q_network to predict the action for the given state. This gives you the action row-wise.



Hope this helps.

I am not a seasoned coder,

it would be really helpful if you can please show me a sample code on how to do that.

You can refer to the live trading template for the sample code. The code inside the strategy function will need to be put in a for loop if you are running on a historical data frame. The bars5m data would be the rolling window of historical data needed to create the state.

 

Thanks Gaurav, will try it out.

You can refer to the following notebook: Quantra by QuantInsti | Courses on Algorithmic and Quantitative Trading



In this notebook, the dataframe trade_analytics_df will help you with the positions (Buy, Sell) take by the RL in the "position" column and at what timestamp (Time index). A sample output from trade_analytics_df is shown below.



The value of +1 indicates Buy signal, -1 indicates Sell signal and 0 indicates no position.



You can use this position column with your other trading signals and trade using combined signal.



I hope this helps.





Thanks Ishan.



This helps.