Navigation

    Quantiacs Community

    • Register
    • Login
    • Search
    • Categories
    • News
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Trading System Optimisation Code

    Support
    2
    2
    178
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      anshul96go last edited by

      Hi

      I have confusion regarding the trading system optimization and optimal parameter selection feature you are providing. I tried to do the same manually but the results varied with the ones I got using your trading system optimization feature. Can you tell how it decides the optimal parameters?

      support 1 Reply Last reply Reply Quote 0
      • support
        support @anshul96go last edited by admin

        Hello.

        If you open the source code qnt/optimizer.py, you can find that the optimizer uses these functions for optimization:

        
        def standard_stats_function(data, output):
            """
            Calculates statistics for the iteration output.
            :param data: market data
            :param output: weights
            :return: dict
            """
            start_date = qns.get_default_is_start_date_for_type(data.name)
            stat = qns.calc_stat(data, output.sel(time=slice(start_date, None)))
            return stat.isel(time=-1).to_pandas().to_dict()
        
        def standard_stats_to_weight(stat):
            """
            Converts the statistics to weight.
            :param stat: dict
            :return:
            """
            res = stat.get('sharpe_ratio', float('-inf'))
            if math.isfinite(res):
                return res
            else:
                return float('-inf')
        

        You can use other functions if you want. Just specify stats_function and stats_to_weight when you call optimize_strategy.

        It is ok that you use your own optimization algorithm. This one is the simplest implementation and it may not suit you perfectly. You can just reuse some code from optimizer.py which relates to workers. It may be useful if you want to speed up your optimizer.

        Regards.

        1 Reply Last reply Reply Quote 1
        • First post
          Last post
        Powered by NodeBB | Contributors
        • Documentation
        • About
        • Career
        • My account
        • Privacy policy
        • Terms and Conditions
        • Cookies policy
        Home
        Copyright © 2014 - 2021 Quantiacs LLC.
        Powered by NodeBB | Contributors