Hi Brother...
df_curr_pos = pd.DataFrame(positions['net'])
sell_trades = df_curr_pos.loc[(df_curr_pos['quantity'] <= 0) | (df_curr_pos['quantity'] > 0) & (df_curr_pos['tradingsymbol']).str.contains("NIFTY")]
####pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
####################################################
symbol = sell_trades['tradingsymbol']
sell_value = sell_trades['sell_value']
buy_value = sell_trades['buy_value']
multi = sell_trades['multiplier']
qty = sell_trades['quantity']
#print(positions)
k =0
mtm_sum = 0
for i in symbol :
lp = get_live_data(i,ins_type)
pnl = (sell_value[k]- buy_value[k]) + (qty[k] * lp * multi[k])
mtm_sum = mtm_sum + pnl
k = k+1
print(mtm_sum)
October 2020