Making dividends myself

Posted By: alun

Making dividends myself - 09/03/22 21:50

Hello friends,

I have an ETF strategy that I want to test.

ETFs don't have splits only dividends.

I'm using upper/lower channel to rotate between risk/defensive ETFs

1. I want my channels on UNADJUSTED price curve to drive switch decisions

2. I still want to consider dividends in resulting equity and reinvesting

Finally 3. I want to apply my own tax on dividends, say 15%

Is there a good practice of how to achieve this in Zorro?

Thanks!
Posted By: AndrewAMD

Re: Making dividends myself - 09/04/22 14:11

For backtesting, use adjusted t6 for asset history, and load unadjusted t6 using the dataset functions as an indicator. (Or merge unadjusted price data into the dataVal column on the adjusted dataset and use that as the history file.)

For live trading, read the equity value supplied by your plugin while using unadjusted data.
Posted By: alun

Re: Making dividends myself - 09/04/22 20:29

Hi Andrew,

Thanks for your input.

I was thinking about using t6 unadjusted price with fVal column for dividends.

Once I encounter fVal > 0, I need somehow to make an immediate trade maybe with `enterTrade`? to add a profit of `TradeLots * fVal * (1-0.15)`

If use adjusted price there are two issues:
1. I can't deduct taxes from dividends
2. The amount of shares I buy in the past is different (higher) since adjusted price is lower in the past - this means fees are not calculated correctly.

I'll try to work and see if I could tinker something like you did in your article - https://www.vitaltrades.com/2020/07/14/adding-exact-fee-and-credit-calculations-to-zorro/

Thanks for sharing BTW.

© 2024 lite-C Forums