Navigation

    Backtrader Community

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

    Trade Prophet

    @Trade Prophet

    3
    Reputation
    1082
    Profile views
    55
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Trade Prophet Unfollow Follow

    Best posts made by Trade Prophet

    • RE: Interactive Broker on daily data and paper account

      Problem Solved!

      Issues I had in the process:

      1. Paper account may receive RT bars(like 1 or 5 minutes bars), to enable that you need to enable "Share real-time market data subscriptions with paper trading account" option in your real live account, ask IB support for help to find it
      2. You MUST run the trading strategy on the same computer where the real live account runs, it's not possible to have the live account run TWS on one computer and the paper TWS run on another

      once you take care of the above, the Backtrader running IB trading should start to trade with the paper account

      posted in General Code/Help
      T
      Trade Prophet
    • RE: Find if an open position is a losing position

      Eventually, I saved the open price in a file and read it in next() method, easy...

      posted in General Code/Help
      T
      Trade Prophet
    • Error loading daily data when using todate

      Hello,
      I'm trying to load daily data from .csv files, but
      bt does not load any data from .csv file when using 'todate' parameter.
      Using this command :

                 data = bt.feeds.GenericCSVData(dataname=dataname, seperatotr=',',
                                                         dtformat='%Y-%m-%d',
                                                         datetime=0,
                                                         open=1,
                                                         high=2,
                                                         low=3,
                                                         close=4,
                                                         volume=5,
                                                         openinterest=-1,
                                                         adjclose=-1,
                                                         reverse=True,
                                                         timeframe=bt.TimeFrame.Days,
                                                         compression=1,
                                                         fromdate=datetime.datetime(2015, 1, 1),
                                                         todate=datetime.datetime(2016, 1, 1)
                                                         )
      

      on this data :

      Date,Open,High,Low,Close,Volume
      ...
      2016-01-05,201.40,201.90,200.05,201.36,110845848
      2016-01-04,200.49,201.03,198.59,201.02,222353536
      2015-12-31,205.13,205.89,203.87,203.87,114877856
      2015-12-30,207.11,207.21,205.76,205.93,63317680
      2015-12-29,206.51,207.79,206.47,207.40,92640672
      2015-12-28,204.86,205.26,203.94,205.21,65899940
      ...
      removing the 'todate' parameter and bt is OK, but with the parameter bt loads no values for any .csv file
      any idea how to fix this ?
      Thank you

      posted in General Code/Help
      T
      Trade Prophet

    Latest posts made by Trade Prophet

    • RE: IB live trade ,skip backfiling

      Thank you for the quick reply,
      Can you please tell me what to look for in the data feed reference to help me skip backfilling?
      Thank you

      posted in General Code/Help
      T
      Trade Prophet
    • IB live trade ,skip backfiling

      Hello,
      Is there a way to skip backfilling when using IB, and just use the broker for the order execution but not for data feed management?
      Thank you

      posted in General Code/Help
      T
      Trade Prophet
    • RE: Waiting a long time for IB to backfill

      Can you please specify how to activate the option? and how can I know from the messages what is slowing me down?
      Thank you

      posted in General Code/Help
      T
      Trade Prophet
    • Waiting a long time for IB to backfill

      Hello,
      I using IB for live trade but the waiting time for backfill is very long(~20 minutes+),
      I need daily bars of the last year for my strategy to start so its not many bars but still, I wait a long time,
      here is my code :
      I have a list of strategies(one in the added example) the symbols are read from csv file(2 in this case), then IB is registered and operated, nothing fancy.
      '''
      def live_trade():
      feed_folder = 'quotes'
      constituents = []
      constituents.append('SPY')

      cerebro = bt.Cerebro()
      ibstore = bt.stores.IBStore(host='127.0.0.1', port=8002, clientId=33,notifyall=True)
      cerebro.broker = ibstore.getbroker()
      
      lookback = datetime.timedelta(days=200)
      strategies = [RiskPair_NN]
      for strategy in strategies:
          strats = cerebro.addstrategy(strategy=strategy, timeframe=datetime.timedelta(days=1),optimizing=False,
                                       feed_folder=feed_folder, start_date=datetime.datetime.now() - lookback,\
                                       end_date=datetime.datetime.now())
      
      symbol_list = ['SPY']
      for strategy in strategies:
          with open(strategy.get_symbol_list_filename(), 'r') as f:
              reader = csv.reader(f)
              for ticker in reader:
                  if len(ticker): symbol_list.append(ticker[0])
      
      symbol_list = set(symbol_list)
      
      for ticker in symbol_list:
          ib_dataname = ticker+'-STK-SMART-USD'
          data = ibstore.getdata(dataname=ib_dataname, name=ticker, clientId=33, reverse=False)
          cerebro.adddata(data)
      
      cerebro.run()
      

      '''
      Can anyone share if they have to wait a long time too? can something be done about this?
      Please advise,
      Thank you.

      posted in General Code/Help
      T
      Trade Prophet
    • RE: Issue with order_target on live trading

      I have the same problem as reported in the initial post:
      in my strategy, I call self.order_target_value(...), when debugging into that function I get to the framework call value = self.broker.getvalue(datas=[data]) , this call returns an invalid value(a very large value, close to the value of the entire portfolio), in my case, it should return 0 since the ticker does not exist in IB portfolio
      Can you try and replicate this behavior and fix in case there is a bug?
      Thank you

      posted in General Code/Help
      T
      Trade Prophet
    • RE: Get analyzer result in the stop() method

      OK, Cheers.

      posted in Indicators/Strategies/Analyzers
      T
      Trade Prophet
    • RE: Get analyzer result in the stop() method

      Thx !
      Can I set a parameter for the analyzer to constantly update?

      posted in Indicators/Strategies/Analyzers
      T
      Trade Prophet
    • Get analyzer result in the stop() method

      Hi,
      Is there a way to get the results of an analyzer in the stop() method of the strategy instead of waiting for cerebro.run() to finish?

      Thank you

      posted in Indicators/Strategies/Analyzers
      T
      Trade Prophet
    • RE: error when buying stocks with ib

      Found the problem, the size parameter cant be float value, even if it is 170.0 it must be converted to an int

      posted in General Code/Help
      T
      Trade Prophet
    • error when buying stocks with ib

      Hello,
      I use ib as the live broker and everything seems to be ok until I get to the code that actually buys a stock
      self.buy(data=self.getdatabyname(ticker), size=100)
      I get the error "error() takes 2 positional arguments but 4 were given"
      can anyone help?

      posted in General Code/Help
      T
      Trade Prophet