Best language/structure for portfolio opt

Discussion in 'Automated Trading' started by Daniel.a, Oct 1, 2019.

  1. Daniel.a


    Need advice from you guys, i have an good infrastructure for my algo trading setup, that i am very happy with. I am limited of how i can control this, since its based on 3rd party software etc. I am running a multiple of strategies and my process involves ranking top strategies to use every quarter from my library.

    So here is my question, i am receiving a backtest report in a CSV format every week from every strategy i have, based in this i rank them.

    BUT, i would like to build a tool that can auto import and test / present which strategies i shall run for the next quarted based on my defined rule set, for example top 4 strategies based on sortino and NP/DD etc.. i would also like to be able to backtest what rules for sorting would have been the best in the past...
    If i at some stage build out this software to calculate diff in slippage in live trading from backtest reports, i would be very happy, but this is a second phase since it would involve link between IB and my software.

    if the proposed structure i could also later on be used to build customized Montecarlo tests, testing random entries and exits etc for my imported price series backtest it would be good.

    What shall i base this tool on? language R, python ? i do not think excel will work since there is well over 200 strategies and the amount of data for each strategy looking back 20 years with intraday trades is quite a lot..

    I will need to hire a programmer to help me, but i guess i would need advice what language/structure to base the tool/software on.

    Any advice from the pros out there is greatly appreciated
  2. I'm going to be honest and say this is unlikely to work. You won't see statistically significant differences in performance based on such short periods of time. Evidence of predicting trading strategy performance is weak, and where it does work it relies on exogenous variables rather than the performance of the strategy itself. There is also the danger you will do worse than random if, for example, your strategies have mean reverting performance. Is there a reason why you can't run all your strategies?

    tommcginnis likes this.
  3. Daniel.a


    @globalarbtrader , Thank you for taking the time to reply, .. perhaps i need to be more clear, i am not really after optimising performance, i am more after setting a process that is quantifiable to make sure i vet out strategies that is not performing .. "not performing" needs to be decided upon for me how to define this. Anyway perhaps its better to do the vetting out process one time a year... i would estimate each strategy has about 100 trades in average per year.. and to be more clear this is only intraday strategies.

    I would love to trade them all, but not doable due to lack of enough capital.

    At the moment i need to limit myself to trade 4 strategies per market, ES, CL, NG, S and SI.

  4. Yes you need to decide what you mean by not performing, and from that you can determine whether 100 trades is sufficient to make that decision. This will depend on your confidence interval; do you want to be 95% certain that a strategy is not performing? 99%? 75%?

    Why do you need more capital to run more strategies?

  5. Daniel.a


    @globalarbtrader thanks for your input, I would say that strategies not performing would for me at a basic level mean, not profitable over lets say 100 trades which would be equivalent to around 12 month of trading, especially since i do not allow any strategies for live trading that has been unprofitable during a single year since 10 years back during a backtest.

    I cant run all strategies at the same time, my money management rule for my portfolio is set to trade at a 0.25 % risk per strategy per trade of my portfolio size based on my stop.
    And i trade with 4 strategies per market.

    And if i would allow all strategies as you might suggest, then this would mean that total risk per market would be to high for my preference level i think, i could thoug prioritise between the signals to but then i would have to define what to base my priority on... :) Or increase portfolio funds, but this i would not like to do at this moment.

    So i decided some time ago to go the route of vetting out "not performing ones" this process i have not defined yet and i am still running with the initial strategies, hence my need to quantify this last step.

    Would you say that your would rather chose to prioritise between signals to not reach max amount?

    Or you would vet out the "not performing" ones?

    How would you have solved the situation for vetting/prioritising out strategies in order to keep risk according to the set MM?

    Open for suggestions, i have debating on this one by myself for a very long time.
  6. fan27


    You have several moving parts in terms of portfolio construction. Each strategy having some minimum performance level is the first part. But you can't just take the best performers because you are really interested in how the strategies perform as a group and some lesser performers might help to smooth out your equity curve. You also have to take into account that you do not want to be over allocated from a risk perspective. I use a very simple approach where I have strategy groupings and I have rules that I will only have X number of trades for a strategy grouping or a single strategy. Any trade exceeding that amount will not be taken.

    Seems like your quickest (and cheapest) path forward is to continue doing what you are doing in terms of the strategy ranking and add a component to your current setup (C#, correct?) which can limit your concurrent trades as a form of risk control.
    tommcginnis likes this.
  7. tommcginnis


    One of the things both GAT and fan27 have mentioned is that you don't want to find yourself 'chasing returns' -- which is what happens when we filter by performance post hoc.

    What is science at one time frame still becomes art at another. :confused:
  8. Daniel.a


    @fan27 thanks for feedback, My approach is to diversify and smoothen out my equity curve of my portfolio by using multiple markets in my case, ES, CL, NG, S, SI. My risk approach is to have a maximum risk per market to 1% of my portfolio If all strategies per market trades at the same time, my risk allocation per strategy is 0.25% and i use 4 strategies max per market.

    If i would do it as you, which would be ranking between signals, which i could easily setup to , but, then again the issue comes in about ranking based on previous performance, which in turn leads in to the question if picking strategies signals based on previous performance is a good thing to do. Perhaps i misunderstand though. Do you randomly exclude signals between your signals or how do you chose if you for example has N as max trades per group and you get signals exceeding this N amount ?

    My approach was to find a way to vet out the least performing ones, (which i initially planned every quarter) but as globaltrader kindly pointed to, was not optimal. so kind of back to drawing board and appreciate your thoughts on best approach. Not looking for anything super optimised but rather a robust and simple solution.

  9. Daniel.a


    @tommcginnis i agree wit this, i would say then that i am trying to find a good solution to avoid the BAD rather than chasing the best :)
    tommcginnis likes this.
  10. guru


    I’m dealing with similar issues and I have a few million strategies that never had a losing year since 2007, and many never had a losing month (most are variants of other strategies so each one isn’t fully unique). However, about 30% of those strategies (and their combinations) will stop working the following year, despite being profitable during the past 12 years, and despite some being profitable every month (simply because I can fit/overfit strategies to any level I want). And some that worked 10 years ago may start working again tomorrow.
    So now imagine using only last year or last quarter to evaluate future performance...
    You’re simply pointing the problem that everyone has with strategy selection.
    But in terms of your core question, I think that most people here use C# and others Python, so these would be couple great choices. You may want to Google topics such as “portfolio optimization Python” to find plenty of examples.
    #10     Oct 1, 2019
    fan27 and tommcginnis like this.