Skip to content

how to get commission of each trade. #707

Answered by kernc
sultank1 asked this question in Q&A
Discussion options

You must be logged in to vote

any way to add a new column(commission) in stat._trades
want to verify if the commissions are being calculated correctly...

You can compare the trade EntryPrice with its respective bar's Open price.

See what you can do with the following piece of code:

trades = stats['_trades'].set_index('EntryTime')
prices = data.Open[trades.index]
commissions = (prices - trades.EntryPrice) * -np.sign(trades.Size) / prices

E.g. commissions with Quick Start example:

2004-09-17    0.002
2004-11-12    0.002
2004-11-26    0.002
2004-11-30    0.002
2004-12-06    0.002
              ...  
2012-11-29    0.002
2013-01-08    0.002
2013-01-10    0.002
2013-01-23    0.002
2013-01-31    0.002
Length: 153, dtype: …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@sultank1
Comment options

Answer selected by sultank1
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants