Inconsistent download_executions for BAG

Hi Brian, a paper trade returns 1 single IC with all contracts, but live trade returns N IC's based on how many contracts were executed. Here's a test for 3 contracts.
I.E. IC114 shows up 3 times instead of 1 BAG with 3 contracts.

f = io.StringIO()
download_executions(
    f,
    order_refs=[strategy],
    start_date=today
    )
df = pd.read_csv(f)
# paper trade dataframe
paper = df[df["OrderId"] == '6001:242']

                    ExecId   OrderId Account     OrderRef          Sid  \
0  00020057.68f02559.05.01  6001:242   paper  my_strategy  IB814612236   
1  00020057.68f02559.04.01  6001:242   paper  my_strategy  IB814612257   
2  00020057.68f02559.03.01  6001:242   paper  my_strategy  IB817751331   
3  00020057.68f02559.02.01  6001:242   paper  my_strategy  IB817751375   
4  00020057.68f02559.01.01  6001:242   paper  my_strategy        IC113   

  Exchange  Price Side  Quantity  Commission ComboType  Liquidation  \
0     CBOE   10.1  SLD        -3      3.8652       LEG            0   
1     CBOE    5.9  BOT         3      3.8652       LEG            0   
2     CBOE    7.2  BOT         3      3.8652       LEG            0   
3     CBOE   10.5  SLD        -3      3.8652       LEG            0   
4     CBOE   -7.5  BOT         3      0.0000       BAG            0   

   LastLiquidity                                             Symbol Currency  \
0              1                              SPXW  251015C06660000      USD   
1              1                              SPXW  251015C06670000      USD   
2              1                              SPXW  251015P06645000      USD   
3              1                              SPXW  251015P06655000      USD   
4              1  SPXW  251015P06645000,SPXW  251015P06655000,SP...      USD   

  SecType  PriceMagnifier  Multiplier BaseCurrency  Rate  GrossProceeds  \
0     OPT               1         100          USD     1         3030.0   
1     OPT               1         100          USD     1        -1770.0   
2     OPT               1         100          USD     1        -2160.0   
3     OPT               1         100          USD     1         3150.0   
4     BAG               1         100          USD     1         2250.0   

    Proceeds  ProceedsInBaseCurrency  CommissionInBaseCurrency  
0  3026.1348               3026.1348                    3.8652  
1 -1773.8652              -1773.8652                    3.8652  
2 -2163.8652              -2163.8652                    3.8652  
3  3146.1348               3146.1348                    3.8652  
4  2250.0000               2250.0000                    0.0000 

# live trade dataframe
live = df[df["OrderId"] == '6001:243']
                     ExecId   OrderId Account     OrderRef          Sid  \
0   0000fb35.68f61094.05.01  6001:243    live  my_strategy  IB813616388   
1   0000fb35.68f61095.05.01  6001:243    live  my_strategy  IB813616388   
2   0000fb35.68f61096.05.01  6001:243    live  my_strategy  IB813616388   
3   0000fb35.68f61094.04.01  6001:243    live  my_strategy  IB817019858   
4   0000fb35.68f61095.04.01  6001:243    live  my_strategy  IB817019858   
5   0000fb35.68f61096.04.01  6001:243    live  my_strategy  IB817019858   
6   0000fb35.68f61094.03.01  6001:243    live  my_strategy  IB819203639   
7   0000fb35.68f61095.03.01  6001:243    live  my_strategy  IB819203639   
8   0000fb35.68f61096.03.01  6001:243    live  my_strategy  IB819203639   
9   0000fb35.68f61094.02.01  6001:243    live  my_strategy  IB819203653   
10  0000fb35.68f61095.02.01  6001:243    live  my_strategy  IB819203653   
11  0000fb35.68f61096.02.01  6001:243    live  my_strategy  IB819203653   
12  0000fb35.68f61094.01.01  6001:243    live  my_strategy        IC114   
13  0000fb35.68f61095.01.01  6001:243    live  my_strategy        IC114   
14  0000fb35.68f61096.01.01  6001:243    live  my_strategy        IC114   

   Exchange  Price Side  Quantity  Commission ComboType  Liquidation  \
