Hey guys...
So I wanted to encapsulate the payment of trade fees and track them to get an idea of how much I'm losing to commissions.
Attached is the Sample Algorithm provided within this forum + a small helper function which handles the payments of fees.
The nominal fee (avg_trade_fee) is declared in the initializer, along with a total fees counter (total_trade_fees) to keep track of how much profit I've lost to fees.
I have noticed that under some conditions, I get total_trade_fees numbers which are not even denominators of the avg_trade_fee. Not sure why, but my first guess is that it's due chopping a given trade in two pieces between days. The log output shows a consistent trade payment.
Next step is to include a small function which checks that an equity trade is large enough to make a net profit over the trade fee. Something to the effect of:
if (trade_is_profitable) = true then (commit order).
Comments / suggestions are greatly welcomed!
Thanks,
-mc