Backtrader Community

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

    Thomas Fischer

    @Thomas Fischer

    0
    Reputation
    34
    Profile views
    5
    Posts
    0
    Followers
    1
    Following
    Joined Last Online

    Thomas Fischer Unfollow Follow

    Latest posts made by Thomas Fischer

    • RE: Crypto Trading Bot for Kraken

      @backtrader Thank you very much for the advice! I will have a closer look.

      posted in General Code/Help
      Thomas Fischer
      Thomas Fischer
    • RE: Anyone use backtrader to do live trading on Bitcoin exchange?

      @Rodrigo-Brito Hello Rodrigo, thank you very much for your cool Trading Bot, it really gives me a great learning opportunity.

      posted in General Discussion
      Thomas Fischer
      Thomas Fischer
    • RE: Crypto Trading Bot for Kraken

      Chart.PNG

      posted in General Code/Help
      Thomas Fischer
      Thomas Fischer
    • RE: Crypto Trading Bot for Kraken

      @backtrader Hello, thank you for looking into this.

      If I do something stupid like:

      # Create data feeds
      try:
          hist_start_date = datetime.utcnow() - timedelta(minutes=3)
          data_min = bt.feeds.CCXT(exchange="kraken", symbol="BTC/USD", name="btc_usd_min",
                               timeframe=bt.TimeFrame.Minutes, fromdate=hist_start_date, compression=1,
                               config={'rateLimit': 10000, 'enableRateLimit': True}) #, historical=True)
      
      
      # data_min=bt.feeds.YahooFinanceData(dataname='MSFT',fromdate=datetime(2011,1,1),todate=datetime(2012,12,31))
      
          cerebro.adddata(data_min)
          print (data_min)
          cerebro.addstrategy(SmaCross)
          cerebro.run()
          cerebro.plot()
      
      except Exception as e:
          logging.error("Exeption", exc_info=True)
      
      

      I get:

      <backtrader.feeds.ccxt.CCXT object at 0x00000183FB3C3C88>
      

      Even with the Yahoo Feed it is not trading, but it is plotting the chart at least.
      I have the guts feeling the data needs to be formatted.

      posted in General Code/Help
      Thomas Fischer
      Thomas Fischer
    • Crypto Trading Bot for Kraken

      Hello all,

      I am new to Python Coding with Backtrader. I would like to create a Backtrader based Bot for Kraken Crypto exchange, but I ran into an issue with
      plotting the data for example. I have been using some SMA example code and add a CCXT Data Stream to it, it basically compiles, but it doesn't plot any data.
      I wonder if some one could have a look?

      Thank you in advance!

      from __future__ import(absolute_import, division, print_function, unicode_literals)
      from datetime import datetime, timedelta
      import backtrader as bt
      from backtrader import cerebro
      import time
      
      '''
      def connect_broker():
          config = {'urls': {'api': 'https://api.sandbox.gemini.com'},
                               'apiKey': 'XXXXX',
                               'secret': 'XXXXX',
                               'nonce': lambda: str(int(time.time() * 1000))
                              }
          broker = bt.brokers.CCXTBroker(exchange="kraken",
                                         currency="USD", config=config)
          cerebro.setbroker(broker)
      
          # Create data feeds
          data_ticks = bt.feeds.CCXT(exchange="kraken", symbol="BTC/USD",
                                    name="btc_usd_tick",
                                    timeframe=bt.TimeFrame.Ticks,
                                    compression=1, config=config)
          cerebro.adddata(data_ticks)
      '''
      
      class TestStrategy(bt.Strategy):
          #class SmaCross(bt.Strategy):
          # list of parameters which are configurable for the strategy
          params = dict(
              pfast=10,  # period for the fast moving average
              pslow=30   # period for the slow moving average
          )
      
          def __init__(self):
              sma1 = bt.ind.SMA(period=self.p.pfast)  # fast moving average
              sma2 = bt.ind.SMA(period=self.p.pslow)  # slow moving average
              self.crossover = bt.ind.CrossOver(sma1, sma2)  # crossover signal
      
          def next(self):
              if not self.position:  # not in the market
                  if self.crossover > 0:  # if fast crosses slow to the upside
                      self.buy()  # enter long
      
              elif self.crossover < 0:  # in the market & cross to the downside
                  self.close()  # close long position 
         
      if __name__ == '__main__':
          
          # Create Data Stream:
          hist_start_date = datetime.utcnow() - timedelta(minutes=60)
          data_min = bt.feeds.CCXT(exchange="kraken", symbol="BTC/USD", name="btc_usd_min", fromdate=hist_start_date,
                                   timeframe=bt.TimeFrame.Minutes)
          
          # Create Cerebro Entity
          cerebro = bt.Cerebro()
          cerebro.adddata(data_min)
          cerebro.addstrategy(TestStrategy)
          cerebro.run()
          cerebro.plot()
      
      
      posted in General Code/Help
      Thomas Fischer
      Thomas Fischer