Hi all,
I have created custom properties for a class.
I am placing some of the code of the class below so that you have context.
How do I set the value of the rsi_period?
I am trying to invoke the relevant property but am being told about a
missing parameter.
class stocks:
#Contains the data for one security which is tested and the result
is output in the form of properties
def __init__(self,asset_name,asset_frame):
self.asset_df=asset_frame
self.asset_name=asset_name
self.rsi_period=14
self.take_profit_factor=3
self.stop_loss_factor=2
self.long_atr=1
self.adx_period=14
self.sar_period=14
self.atr_period=14
self.asset_df["signal"]=0
self.bh_returns=0
self.strategy_returns=0
#getters and setters for paramaterizing the back test
@property
def set_rsi_period(self,prd):
self.rsi_period=prd
@property
def get_rsi_period(self):
return self.rsi_period
@property
def set_take_profit_factor(self,tf):
self.take_profit_factor=tf
@property
def get_take_profit_factor(self):
return self.take_profit_factor
#We exit the class so add some code to run the script
Stx=stocks("MM",df)
Stx. set_rsi_period(14)
The above syntax fails since the routine is expecting the self parameter
which I am not sure how to specify.
Pranav
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq