Python Forum

Full Version: generate trades detail from code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
python code help

initial_capital= float(1000.0)
positions = pd.DataFrame(index=signals.index).fillna(0.0)
positions['AAPL'] = 100*signals['signal']  
portfolio = positions.multiply(aapl['Adj Close'], axis=0)
pos_diff = positions.diff()
portfolio['holdings'] = (positions.multiply(aapl['Adj Close'], axis=0)).sum(axis=1)
portfolio['cash'] = initial_capital - (pos_diff.multiply(aapl['Adj Close'], axis=0)).sum(axis=1).cumsum()
portfolio['total'] = portfolio['cash'] + portfolio['holdings']
portfolio['returns'] = portfolio['total'].pct_change()
I m not using pyalgo trade for that.
how can I generate no of trades in profit
I generate no of trades in loss

biggest winning trade
biggest loosing trade
average profit
average loss