Earn 1,800 ($18.00)
Name your price - Basic backtesting tool
Bounty Description
I didn't know what to price this at, so please ignore the listed price and feel free to make a suggestion as to what you would like to be paid for this - I'm open to offers! :)
Problem Description
I have an idea for a trading strategy that I’d like to backtest, and would like a Python script to allow me to see how it would have performed.
I have detailed the strategy that I am planning to put live, so that you know what needs to happen during the backtest.
The site is www.darwinex.com and they have trading products called ‘Darwins’. Each Darwin has a three letter codename e.g. ‘THA’.
Here is their API documentation: https://darwinex.github.io/darwin-api-tutorials/ and https://api.darwinex.com/store/
To start the trading strategy, the system should filter all of the available ‘Darwins’ by the following criteria:
- Monthly divergence of less than -0.19%
- Loss aversion of more than 6
- D-Score of more than 75
- Risk Stability of more than 7
- Capacity of more than 3
If the filter returns more than 10 strategies, it should order all strategies returned by the D-score (highest number being the best) and should then buy an even amount of the account balance in the ten highest ranking strategies (e.g. buy 10% account balance into each of the top ten strategies).
If there are fewer than 10 strategies returned, it should split the available amount and buy each of those equally (e.g. if there are 5 strategies returned, it should use 20% of the balance on each strategy).
Each day, the system should then run the same filter to see who the top traders are according to the filters. If any of the existing strategies that we hold has fallen off the top ten, it should be sold, and the new strategy that has joined the top ten should then be bought with the balance from the sale of that strategy.
If there were fewer than 10 strategies in the list of currently owned strategies and a new strategy makes the top ten, the existing strategies should each sell a percentage of their holdings to free up enough balance to buy the new strategy. For instance, we currently have 20% of our balance on each of our five strategies, so each strategy sells approximately 3.4% of the total balance, leaving each of them with around 16.6% and making 16.6% available for the new strategy.
Once per month, the program should perform a ‘rebalance’ activity. Where it checks the total number of strategies invested in, and what percentage of the overall balance it holds, and then performs the appropriate maths to rebalance to make all of them hold an equal percentage of the holding. Eg you have 10 strategies, but one strategy holds 20% of the total balance, some of this should be sold and redistributed to the others to ensure each strategy only holds 10%.
Given this as the objective of the strategy, I would like to build a backtesting tool using data from the DarwinEx API which allows me to test how this would have performed over the last three years.
If this goes well, I will likely be wanting to make this a live working app, so there is likely to be more work following this :)
Acceptance Criteria
Access to the code which is well documented so that I can easily change the filter variables specified (e.g. if I want to see what happens if I change the loss aversion filter, I can easily change that number and re-run the test)
A graph showing the output of the backtest, with time on the X axis, and percentage return on the Y axis
A figure under the graph showing the results of the backtest in percentage return