Please help, i'm able to create a DataFrame with context.stocks as the index, however, I'm trying to replace the data when i meet certain conditions; When I was running the system, the system didn't send me error; However, the data within the DataFrame still has not change at all.
def initialize(context):
context.stocks = [sid(42950), sid(47208), sid(46631), sid(3212), sid(8554)]
context.stop_loss_df = pd.DataFrame(index=context.stocks, columns=['long_short','current_price', 'exec_price','stop_loss'])
def handle_data(context, data):
context.stop_loss_df.replace({'long_short':{stock:'long'}})
context.stop_loss_df.replace({'current_price':{stock : data.current(stock,'price')}})
context.stop_loss_df.replace({'exec_price':{stock : data.current(stock,'price')}})
context.stop_loss_df.replace({'stop_loss':{stock : data.current(stock,'price') * 0.98}})
log.info(context.stop_loss_df)