Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. CptanPanic
    3. Best
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    C
    • Profile
    • Following 2
    • Followers 1
    • Topics 7
    • Posts 20
    • Best 5
    • Groups 0

    Best posts made by CptanPanic

    • Anyone use backtrader to do live trading on Bitcoin exchange?

      I have set up back testing to work so far, and plan to set it up for at least live manual trade signals if not just full automated trading. I have seen a few questions, but was wondering if anyone has created a live data feed and/or broker for an exchange like gdax, bitfinex, etc.

      posted in General Discussion
      C
      CptanPanic
    • Why do I get 'None' as value for SharpeRatio?

      So I am new to backtrader, and have setup an initial strategy. I have a few analyzer added, and the other ones give a value, but the SharpeRatio one gives me 'None' Any ideas?

      cerebro = bt.Cerebro()
      
      cerebro.broker.setcash(1000.0)
      
      
      print('STart Portfolio Value: %.2f' % cerebro.broker.getvalue())
      
          # Add a strategy
      cerebro.addstrategy(TestStrategy)
          
      # Pass it to the backtrader datafeed and add it to the cerebro
      #data_feed = bt.feeds.PandasData(dataname=data['USDT_ETH'])
      
      # Create a Data Feed
      data_feed = bt.feeds.InfluxDB(
          dataname="USDT_ETH",
          username="admin",
          password="conStant",
          database="finance",
          host="192.168.1.82",
          open="open",
          close="close",
          high="high",
          low="low",
          # Do not pass values before this date
          fromdate=datetime.datetime(2017, 1, 1),
          # Do not pass values after this date
          todate=datetime.datetime(2017, 12, 31))
      
      cerebro.adddata(data_feed)
      
      data_feed = bt.feeds.InfluxDB(
          dataname="USDT_BTC",
          username="admin",
          password="conStant",
          database="finance",
          host="192.168.1.82",
          open="open",
          close="close",
          high="high",
          low="low",
          # Do not pass values before this date
          fromdate=datetime.datetime(2017, 1, 1),
          # Do not pass values after this date
          todate=datetime.datetime(2017, 12, 31))
      
      cerebro.adddata(data_feed)
      
      
      # Analyzer
      cerebro.addanalyzer(btanalyzers.SharpeRatio, _name='mysharpe')
      cerebro.addanalyzer(btanalyzers.AnnualReturn, _name='annual')
      
      thestrats = cerebro.run()
      thestrat = thestrats[0]
      
      cerebro.plot()
      
      
      print('Sharpe Ratio:', thestrat.analyzers.mysharpe.get_analysis())
      print('Anual Ratio:', thestrat.analyzers.annual.get_analysis())
      print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())
      
      '''
      posted in General Code/Help
      C
      CptanPanic
    • RE: Anyone use backtrader to do live trading on Bitcoin exchange?

      @ricpruss Actually that library ccxt looks great, it has support for tons of exchanges and is updated frequently. Would make sense to make a backtrader broker that just takes a ccxt object, and backtrader wouldn't have to worry about individual exchanges at all.

      posted in General Discussion
      C
      CptanPanic
    • RE: Tearsheets - QSTrader

      I'm just wondering what you mean by pyfolio tear-sheets are 'iffy'?

      posted in General Code/Help
      C
      CptanPanic
    • PyFolio analyzer multiple data sources not working.

      If i call get_pf_items, the positions does not show positions from all data sources. Looking at source, the suspect line is https://github.com/mementum/backtrader/blob/master/backtrader/analyzers/pyfolio.py#L130
      the v[-2:] is assuming there is only one data, and should be based on number of datas.

      posted in General Code/Help
      C
      CptanPanic
    • 1 / 1