0      CBOE   1.39  SLD        -1      1.7384       LEG            0   
1      CBOE   1.39  SLD        -1      1.0384       LEG            0   
2      CBOE   1.39  SLD        -1      1.3884       LEG            0   
3      CBOE   0.42  BOT         1      1.6484       LEG            0   
4      CBOE   0.42  BOT         1      0.9484       LEG            0   
5      CBOE   0.42  BOT         1      1.2984       LEG            0   
6      CBOE   2.88  BOT         1      1.7384       LEG            0   
7      CBOE   2.88  BOT         1      1.0384       LEG            0   
8      CBOE   2.88  BOT         1      1.3884       LEG            0   
9      CBOE   7.16  SLD        -1      1.7384       LEG            0   
10     CBOE   7.16  SLD        -1      1.0384       LEG            0   
11     CBOE   7.16  SLD        -1      1.3884       LEG            0   
12     CBOE  -5.25  BOT         1      0.0000       BAG            0   
13     CBOE  -5.25  BOT         1      0.0000       BAG            0   
14     CBOE  -5.25  BOT         1      0.0000       BAG            0   

    LastLiquidity                                             Symbol Currency  \
0               2                              SPXW  251020C06750000      USD   
1               2                              SPXW  251020C06750000      USD   
2               2                              SPXW  251020C06750000      USD   
3               2                              SPXW  251020C06760000      USD   
4               2                              SPXW  251020C06760000      USD   
5               2                              SPXW  251020C06760000      USD   
6               2                              SPXW  251020P06735000      USD   
7               2                              SPXW  251020P06735000      USD   
8               2                              SPXW  251020P06735000      USD   
9               2                              SPXW  251020P06745000      USD   
10              2                              SPXW  251020P06745000      USD   
11              2                              SPXW  251020P06745000      USD   
12              1  SPXW  251020P06735000,SPXW  251020P06745000,SP...      USD   
13              1  SPXW  251020P06735000,SPXW  251020P06745000,SP...      USD   
14              1  SPXW  251020P06735000,SPXW  251020P06745000,SP...      USD   

   SecType  PriceMagnifier  Multiplier BaseCurrency  Rate  GrossProceeds  \
0      OPT               1         100          USD     1          139.0   
1      OPT               1         100          USD     1          139.0   
2      OPT               1         100          USD     1          139.0   
3      OPT               1         100          USD     1          -42.0   
4      OPT               1         100          USD     1          -42.0   
5      OPT               1         100          USD     1          -42.0   
6      OPT               1         100          USD     1         -288.0   
7      OPT               1         100          USD     1         -288.0   
8      OPT               1         100          USD     1         -288.0   
9      OPT               1         100          USD     1          716.0   
10     OPT               1         100          USD     1          716.0   
11     OPT               1         100          USD     1          716.0   
12     BAG               1         100          USD     1          525.0   
13     BAG               1         100          USD     1          525.0   
14     BAG               1         100          USD     1          525.0   

    Proceeds  ProceedsInBaseCurrency  CommissionInBaseCurrency  
0   137.2616                137.2616                    1.7384  
1   137.9616                137.9616                    1.0384  
2   137.6116                137.6116                    1.3884  
3   -43.6484                -43.6484                    1.6484  
4   -42.9484                -42.9484                    0.9484  
5   -43.2984                -43.2984                    1.2984  
6  -289.7384               -289.7384                    1.7384  
7  -289.0384               -289.0384                    1.0384  
8  -289.3884               -289.3884                    1.3884  
9   714.2616                714.2616                    1.7384  
10  714.9616                714.9616                    1.0384  
11  714.6116                714.6116                    1.3884  
12  525.0000                525.0000                    0.0000  
13  525.0000                525.0000                    0.0000  
14  525.0000                525.0000                    0.0000

QuantRocket doesn't handle paper and live differently, so if there is a difference in the executions, I think it must either be a subtle difference in the order itself, or a difference in what IBKR sends back. Your live and paper BAG orders look quite different; try sending an identical order for both and see what comes back. Also, try sending a simpler BAG (2 legs), for easier troubleshooting. If you send the same simple BAG and get different live vs paper results, try opening the IB Gateway GUI and look at the executions messages coming back on client 6000 to see if IBKR is sending something different. QuantRocket's BAG support is tested against paper trading, with an expectation that IBKR will treat live the same as paper.

Hi Brian, thanks. I will try the recommended suggestions and circle back.
I did want to let you know that yes the order (SIDS) look different but the only difference was day. Pipeline didn't move at all.
The only difference was swapping ACCOUNT env var from paper to live. Nothing else changed.

I suspected it was IBKR returning a different response. I can write a script to handle the differences if this is the case, but my only initial worry was if N becomes larger and how other backend QR functions handle seeing many different IC114's. Will circle back with findings.