How to get next expiration contact symbol

 

Hi, 

I want to implement an automated EA that do rollover contracts few fays before expiration, using symbol name and SYMBOL_EXPIRATION_TIME I know when i decide to rollover, the piece that i'm missing is how to "guess" what is the n next expiry contract name, let each hour I check if I enter to rollover windows that I decide (ex 5 days before expiry time), I close the current positions and orders  and I need to know what is the next expiry to the current contacts to re-open the orders/pos.

I can list the what is in the market watch window but I need a way to correlate the current/next contract, it could be done manually by filling a database using all contracts but it's not a very smart way to do it.

Any idea if the next contract can be simply retrieved on various futures (ES, CL, grain, ...)


Thanks

     

 
Any help ?
 
Raf #:
Any help ?
Since the names of the Symbols are more or less arbitrary picked by the broker, it's a fuzzy search.

You could maybe come up with some algo to do it. Parameters I would use for matching are: tick size, tick value, symbol description, trading and quote hours, margin parameters, contract size, calculation type, ...

Not all brokers will have overlapping contracts though.

It won't be a simple task, and the result might be faulty.

I guess a manual matching table is a better approach.
 
Dominik Egert #:
Since the names of the Symbols are more or less arbitrary picked by the broker, it's a fuzzy search.

You could maybe come up with some algo to do it. Parameters I would use for matching are: tick size, tick value, symbol description, trading and quote hours, margin parameters, contract size, calculation type, ...

Not all brokers will have overlapping contracts though.

It won't be a simple task, and the result might be faulty.

I guess a manual matching table is a better approach.

I doubt that the symbol's name are picked arbitrarily by a broker.

For sure it's different between brokers but for one broker it should not be a problem, I did it for AMP.

 
Raf:

Hi, 

I want to implement an automated EA that do rollover contracts few fays before expiration, using symbol name and SYMBOL_EXPIRATION_TIME I know when i decide to rollover, the piece that i'm missing is how to "guess" what is the n next expiry contract name, let each hour I check if I enter to rollover windows that I decide (ex 5 days before expiry time), I close the current positions and orders  and I need to know what is the next expiry to the current contacts to re-open the orders/pos.

I can list the what is in the market watch window but I need a way to correlate the current/next contract, it could be done manually by filling a database using all contracts but it's not a very smart way to do it.

Any idea if the next contract can be simply retrieved on various futures (ES, CL, grain, ...)


Thanks

     

What are the current symbols name you are using and what broker ?
 
Alain Verleyen #:

I doubt that the symbol's name are picked arbitrarily by a broker.

For sure it's different between brokers but for one broker it should not be a problem, I did it for AMP.

What I wanted to express was every broker has its own scheme on picking these names. That's why I stated "more or less arbitrary" and continued with "a fuzzy search" is required to do this.

Naming of symbols is not standardized in any way. The only standard that's somewhat applicable is ISO 4217, but that's just for currencies. And for stocks we have ISIN numbers, but there is no standard for Options or Futures or Commodities. - At least as far as I am aware.

So from this point of view, I stated it's more or less arbitrary.

CME, PMEX, IronBeam, and others, all use their own type of naming conventions. None of them have to stick to it, and it might change in the future. So it is to some extend "risky" to automate this process, as it can result in failed matchings.

I thought, I laid this issue out in a way, the OP is aware of this.
 
Dominik Egert #:
What I wanted to express was every broker has its own scheme on picking these names. That's why I stated "more or less arbitrary" and continued with "a fuzzy search" is required to do this.

Naming of symbols is not standardized in any way. The only standard that's somewhat applicable is ISO 4217, but that's just for currencies. And for stocks we have ISIN numbers, but there is no standard for Options or Futures or Commodities. - At least as far as I am aware.

So from this point of view, I stated it's more or less arbitrary.

CME, PMEX, IronBeam, and others, all use their own type of naming conventions. None of them have to stick to it, and it might change in the future. So it is to some extend "risky" to automate this process, as it can result in failed matchings.

I thought, I laid this issue out in a way, the OP is aware of this.
I implemented the manual solution that I described and it worked well, have à list of known symbole, put them in a lookup table in à file :bases name, all contracts ex (mnq,hmuv) when the rolling time is reached, I read the current symbol, extract the current month letter ex MCLEN24, extract N letter, read from config file all contracts for the basis instruments, iterate through them  to find the next letter representing the next expiration, reconstruct the next symbol (basis+new letter+year) and finally I roll the current  contract to the new one