开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: Rolling futures to the next expiry


 

I have been looking into calendar spreads for a few weeks and it looks to me that what you experience is intended this way. By default and documented as such in the tool tips, TWS seems to
  • sort the legs in the order <earlier expiration>, <later expiration>. Meaning RTYU4-Z4? and RTYZ4-U4 both are treated as RTYU4-Z4 (and RTYH5-Z4 becomes RTYZ4-H5)
  • sells contracts for the future with the earlier expiration and buys the one with the later expiration

If you BUY 1 spread of RTYU4-Z4 you will get positions: -1 RTYU4 and +1 RTYZ4

If you SELL 1 spread of RTYU4-Z4 you will get positions: +1 RTYU4 and -1 RTYZ4

With the "Spread Trader" in TWS or via the API you can define this the other way around, but I got myself turned around a few time when buying and selling the various combinations. So I decided to stay with that "front -1, back +1" convention for my TWS API implementation calendar spread order placement.

闯ü谤驳别苍

?
On Mon, Jun 24, 2024 at 03:52 AM, Brian wrote:

Hi all,

I was trying to roll my future to the next expiry (RTY Sep, CME -> RTY Dec, CME) with a negative current position (RTY Sep, CME: -1) on TWS GUI, i.e.

from?

RTY Sep, CME: -1

RTY Dec, CME: 0

to

RTY Sep, CME: 0

RTY Dec, CME: -1


I'm also connecting to TWS through TWS API. However, when the callback function "openOrder" is called, i get the wrong action (BUY/SELL) for the respective orders.


Details:
637533627: RTY Sep, CME

654503362: RTY Dec, CME

contract.comboLegsDescrip: ?637533627|-1|CME,654503362|1|CME

Leg. conId: 637533627 action: SELL
Leg. conId: 654503362 action: BUY

To my best knowledge, isn't it supposed to be

contract.comboLegsDescrip: ?637533627|1|CME,654503362|-1|CME

Leg. conId: 637533627 action: BUY
Leg. conId: 654503362 action: SELL


However, in the end, i'm able to get the correct execution details:

637533627: BOT

654503362: SLD

So I was wondering if I misunderstood the definition, or could this be a bug from TWS?

Join [email protected] to automatically receive all group messages.