Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Tausif
    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 5
    • Posts 12
    • Best 0
    • Groups 0

    Tausif

    @Tausif

    0
    Reputation
    592
    Profile views
    12
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Tausif Unfollow Follow

    Latest posts made by Tausif

    • RE: btrun how to set dtformat=('%Y-%m-%d %H:%M:%S') and tmformat =('%H:%M:%S')

      So for 15 mins timeframe should be minutes and compression 1 right?

      posted in General Code/Help
      T
      Tausif
    • RE: btrun how to set dtformat=('%Y-%m-%d %H:%M:%S') and tmformat =('%H:%M:%S')

      three records in the file(Data_Q117_asianpaint.csv) looks like -
      date,high,low,open,close,volume,openinterest
      2017-03-01 09:15:00,1033.1,1026.4,1028.95,1029.45,150520,0
      2017-03-01 09:30:00,1033.5,1028,1029,1031.4,83338,0
      2017-03-01 09:45:00,1035.9,1031.4,1031.4,1034,68902,0

      But output that i see in result.csv file is -
      Id,Data_Q117_asianpaint,len,datetime,open,high,low,close,volume,openinterest,Strategy,len,datetime,Value,len,value
      1,Data_Q117_asianpaint,1,2017-03-01 23:59:59.999989,1033.1,1026.4,1028.95,1029.45,150520.0,0.0,Strategy,1,736389.9999999999,Value,1,100000.0
      2,Data_Q117_asianpaint,2,2017-03-01 23:59:59.999989,1033.5,1028.0,1029.0,1031.4,83338.0,0.0,Strategy,2,736389.9999999999,Value,2,100000.0
      3,Data_Q117_asianpaint,3,2017-03-01 23:59:59.999989,1035.9,1031.4,1031.4,1034.0,68902.0,0.0,Strategy,3,736389.9999999999,Value,3,100000.0

      posted in General Code/Help
      T
      Tausif
    • RE: btrun how to set dtformat=('%Y-%m-%d %H:%M:%S') and tmformat =('%H:%M:%S')

      Need help if someone was able to use btrun and correctly consume 15 min data

      posted in General Code/Help
      T
      Tausif
    • btrun how to set dtformat=('%Y-%m-%d %H:%M:%S') and tmformat =('%H:%M:%S')

      Hi,
      I am using btrun to execute backtesting.
      I am trying to feed 15 mins data for backtesting my strategies using btrun.
      I would like to set dtformat and tmformat when feeding the data.
      Following is the command to execute btrun -
      btrun --csvformat btcsv --data /home/dev/backTest/btDev/data/EOD/Long/Data_Q117_asianpaint.csv --strategy /home/dev/backTest/btDev/data/tbadu99/strategyA --cash 100000 --commission 0.006 --fromdate 2017-01-01 --todate 2017-03-31 --analyzer :Returns --analyzer :DrawDown --analyzer :SharpeRatio --analyzer :Transactions --observer :Value --nostdstats --write csv=True --slip_open --slip_perc 0.01 > /home/dev/backTest/btDev/data/tbadu99/result.csv

      When using jupyter notebook backtrader correctly consumes 15 min data since we have option to specify the data format using dtformat and tmformat.

      But when going throught the btrun documentation https://www.backtrader.com/docu/automated-bt-run/automated-bt-run.html. It doesn;t have it listed anywhere.

      posted in General Code/Help
      T
      Tausif
    • RE: I've just discovered who made copyright violations on Backtrader.

      :-) Funny

      posted in General Discussion
      T
      Tausif
    • RE: Trying to close all open position after last call made to next function

      Thanks @backtrader , i was able to close all open positions.
      Changed condition to

      if len(d) == (d.buflen()-1):
      
      posted in General Code/Help
      T
      Tausif
    • btrun passing parameters to strategy

      I am trying to execute a strategy using btrun. I would also like to pass parameters stoploss and profit to the strategy. Following command line code -

       btrun --csvformat btcsv  --data /home/dev/backTest/btDev/data/EOD/data1.csv --data /home/dev/backTest/btDev/data/EOD/data2.csv --data /home/dev/backTest/btDev/data/EOD/data3.csv --data /home/dev/backTest/btDev/data/EOD/data4.csv --strategy :/home/dev/backTest/btDev/data/tbadu99/strategy00113.py:stoploss=0.01,profit=0.1 --cash 100000 --commission 0.006 --fromdate 2016-01-01 --todate 2016-04-04 --analyzer :Returns --analyzer :DrawDown --analyzer :SharpeRatio --analyzer :Transactions --observer :Value --nostdstats --write csv=True > /home/dev/backTest/btDev/data/tbadu99/result.csv
      

      Passing two parameter to strategy00113 - stoploss and profit
      While execution it produces no results
      Error below -
      No class stoploss=0.01 profit=0.1 / module /home/dev/backTest/btDev/data/tbadu99/strategy00113.py

      posted in General Code/Help
      T
      Tausif
    • RE: Trying to close all open position after last call made to next function

      I have added the self.close(d,exectype=bt.Order.Market) in the next function as below.

      def next(self):
                      i =  list(range(0, len(self.datas)))
                      for (d,j) in zip(self.datas,i):
                          if len(d) == d.buflen():
                              close = self.close(d,exectype=bt.Order.Market)
                              print(close)
      

      Also i am check if the last bar was executed by comparing len() and buflen(). print(close) shows that orders were submitted but trade did not happen.

      posted in General Code/Help
      T
      Tausif
    • Trying to close all open position after last call made to next function

      I am trying to close all open positions after last iteration call is made to next function -
      Below in the stop function i am calling self.close function to close all open positions
      def stop(self):
      i = list(range(0, len(self.datas)))
      for (d,j) in zip(self.datas,i):
      print(d.close[0])
      close = self.close(d,exectype=bt.Order.Market)
      print(close)
      print(self.datas[j]._name)
      print(self.getposition(d).size)
      print("Backtesting completed")

      self.close function does return the following:
      Ref: 92
      OrdType: 0
      OrdType: Buy
      Status: 1
      Status: Submitted
      Size: 10
      Price: None
      Price Limit: None
      TrailAmount: None
      TrailPercent: None
      ExecType: 0
      ExecType: Market
      CommInfo: None
      End of Session: 736088.9999999999
      Info: AutoOrderedDict()
      Broker: None
      Alive: True

      But the last close transaction is not captured by the bt.analyzers.Transactions. When i print the Transactions capture by the analyzer it doesn't show the last transaction which was closed by self.close().
      Please advise. Thanks

      posted in General Code/Help
      T
      Tausif
    • RE: Can i get btrun output into pandas dataframe

      ok , Thanks

      posted in General Discussion
      T
      Tausif