Backtrader Community

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

    jesseliu0

    @jesseliu0

    4
    Reputation
    58
    Profile views
    20
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    jesseliu0 Unfollow Follow

    Best posts made by jesseliu0

    • RE: Please help to understand cash changes

      @backtrader said in Please help to understand cash changes:

      Which obviously has no times 10 (i.e.: the multiplier in the above calculation).

      In the first post, I put the code

      comm_rb = CommInfoFutures(commission=1e-4, margin=0.09, mult=10.0)
      

      I use 0.9 because 0.9 = 0.09 * 10.

      @backtrader said in Please help to understand cash changes:

      Cash remaining in your account after you enter the market: 20000000.00 - 2615 * 0.9 = 19997646.50
      Closing price: 2609
      Cash to be added to your account at the end of the day: (2615 - 2609) * 10 = 60.00
      Cash at the end of the day: 19997646.50 + 60.00 = 19997706.50.

      The margin cost at the end of day should be based on close price 2609 instead of the price when entering the market 2615, so cash at the end of day should be 20000000.00 - 2609 * 0.9 + 60, instead of 20000000.00 - 2615 * 0.9 + 60.

      About the value. My understanding is some money could move between margin cost and cash in the account, but the total account value should not be affected by margin cost. I think the account value at the end of day should be 20000000.00 + 60, instead of 20000000.00 + (2609 - 2615) * 0.9 + 60.

      Sorry if the calculations confused you. I don't think more code helps since the problem and reasoning are very simple. More code just bring more confuse.

      @backtrader said in Please help to understand cash changes:

      I would go into the market and buy 1-future of whatever and see how things work. Real life experience does really mean something.

      Yes I did.

      posted in General Code/Help
      J
      jesseliu0
    • RE: How to get the next trading day's date?

      @run-out
      Cool! Exactly what I want. Thank you so much.

      posted in General Code/Help
      J
      jesseliu0
    • RE: How to optimize with a list of grouped parameters?

      @vladisld Thank you!

      posted in General Code/Help
      J
      jesseliu0

    Latest posts made by jesseliu0

    • RE: How to optimize with a list of grouped parameters?

      @vladisld Thank you!

      posted in General Code/Help
      J
      jesseliu0
    • How to optimize with a list of grouped parameters?

      Hi,

      I'm trying to run an optimization for a strategy. As I learned, I can do something like cerebro.optstrategy(MyStrategy, param1=param1_val_list, param2=param2_val_list, param3=param3_val_list).

      However, I don't want to run over every value on the value grid, but just a manually picked subsets. In this way the parameters are grouped like this:
      param_groups = [(param1_val, param2_val, param3_val), (param1_val, param2_val, param3_val), (param1_val, param2_val, param3_val), ...], so the value grid is irregular. Can someone suggest how to pass this list to the optimization engine? Thank you!

      posted in General Code/Help
      J
      jesseliu0
    • RE: Issue with extending a data feed

      I have the same issue. Looks like data extending does not work with cerebro.resampledata(). You can duplicate with the following code and data. @sirbradflies @backtrader

      import datetime
      import numpy as np
      import pandas as pd
      import backtrader as bt
      
      
      class PandasDataExt(bt.feeds.PandasData):
          lines = ('dtstamp',)
          params=(
              ('datetime', None),
              ('open', 'open'),
              ('high', 'high'),
              ('low', 'low'),
              ('close', 'close'),
              ('volume', 'volume'),
              ('openinterest', None),
              ('dtstamp', 'dtstamp'),
          )
      setattr(bt.metabase, PandasDataExt.__name__, PandasDataExt)
      
      class MyStrategy(bt.Strategy):
          def next(self):
              print(self.data.datetime.datetime(0), self.data0.dtstamp[0], self.data1.dtstamp[0])
      
      
      if __name__ == '__main__':
          cerebro = bt.Cerebro()
          cerebro.addstrategy(MyStrategy)
      
          df = pd.read_csv("~/Workspace/data.csv", index_col=0)
          df.index = pd.DatetimeIndex(df.index)
          df['dtstamp'] = df.index.astype(np.int64) // 10**9
          my_data = PandasDataExt(dataname=df, name='MyData', timeframe=bt.TimeFrame.Minutes)
          cerebro.adddata(my_data, name='MyData')
          resampled_data = PandasDataExt(dataname=df, name='ResampledData', timeframe=bt.TimeFrame.Minutes)
          cerebro.resampledata(resampled_data, name='ResampledData', timeframe=bt.TimeFrame.Minutes, compression=5)
          cerebro.run()
      
      datetime,open,high,low,close,volume
      2020-02-02 17:00:00,8982.75,9024.0,8975.0,9013.5,2480
      2020-02-02 17:01:00,9011.75,9024.75,9011.75,9017.75,875
      2020-02-02 17:02:00,9018.75,9032.75,9018.0,9031.0,802
      2020-02-02 17:03:00,9030.5,9032.0,9021.25,9029.0,493
      2020-02-02 17:04:00,9029.0,9032.25,9024.0,9024.0,454
      2020-02-02 17:05:00,9024.0,9024.25,9017.5,9021.75,419
      2020-02-02 17:06:00,9021.5,9027.5,9018.75,9027.25,360
      2020-02-02 17:07:00,9027.5,9032.5,9027.25,9028.0,316
      2020-02-02 17:08:00,9028.75,9029.0,9016.5,9017.0,467
      2020-02-02 17:09:00,9017.0,9017.75,9009.75,9012.0,431
      2020-02-02 17:10:00,9011.25,9012.5,9008.0,9008.0,198
      2020-02-02 17:11:00,9008.75,9008.75,8999.0,8999.5,617
      2020-02-02 17:12:00,8999.0,9017.0,8998.0,9012.5,764
      2020-02-02 17:13:00,9012.75,9018.25,9011.5,9018.0,296
      2020-02-02 17:14:00,9017.25,9023.25,9014.75,9022.75,369
      2020-02-02 17:15:00,9022.75,9024.5,9016.25,9021.5,352
      2020-02-02 17:16:00,9021.5,9028.0,9015.0,9023.5,388
      2020-02-02 17:17:00,9023.0,9025.75,9021.25,9023.75,121
      2020-02-02 17:18:00,9024.5,9026.25,9018.25,9020.25,196
      2020-02-02 17:19:00,9021.5,9021.5,9017.75,9020.75,105
      2020-02-02 17:20:00,9020.25,9023.5,9020.25,9023.0,167
      2020-02-02 17:21:00,9022.25,9028.0,9022.25,9024.75,246
      2020-02-02 17:22:00,9025.5,9031.0,9021.25,9022.5,381
      2020-02-02 17:23:00,9023.0,9023.25,9018.0,9018.5,180
      2020-02-02 17:24:00,9019.0,9029.75,9019.0,9028.0,296
      2020-02-02 17:25:00,9027.25,9031.25,9023.5,9024.5,444
      2020-02-02 17:26:00,9024.5,9028.5,9021.75,9028.5,198
      2020-02-02 17:27:00,9028.75,9031.25,9026.0,9030.25,358
      2020-02-02 17:28:00,9030.0,9030.25,9027.0,9027.25,190
      2020-02-02 17:29:00,9026.75,9030.25,9024.5,9025.5,276
      2020-02-02 17:30:00,9026.0,9028.5,9022.75,9027.5,245
      2020-02-02 17:31:00,9028.25,9031.25,9028.25,9030.75,160
      2020-02-02 17:32:00,9031.25,9038.25,9030.25,9030.5,682
      2020-02-02 17:33:00,9030.5,9031.25,9029.25,9029.5,132
      2020-02-02 17:34:00,9029.75,9030.25,9023.75,9025.25,312
      2020-02-02 17:35:00,9025.5,9029.25,9021.0,9026.0,262
      2020-02-02 17:36:00,9026.0,9027.5,9020.75,9021.5,177
      2020-02-02 17:37:00,9022.0,9026.75,9021.75,9025.75,165
      2020-02-02 17:38:00,9026.0,9029.25,9026.0,9029.0,181
      2020-02-02 17:39:00,9029.25,9031.5,9028.25,9030.5,123
      2020-02-02 17:40:00,9031.0,9034.75,9027.25,9028.5,291
      2020-02-02 17:41:00,9028.5,9031.5,9026.0,9027.0,182
      2020-02-02 17:42:00,9028.0,9030.5,9028.0,9029.5,95
      2020-02-02 17:43:00,9029.75,9030.25,9026.25,9027.75,113
      2020-02-02 17:44:00,9028.0,9031.75,9027.25,9030.0,137
      2020-02-02 17:45:00,9030.25,9031.75,9021.5,9025.5,297
      2020-02-02 17:46:00,9024.75,9024.75,9016.0,9022.25,535
      2020-02-02 17:47:00,9022.0,9026.0,9018.0,9019.75,318
      2020-02-02 17:48:00,9019.75,9023.5,9018.0,9020.0,246
      2020-02-02 17:49:00,9020.5,9021.0,9017.25,9018.75,165
      2020-02-02 17:50:00,9018.25,9019.25,9012.75,9014.5,334
      2020-02-02 17:51:00,9014.0,9018.0,9013.0,9013.25,200
      2020-02-02 17:52:00,9013.5,9016.5,9013.25,9015.25,145
      2020-02-02 17:53:00,9014.75,9015.0,9011.5,9011.75,131
      2020-02-02 17:54:00,9011.75,9014.25,9010.5,9013.0,183
      2020-02-02 17:55:00,9013.0,9016.25,9012.0,9015.0,247
      2020-02-02 17:56:00,9014.75,9018.75,9014.25,9017.75,248
      2020-02-02 17:57:00,9017.5,9020.25,9017.25,9019.25,161
      2020-02-02 17:58:00,9019.75,9020.75,9017.5,9018.75,97
      2020-02-02 17:59:00,9018.25,9020.75,9017.25,9020.75,127
      2020-02-02 18:00:00,9020.0,9020.0,9017.75,9018.0,148
      2020-02-02 18:01:00,9018.25,9019.0,9011.25,9016.25,323
      2020-02-02 18:02:00,9016.0,9020.25,9016.0,9018.75,177
      2020-02-02 18:03:00,9018.75,9024.25,9017.5,9017.5,357
      2020-02-02 18:04:00,9017.5,9021.75,9016.0,9020.25,212
      2020-02-02 18:05:00,9020.5,9025.0,9020.5,9023.25,228
      2020-02-02 18:06:00,9023.25,9024.25,9019.5,9023.0,233
      2020-02-02 18:07:00,9023.0,9023.0,9019.0,9020.0,206
      2020-02-02 18:08:00,9020.75,9023.25,9020.75,9022.5,139
      2020-02-02 18:09:00,9022.0,9023.75,9020.75,9023.25,100
      2020-02-02 18:10:00,9023.25,9027.75,9022.25,9024.0,441
      2020-02-02 18:11:00,9023.75,9032.25,9023.75,9031.25,440
      2020-02-02 18:12:00,9031.5,9035.0,9030.5,9030.75,613
      2020-02-02 18:13:00,9031.0,9034.0,9029.0,9031.0,261
      2020-02-02 18:14:00,9031.0,9031.75,9027.25,9028.0,244
      2020-02-02 18:15:00,9028.25,9028.5,9025.5,9025.75,156
      2020-02-02 18:16:00,9026.0,9026.0,9021.0,9024.0,317
      2020-02-02 18:17:00,9024.5,9026.25,9022.0,9022.5,147
      2020-02-02 18:18:00,9022.25,9024.0,9020.25,9023.0,244
      2020-02-02 18:19:00,9022.5,9025.0,9021.25,9025.0,157
      2020-02-02 18:20:00,9024.5,9026.0,9023.5,9025.75,139
      2020-02-02 18:21:00,9026.0,9028.0,9025.75,9027.75,123
      2020-02-02 18:22:00,9027.75,9029.25,9025.75,9026.5,161
      2020-02-02 18:23:00,9026.5,9028.0,9025.75,9026.75,77
      2020-02-02 18:24:00,9026.75,9029.25,9026.75,9028.25,91
      2020-02-02 18:25:00,9028.25,9031.0,9028.0,9028.5,172
      2020-02-02 18:26:00,9028.25,9028.5,9027.5,9027.5,48
      2020-02-02 18:27:00,9028.0,9029.0,9027.0,9029.0,80
      2020-02-02 18:28:00,9028.75,9029.5,9027.5,9028.25,47
      2020-02-02 18:29:00,9028.5,9029.75,9028.5,9028.5,77
      2020-02-02 18:30:00,9028.5,9029.0,9027.0,9027.75,62
      2020-02-02 18:31:00,9027.75,9031.25,9026.25,9030.5,140
      2020-02-02 18:32:00,9030.5,9032.75,9030.25,9032.5,129
      2020-02-02 18:33:00,9032.5,9032.75,9031.5,9032.75,76
      2020-02-02 18:34:00,9032.75,9034.0,9032.0,9033.75,130
      2020-02-02 18:35:00,9033.5,9040.0,9033.5,9040.0,495
      2020-02-02 18:36:00,9039.5,9044.25,9039.5,9040.75,581
      2020-02-02 18:37:00,9041.0,9048.5,9040.75,9047.5,507
      2020-02-02 18:38:00,9047.5,9055.25,9047.5,9053.25,908
      2020-02-02 18:39:00,9053.5,9053.5,9049.0,9050.0,362
      2020-02-02 18:40:00,9049.75,9051.25,9046.25,9048.0,278
      2020-02-02 18:41:00,9048.25,9048.25,9042.25,9044.25,341
      2020-02-02 18:42:00,9043.75,9046.5,9043.25,9044.75,108
      2020-02-02 18:43:00,9044.25,9047.75,9044.25,9045.5,161
      2020-02-02 18:44:00,9046.0,9053.75,9045.75,9051.75,394
      2020-02-02 18:45:00,9051.5,9058.0,9051.5,9057.25,481
      2020-02-02 18:46:00,9057.75,9065.5,9057.25,9063.75,596
      2020-02-02 18:47:00,9063.5,9063.5,9054.25,9057.25,371
      2020-02-02 18:48:00,9057.5,9058.0,9053.5,9055.25,264
      2020-02-02 18:49:00,9056.0,9056.0,9050.0,9050.25,216
      2020-02-02 18:50:00,9050.25,9051.75,9047.25,9049.75,375
      2020-02-02 18:51:00,9049.25,9050.5,9045.75,9049.25,256
      2020-02-02 18:52:00,9049.5,9051.5,9048.0,9049.0,177
      2020-02-02 18:53:00,9049.25,9049.75,9046.5,9047.0,262
      2020-02-02 18:54:00,9047.25,9049.75,9046.75,9048.75,157
      2020-02-02 18:55:00,9049.0,9051.5,9046.25,9050.75,358
      2020-02-02 18:56:00,9050.75,9053.5,9046.75,9046.75,219
      2020-02-02 18:57:00,9046.5,9049.25,9046.25,9048.0,188
      2020-02-02 18:58:00,9047.75,9048.0,9046.0,9048.0,79
      2020-02-02 18:59:00,9048.0,9049.0,9045.0,9045.0,146
      2020-02-02 19:00:00,9044.75,9045.75,9028.5,9040.5,940
      2020-02-02 19:01:00,9040.25,9043.0,9036.5,9039.25,662
      2020-02-02 19:02:00,9039.25,9044.25,9037.0,9043.75,301
      2020-02-02 19:03:00,9043.75,9044.0,9040.75,9040.75,266
      2020-02-02 19:04:00,9041.0,9041.25,9028.5,9033.75,729
      2020-02-02 19:05:00,9033.75,9037.0,9028.0,9036.75,765
      2020-02-02 19:06:00,9037.0,9037.5,9034.0,9036.75,312
      2020-02-02 19:07:00,9037.25,9047.75,9035.0,9043.5,612
      2020-02-02 19:08:00,9043.0,9051.5,9041.0,9045.75,560
      2020-02-02 19:09:00,9045.75,9053.75,9045.25,9049.0,437
      2020-02-02 19:10:00,9049.25,9056.0,9047.5,9053.25,444
      2020-02-02 19:11:00,9053.75,9058.25,9052.75,9054.0,386
      2020-02-02 19:12:00,9054.5,9057.75,9054.0,9055.0,319
      2020-02-02 19:13:00,9054.0,9054.0,9048.5,9050.5,399
      2020-02-02 19:14:00,9050.5,9053.0,9047.5,9048.25,337
      2020-02-02 19:15:00,9048.5,9051.75,9046.0,9050.5,356
      2020-02-02 19:16:00,9050.0,9050.25,9043.0,9045.0,399
      2020-02-02 19:17:00,9045.0,9045.0,9040.75,9042.5,294
      2020-02-02 19:18:00,9042.75,9050.0,9042.0,9047.75,310
      2020-02-02 19:19:00,9047.5,9047.5,9043.25,9044.75,173
      2020-02-02 19:20:00,9044.75,9049.25,9043.0,9049.25,146
      2020-02-02 19:21:00,9048.5,9050.0,9044.0,9046.25,244
      2020-02-02 19:22:00,9045.5,9047.25,9041.25,9041.5,200
      2020-02-02 19:23:00,9041.25,9041.25,9034.0,9037.0,367
      2020-02-02 19:24:00,9037.25,9038.25,9034.75,9037.75,305
      2020-02-02 19:25:00,9037.5,9045.5,9035.25,9043.75,295
      2020-02-02 19:26:00,9043.5,9044.25,9040.0,9041.75,149
      2020-02-02 19:27:00,9041.5,9043.0,9034.25,9036.75,315
      2020-02-02 19:28:00,9036.5,9040.0,9034.25,9035.25,245
      2020-02-02 19:29:00,9035.0,9045.0,9033.0,9043.75,384
      2020-02-02 19:30:00,9043.75,9048.5,9037.75,9043.5,466
      2020-02-02 19:31:00,9043.75,9056.25,9042.75,9055.75,462
      2020-02-02 19:32:00,9056.0,9058.75,9051.0,9056.5,542
      2020-02-02 19:33:00,9056.25,9069.75,9055.5,9068.25,969
      2020-02-02 19:34:00,9067.75,9068.75,9061.5,9063.0,650
      2020-02-02 19:35:00,9063.0,9066.0,9061.0,9062.75,403
      2020-02-02 19:36:00,9062.5,9067.75,9061.75,9062.75,280
      2020-02-02 19:37:00,9062.5,9076.5,9059.75,9073.5,1012
      2020-02-02 19:38:00,9073.75,9075.0,9068.5,9069.0,547
      2020-02-02 19:39:00,9069.25,9071.25,9063.75,9068.75,589
      2020-02-02 19:40:00,9068.25,9070.75,9065.75,9069.5,204
      2020-02-02 19:41:00,9069.5,9073.0,9069.25,9072.0,306
      2020-02-02 19:42:00,9072.75,9074.75,9069.25,9073.5,285
      2020-02-02 19:43:00,9073.5,9073.5,9067.0,9067.25,341
      2020-02-02 19:44:00,9067.25,9068.25,9063.75,9064.5,355
      2020-02-02 19:45:00,9064.25,9072.25,9064.0,9065.75,315
      2020-02-02 19:46:00,9065.25,9066.75,9061.5,9065.0,252
      2020-02-02 19:47:00,9065.0,9066.25,9059.75,9059.75,355
      2020-02-02 19:48:00,9059.75,9064.0,9059.5,9061.25,374
      2020-02-02 19:49:00,9060.75,9068.25,9059.75,9064.5,293
      2020-02-02 19:50:00,9065.25,9068.5,9064.25,9067.25,260
      2020-02-02 19:51:00,9067.0,9070.5,9065.0,9069.75,205
      2020-02-02 19:52:00,9070.0,9073.0,9069.0,9072.5,246
      2020-02-02 19:53:00,9072.0,9075.25,9068.5,9070.5,382
      2020-02-02 19:54:00,9071.25,9072.5,9068.5,9071.0,180
      2020-02-02 19:55:00,9070.75,9071.0,9065.75,9066.5,231
      2020-02-02 19:56:00,9066.75,9074.75,9066.5,9074.0,308
      2020-02-02 19:57:00,9074.25,9074.5,9069.75,9071.0,215
      2020-02-02 19:58:00,9071.25,9074.5,9069.0,9072.0,212
      2020-02-02 19:59:00,9072.25,9079.5,9072.25,9077.5,593
      2020-02-02 20:00:00,9077.5,9087.0,9073.5,9086.5,1824
      2020-02-02 20:01:00,9086.75,9092.25,9082.5,9082.5,1141
      2020-02-02 20:02:00,9082.75,9086.25,9080.25,9082.25,750
      2020-02-02 20:03:00,9082.5,9083.5,9077.0,9077.25,364
      2020-02-02 20:04:00,9077.0,9079.25,9076.0,9078.0,304
      2020-02-02 20:05:00,9078.25,9078.75,9074.25,9074.75,233
      2020-02-02 20:06:00,9074.75,9077.25,9072.0,9072.5,405
      2020-02-02 20:07:00,9072.25,9073.5,9069.0,9069.25,394
      2020-02-02 20:08:00,9069.25,9073.0,9066.75,9067.25,413
      2020-02-02 20:09:00,9066.75,9072.25,9066.75,9071.25,191
      2020-02-02 20:10:00,9071.5,9072.25,9070.0,9070.25,141
      2020-02-02 20:11:00,9069.75,9070.0,9064.0,9070.0,595
      2020-02-02 20:12:00,9069.75,9069.75,9065.25,9065.25,268
      2020-02-02 20:13:00,9065.75,9067.5,9064.25,9065.75,241
      2020-02-02 20:14:00,9065.75,9065.75,9061.5,9062.0,353
      2020-02-02 20:15:00,9062.25,9066.75,9060.0,9066.75,708
      2020-02-02 20:16:00,9066.25,9066.75,9062.5,9064.5,235
      2020-02-02 20:17:00,9065.0,9071.5,9065.0,9070.75,270
      2020-02-02 20:18:00,9071.25,9071.25,9067.75,9070.0,180
      2020-02-02 20:19:00,9069.75,9072.0,9068.75,9069.5,177
      2020-02-02 20:20:00,9069.25,9071.25,9067.0,9071.0,159
      2020-02-02 20:21:00,9071.0,9073.5,9069.75,9072.0,208
      2020-02-02 20:22:00,9072.5,9076.25,9071.0,9074.75,248
      2020-02-02 20:23:00,9074.25,9075.0,9071.5,9072.25,103
      2020-02-02 20:24:00,9072.5,9073.0,9066.75,9067.25,190
      2020-02-02 20:25:00,9067.0,9070.25,9065.25,9066.0,163
      2020-02-02 20:26:00,9066.25,9071.75,9066.0,9071.0,143
      2020-02-02 20:27:00,9070.25,9070.25,9065.5,9065.75,86
      2020-02-02 20:28:00,9066.0,9070.0,9065.25,9068.25,173
      2020-02-02 20:29:00,9068.25,9068.75,9066.0,9067.5,96
      2020-02-02 20:30:00,9067.25,9069.75,9066.5,9068.5,161
      2020-02-02 20:31:00,9068.0,9068.0,9066.0,9066.5,73
      2020-02-02 20:32:00,9066.75,9070.5,9065.5,9067.5,171
      2020-02-02 20:33:00,9067.25,9067.25,9061.0,9061.75,299
      2020-02-02 20:34:00,9061.5,9063.0,9060.25,9061.25,206
      2020-02-02 20:35:00,9061.5,9067.25,9060.75,9067.0,218
      2020-02-02 20:36:00,9066.5,9068.5,9064.25,9067.0,198
      2020-02-02 20:37:00,9067.0,9068.25,9066.25,9067.25,66
      2020-02-02 20:38:00,9067.0,9068.75,9065.5,9067.5,127
      2020-02-02 20:39:00,9067.75,9067.75,9062.75,9065.5,143
      2020-02-02 20:40:00,9065.5,9066.25,9063.25,9065.0,98
      2020-02-02 20:41:00,9065.0,9066.0,9064.0,9065.0,49
      2020-02-02 20:42:00,9064.75,9065.25,9062.25,9063.25,70
      2020-02-02 20:43:00,9063.75,9066.5,9063.5,9065.75,72
      2020-02-02 20:44:00,9065.5,9065.5,9061.25,9064.0,141
      2020-02-02 20:45:00,9064.25,9065.0,9061.5,9061.75,79
      2020-02-02 20:46:00,9062.25,9063.75,9059.0,9059.5,201
      2020-02-02 20:47:00,9059.5,9059.75,9055.75,9056.75,384
      2020-02-02 20:48:00,9056.75,9058.75,9056.5,9056.5,138
      2020-02-02 20:49:00,9056.5,9056.5,9053.75,9054.75,277
      2020-02-02 20:50:00,9055.0,9056.0,9053.25,9055.5,132
      2020-02-02 20:51:00,9056.0,9060.25,9056.0,9059.5,172
      2020-02-02 20:52:00,9059.25,9059.25,9055.25,9056.0,139
      2020-02-02 20:53:00,9056.0,9056.25,9053.0,9053.0,163
      2020-02-02 20:54:00,9053.25,9059.5,9053.0,9059.0,131
      2020-02-02 20:55:00,9058.75,9058.75,9056.5,9058.25,83
      2020-02-02 20:56:00,9057.75,9057.75,9054.5,9055.25,117
      2020-02-02 20:57:00,9055.5,9058.25,9054.25,9057.5,70
      2020-02-02 20:58:00,9057.5,9057.75,9055.0,9055.5,54
      2020-02-02 20:59:00,9055.5,9057.5,9054.75,9055.5,62
      2020-02-02 21:00:00,9055.75,9057.25,9055.0,9057.0,74
      2020-02-02 21:01:00,9057.0,9063.5,9056.75,9061.25,285
      2020-02-02 21:02:00,9061.0,9061.0,9057.75,9058.25,101
      2020-02-02 21:03:00,9058.25,9059.5,9057.0,9057.0,81
      2020-02-02 21:04:00,9057.0,9057.0,9051.75,9053.0,191
      2020-02-02 21:05:00,9052.75,9056.25,9052.5,9055.25,105
      2020-02-02 21:06:00,9055.25,9056.25,9054.25,9054.75,63
      2020-02-02 21:07:00,9054.75,9055.25,9052.75,9053.0,90
      2020-02-02 21:08:00,9052.75,9054.5,9052.5,9053.5,96
      2020-02-02 21:09:00,9053.25,9059.25,9052.25,9058.75,147
      2020-02-02 21:10:00,9058.5,9059.5,9057.0,9057.75,138
      2020-02-02 21:11:00,9057.75,9058.75,9056.75,9057.0,82
      2020-02-02 21:12:00,9056.5,9057.5,9055.75,9057.0,102
      2020-02-02 21:13:00,9056.75,9061.5,9056.75,9060.5,131
      2020-02-02 21:14:00,9060.75,9061.25,9059.25,9059.75,92
      2020-02-02 21:15:00,9059.5,9059.5,9056.5,9059.0,172
      2020-02-02 21:16:00,9059.25,9071.0,9059.25,9067.75,471
      2020-02-02 21:17:00,9067.75,9070.0,9066.25,9068.75,428
      2020-02-02 21:18:00,9068.5,9069.5,9067.75,9068.0,277
      2020-02-02 21:19:00,9068.0,9069.0,9067.75,9069.0,82
      2020-02-02 21:20:00,9068.75,9071.5,9068.0,9070.25,231
      2020-02-02 21:21:00,9070.25,9071.25,9069.0,9070.25,198
      2020-02-02 21:22:00,9070.5,9075.25,9070.0,9075.25,376
      2020-02-02 21:23:00,9075.5,9077.0,9074.0,9074.75,274
      2020-02-02 21:24:00,9075.25,9076.75,9074.25,9076.0,183
      2020-02-02 21:25:00,9075.75,9075.75,9073.5,9075.0,223
      2020-02-02 21:26:00,9075.0,9078.25,9073.75,9074.0,212
      2020-02-02 21:27:00,9073.75,9074.5,9071.75,9073.75,332
      2020-02-02 21:28:00,9074.25,9074.75,9070.5,9071.5,119
      2020-02-02 21:29:00,9071.75,9072.75,9070.25,9072.5,120
      2020-02-02 21:30:00,9072.25,9073.5,9070.5,9070.75,146
      2020-02-02 21:31:00,9070.5,9073.5,9067.75,9073.5,200
      2020-02-02 21:32:00,9073.75,9074.0,9072.25,9073.25,77
      2020-02-02 21:33:00,9073.75,9077.0,9073.75,9075.25,139
      2020-02-02 21:34:00,9075.25,9076.5,9074.0,9075.0,89
      2020-02-02 21:35:00,9074.5,9077.0,9074.5,9075.75,156
      2020-02-02 21:36:00,9076.25,9077.0,9072.25,9072.75,170
      2020-02-02 21:37:00,9072.75,9073.25,9070.5,9071.75,71
      2020-02-02 21:38:00,9072.0,9072.5,9070.5,9071.75,49
      2020-02-02 21:39:00,9071.25,9071.75,9070.75,9070.75,34
      2020-02-02 21:40:00,9070.5,9072.0,9069.5,9070.75,88
      2020-02-02 21:41:00,9070.25,9071.75,9070.0,9070.25,54
      2020-02-02 21:42:00,9070.25,9070.25,9068.25,9068.75,70
      2020-02-02 21:43:00,9068.75,9070.0,9068.5,9069.0,64
      2020-02-02 21:44:00,9069.0,9069.75,9068.5,9069.25,25
      2020-02-02 21:45:00,9069.0,9070.75,9068.25,9070.75,58
      2020-02-02 21:46:00,9070.5,9070.75,9066.5,9067.75,144
      2020-02-02 21:47:00,9067.75,9069.5,9067.75,9069.5,33
      2020-02-02 21:48:00,9069.5,9073.75,9069.5,9070.75,205
      2020-02-02 21:49:00,9070.75,9071.0,9068.5,9069.5,103
      2020-02-02 21:50:00,9069.5,9070.75,9069.0,9070.0,53
      2020-02-02 21:51:00,9069.75,9070.5,9069.25,9070.25,46
      2020-02-02 21:52:00,9070.25,9072.0,9070.25,9071.75,53
      2020-02-02 21:53:00,9072.0,9076.0,9072.0,9074.0,274
      2020-02-02 21:54:00,9074.25,9074.25,9071.0,9071.5,88
      2020-02-02 21:55:00,9071.5,9072.25,9070.0,9071.5,60
      2020-02-02 21:56:00,9072.0,9076.0,9072.0,9074.5,123
      2020-02-02 21:57:00,9074.0,9074.25,9072.0,9073.0,69
      2020-02-02 21:58:00,9072.5,9074.0,9072.25,9073.25,65
      2020-02-02 21:59:00,9072.75,9073.5,9072.5,9073.25,23
      2020-02-02 22:00:00,9073.75,9077.25,9073.0,9073.0,205
      2020-02-02 22:01:00,9073.5,9073.5,9071.0,9071.5,109
      2020-02-02 22:02:00,9071.25,9071.5,9069.0,9069.25,81
      2020-02-02 22:03:00,9069.0,9069.0,9065.5,9066.25,175
      2020-02-02 22:04:00,9066.5,9067.5,9065.75,9066.0,118
      2020-02-02 22:05:00,9065.75,9068.0,9065.75,9066.75,69
      2020-02-02 22:06:00,9067.0,9068.0,9066.5,9067.5,60
      2020-02-02 22:07:00,9067.75,9068.25,9066.0,9067.75,108
      2020-02-02 22:08:00,9067.75,9068.0,9066.0,9066.25,52
      2020-02-02 22:09:00,9066.25,9068.0,9065.5,9067.25,74
      2020-02-02 22:10:00,9067.5,9068.0,9066.5,9066.5,75
      2020-02-02 22:11:00,9066.5,9068.0,9065.75,9065.75,60
      2020-02-02 22:12:00,9066.25,9067.0,9065.25,9066.5,63
      2020-02-02 22:13:00,9066.25,9066.75,9066.0,9066.0,39
      2020-02-02 22:14:00,9066.0,9066.0,9064.25,9065.25,68
      2020-02-02 22:15:00,9065.5,9067.0,9065.25,9066.75,50
      2020-02-02 22:16:00,9066.75,9067.75,9066.5,9067.0,60
      2020-02-02 22:17:00,9067.5,9071.25,9067.5,9070.75,185
      2020-02-02 22:18:00,9070.5,9072.0,9070.25,9070.5,108
      2020-02-02 22:19:00,9070.75,9071.0,9069.25,9070.25,84
      2020-02-02 22:20:00,9070.25,9071.0,9069.75,9070.0,54
      2020-02-02 22:21:00,9070.25,9070.75,9069.75,9070.0,27
      2020-02-02 22:22:00,9069.75,9071.0,9069.0,9070.75,40
      2020-02-02 22:23:00,9070.75,9071.0,9069.25,9069.75,32
      2020-02-02 22:24:00,9069.25,9069.25,9067.75,9068.0,65
      2020-02-02 22:25:00,9068.0,9070.75,9067.75,9070.0,58
      2020-02-02 22:26:00,9069.75,9070.75,9069.25,9070.75,24
      2020-02-02 22:27:00,9070.75,9070.75,9069.0,9069.0,26
      2020-02-02 22:28:00,9068.75,9069.75,9067.75,9068.75,58
      2020-02-02 22:29:00,9069.0,9072.25,9068.5,9071.75,98
      2020-02-02 22:30:00,9071.75,9071.75,9070.5,9071.0,46
      2020-02-02 22:31:00,9070.75,9070.75,9067.75,9067.75,54
      2020-02-02 22:32:00,9067.75,9068.75,9067.5,9068.0,32
      2020-02-02 22:33:00,9067.75,9068.0,9066.5,9067.5,31
      2020-02-02 22:34:00,9067.75,9068.75,9067.0,9068.25,44
      2020-02-02 22:35:00,9069.0,9070.25,9068.25,9070.25,51
      2020-02-02 22:36:00,9069.75,9070.25,9069.25,9070.25,18
      2020-02-02 22:37:00,9070.0,9070.25,9069.5,9070.0,26
      2020-02-02 22:38:00,9069.75,9070.25,9068.5,9068.75,74
      2020-02-02 22:39:00,9069.0,9069.5,9068.5,9068.75,17
      2020-02-02 22:40:00,9068.5,9069.25,9067.75,9068.0,21
      2020-02-02 22:41:00,9067.75,9069.0,9066.25,9068.5,89
      2020-02-02 22:42:00,9068.5,9069.75,9068.5,9069.5,20
      2020-02-02 22:43:00,9069.75,9070.5,9067.5,9068.25,39
      2020-02-02 22:44:00,9068.0,9069.25,9068.0,9068.0,28
      2020-02-02 22:45:00,9068.0,9068.0,9066.75,9067.25,33
      2020-02-02 22:46:00,9068.75,9069.25,9068.75,9069.25,26
      2020-02-02 22:47:00,9069.0,9069.75,9068.25,9069.5,36
      2020-02-02 22:48:00,9069.5,9069.75,9067.5,9067.75,55
      2020-02-02 22:49:00,9067.5,9068.75,9066.0,9067.25,124
      2020-02-02 22:50:00,9067.25,9069.25,9066.5,9069.25,39
      2020-02-02 22:51:00,9068.75,9070.0,9068.25,9070.0,41
      2020-02-02 22:52:00,9070.0,9072.0,9070.0,9071.0,127
      2020-02-02 22:53:00,9071.0,9071.75,9071.0,9071.0,50
      2020-02-02 22:54:00,9070.75,9071.25,9070.75,9071.0,51
      2020-02-02 22:55:00,9071.0,9072.25,9071.0,9072.25,91
      2020-02-02 22:56:00,9072.25,9074.0,9072.0,9073.75,150
      2020-02-02 22:57:00,9073.75,9073.75,9072.0,9073.0,53
      2020-02-02 22:58:00,9073.25,9073.25,9071.0,9072.0,62
      2020-02-02 22:59:00,9072.0,9072.0,9071.0,9071.5,50
      2020-02-02 23:00:00,9071.25,9074.0,9070.5,9071.25,119
      2020-02-02 23:01:00,9071.25,9072.0,9070.0,9071.5,94
      2020-02-02 23:02:00,9072.25,9079.0,9072.25,9077.25,434
      2020-02-02 23:03:00,9077.25,9077.75,9075.5,9075.5,149
      2020-02-02 23:04:00,9075.5,9079.5,9075.5,9078.5,168
      2020-02-02 23:05:00,9078.25,9078.75,9076.0,9077.0,229
      2020-02-02 23:06:00,9076.75,9078.75,9076.5,9078.0,84
      2020-02-02 23:07:00,9078.75,9079.0,9077.25,9078.5,59
      2020-02-02 23:08:00,9079.0,9079.0,9077.25,9078.5,103
      2020-02-02 23:09:00,9078.25,9078.25,9077.5,9078.0,37
      2020-02-02 23:10:00,9077.75,9077.75,9075.25,9075.5,162
      2020-02-02 23:11:00,9075.5,9079.25,9074.0,9078.75,523
      2020-02-02 23:12:00,9078.5,9078.75,9076.75,9078.0,153
      2020-02-02 23:13:00,9077.5,9079.5,9077.5,9079.0,70
      2020-02-02 23:14:00,9079.5,9080.75,9079.25,9079.25,151
      2020-02-02 23:15:00,9079.0,9080.5,9078.75,9080.0,50
      2020-02-02 23:16:00,9079.75,9084.5,9079.75,9083.75,348
      2020-02-02 23:17:00,9084.0,9084.25,9081.75,9083.25,199
      2020-02-02 23:18:00,9083.5,9084.5,9082.75,9083.25,119
      2020-02-02 23:19:00,9083.5,9083.5,9081.5,9081.75,76
      2020-02-02 23:20:00,9082.25,9085.75,9082.0,9084.75,164
      2020-02-02 23:21:00,9084.75,9086.5,9084.5,9086.25,138
      2020-02-02 23:22:00,9086.25,9087.75,9085.0,9087.5,185
      2020-02-02 23:23:00,9087.75,9088.0,9085.75,9086.0,152
      2020-02-02 23:24:00,9086.0,9086.75,9085.5,9086.75,139
      2020-02-02 23:25:00,9086.75,9087.75,9084.5,9086.0,138
      2020-02-02 23:26:00,9085.25,9086.0,9084.0,9084.25,81
      2020-02-02 23:27:00,9085.25,9085.25,9082.5,9083.0,97
      2020-02-02 23:28:00,9082.75,9083.0,9079.5,9081.25,322
      2020-02-02 23:29:00,9081.5,9084.5,9081.0,9084.25,131
      2020-02-02 23:30:00,9084.25,9087.25,9084.0,9086.0,172
      2020-02-02 23:31:00,9085.5,9085.5,9080.25,9080.5,249
      2020-02-02 23:32:00,9080.75,9082.5,9080.25,9082.5,136
      2020-02-02 23:33:00,9083.0,9083.0,9081.0,9082.0,79
      2020-02-02 23:34:00,9082.25,9085.25,9082.25,9082.25,90
      2020-02-02 23:35:00,9082.5,9083.25,9081.75,9082.0,76
      2020-02-02 23:36:00,9081.5,9081.75,9080.5,9081.5,96
      2020-02-02 23:37:00,9081.5,9083.25,9081.25,9082.75,99
      2020-02-02 23:38:00,9083.0,9085.0,9082.0,9085.0,118
      2020-02-02 23:39:00,9085.25,9085.25,9081.75,9083.75,144
      2020-02-02 23:40:00,9084.0,9085.0,9080.5,9082.0,140
      2020-02-02 23:41:00,9081.75,9082.25,9080.25,9081.75,86
      2020-02-02 23:42:00,9082.0,9082.0,9079.5,9080.25,146
      2020-02-02 23:43:00,9080.25,9080.75,9077.75,9079.5,181
      2020-02-02 23:44:00,9079.75,9081.25,9078.75,9080.5,164
      2020-02-02 23:45:00,9080.25,9080.5,9078.75,9079.75,82
      2020-02-02 23:46:00,9079.5,9080.25,9078.5,9079.5,94
      2020-02-02 23:47:00,9079.25,9079.25,9076.0,9076.75,297
      2020-02-02 23:48:00,9076.25,9076.5,9074.5,9075.0,340
      2020-02-02 23:49:00,9075.0,9075.25,9074.0,9074.5,158
      2020-02-02 23:50:00,9074.75,9076.25,9074.0,9075.0,152
      2020-02-02 23:51:00,9075.0,9075.0,9073.25,9074.5,91
      2020-02-02 23:52:00,9074.25,9075.5,9073.25,9074.25,158
      2020-02-02 23:53:00,9074.5,9077.0,9074.25,9075.75,395
      2020-02-02 23:54:00,9075.75,9077.5,9075.25,9077.5,149
      2020-02-02 23:55:00,9077.25,9078.75,9077.0,9078.5,107
      2020-02-02 23:56:00,9078.75,9080.5,9078.25,9079.75,76
      2020-02-02 23:57:00,9079.5,9082.25,9079.25,9082.0,191
      2020-02-02 23:58:00,9081.75,9082.75,9080.0,9081.0,114
      2020-02-02 23:59:00,9081.0,9081.5,9080.75,9081.25,57
      
      
      posted in General Code/Help
      J
      jesseliu0
    • How to disable plotting data?

      How can I disable plotting input data and only plot observers and analyzers? I tried this but it doesn't work. Thanks.

      data = PandasData(dataname=data_df, name=ticker, timeframe=bt.TimeFrame.Days)
      data.plotinfo.plot = False
      cerebro.adddata(data, name=ticker)
      
      posted in General Code/Help
      J
      jesseliu0
    • RE: How to get the next trading day's date?

      @backtrader said in How to get the next trading day's date?:

      That won't give you the next trading day. It only peeks into data (when preloaded) in the future, which is of course cheating and not portable to non-preloaded data. Be your own guest.

      Not peeking into data. Peeking into calendar on data.

      posted in General Code/Help
      J
      jesseliu0
    • RE: How to get the next trading day's date?

      @run-out
      Cool! Exactly what I want. Thank you so much.

      posted in General Code/Help
      J
      jesseliu0
    • RE: How to get the next trading day's date?

      I mean "the next trading day" according to the data line, which is a line of daily bars. For example, suppose 4/30/2018 is a trading-halt day and no data on that day, and then 4/27 should be the end of month, but calendar module thinks 4/30 is.

      Another use case is there may be data point missing on a particular day, say 4/30/2018, and then I want to use 4/27 as the end of month.

      It would be too much work to add every holiday or data-missing days to the calendar. So the goal is to get dates from data lines, whatever they are. Does there exist something like self.datetime can do that? Thanks.

      posted in General Code/Help
      J
      jesseliu0
    • How to get the next trading day's date?

      Hi,

      My strategy is supposed to deduct monthly broker fee at the end of month. I think it could be done by comparing next trading day's month number with today, but what's the proper way to get the next trading day's date? Or, is there a convenient way to determine month end or year end? Thanks.

      posted in General Code/Help
      J
      jesseliu0
    • RE: Bokeh Integration - Interactive Webbrowser Plotting

      @vbs Have you stopped developing backtrader_plotting? The interactive plots are very nice and helpful. Can you please fix the plotmaster issue? Thanks!

      posted in General Discussion
      J
      jesseliu0
    • RE: Please help to understand cash changes

      @backtrader said in Please help to understand cash changes:

      Which obviously has no times 10 (i.e.: the multiplier in the above calculation).

      In the first post, I put the code

      comm_rb = CommInfoFutures(commission=1e-4, margin=0.09, mult=10.0)
      

      I use 0.9 because 0.9 = 0.09 * 10.

      @backtrader said in Please help to understand cash changes:

      Cash remaining in your account after you enter the market: 20000000.00 - 2615 * 0.9 = 19997646.50
      Closing price: 2609
      Cash to be added to your account at the end of the day: (2615 - 2609) * 10 = 60.00
      Cash at the end of the day: 19997646.50 + 60.00 = 19997706.50.

      The margin cost at the end of day should be based on close price 2609 instead of the price when entering the market 2615, so cash at the end of day should be 20000000.00 - 2609 * 0.9 + 60, instead of 20000000.00 - 2615 * 0.9 + 60.

      About the value. My understanding is some money could move between margin cost and cash in the account, but the total account value should not be affected by margin cost. I think the account value at the end of day should be 20000000.00 + 60, instead of 20000000.00 + (2609 - 2615) * 0.9 + 60.

      Sorry if the calculations confused you. I don't think more code helps since the problem and reasoning are very simple. More code just bring more confuse.

      @backtrader said in Please help to understand cash changes:

      I would go into the market and buy 1-future of whatever and see how things work. Real life experience does really mean something.

      Yes I did.

      posted in General Code/Help
      J
      jesseliu0