Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Help with Sorting the Python List

    Indicators/Strategies/Analyzers
    1
    1
    34
    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.
    • K
      kk7134 last edited by

      Hi All

      I am using optimizer functionality to evaluate the best parameter combination that I can use in my trading strategy. The output from the optimizer for each parameter set (Slow_EMA, Fast_EMA) along with it's value are added to the list and the code for the same is

      val_list = [self.params.sl_maperiod, self.params.ft_maperiod,self.broker.getvalue()]
      print (val_list)

      the first column is Slow_EMA value and the second column is Fast_EMA value and the third column is the cash value that the optimizer generates for the Slow_EMA and Fast_EMA combination. I am providing the output below

      [5, 20, 101416.90550000001]
      [5, 21, 101717.35600000001]
      [5, 22, 101942.15999999999]
      [5, 23, 101938.65450000002]
      [5, 24, 101785.45050000002]
      [5, 25, 102084.91550000002]
      [5, 26, 101634.87550000002]
      [5, 27, 101835.576]
      [5, 28, 101889.99200000001]
      [5, 29, 101906.11300000001]

      I want to sort this output in a descending order based on column 3(Cash Value) such that the record with the highest value gets displayed at the top.

      Please help me here

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors