continuous future contracts

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

d952
Posts: 64
Joined: Tue Nov 22, 2011 6:30 am

continuous future contracts

Postby d952 » Fri Dec 20, 2013 1:03 pm

Hi
my goal is to clear or adjust the continuous future contracts that I have. what I understood until now from reading references is that the usual approach is to "link prices" using either an additive or multiplicative price adjustment. I am using the Quandl continuous contracts database, Quandl's continuous contracts are created using the simplest possible roll algorithm: "end-to-end concatenation without any price adjustment, so I have to remove the price jump due to switching from the old to the new contract, And I can either adjust all the old prices to match the current true market price, or the current prices to match some point in the past. Now my question is that what is the Eviews command to perform this adjustment?
I appreciate alot if you guide me.
Thanks
Last edited by d952 on Fri Feb 14, 2014 2:08 am, edited 1 time in total.

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: Create continuous future contracts

Postby EViews Glenn » Tue Dec 31, 2013 9:55 am

If I'm understanding what you want to do, I don't think there is anything built-in. If you can give us a better idea of what you'd like to do at the seams, we can probably give you EViews commands to do the adjustment.

d952
Posts: 64
Joined: Tue Nov 22, 2011 6:30 am

Re: Create continuous future contracts

Postby d952 » Tue Dec 31, 2013 11:11 am

EViews Glenn wrote:If I'm understanding what you want to do, I don't think there is anything built-in. If you can give us a better idea of what you'd like to do at the seams, we can probably give you EViews commands to do the adjustment.


Thanks for your reply, I want to make 2 types of continuous contracts: 1. the first way is to make back-adjusting the price series: calculate the the difference of the closing price between the near and far contracts on each of the roll dates and obtain a scalar, and then multiple that scalar to the new contract prices, and generalize this to the whole series, 2. and the second way is to make a perpetual contract: which is a time-weighted average of the series.
I attache you here the continuous contract that I have and is not adjusted.
Thank you in advance
Niaz
Last edited by d952 on Fri Feb 14, 2014 2:07 am, edited 1 time in total.

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: Create continuous future contracts

Postby EViews Glenn » Tue Dec 31, 2013 12:48 pm

Sorry for the stupid question, but how do I know where the seams are?

d952
Posts: 64
Joined: Tue Nov 22, 2011 6:30 am

Re: Create continuous future contracts

Postby d952 » Tue Dec 31, 2013 1:27 pm

EViews Glenn wrote:Sorry for the stupid question, but how do I know where the seams are?


Im sorry I had to give information about roll-over dates, the problem is that there is not equal dates for contracts expirations, most of the months its 18th or 20th but some months are also 16th, 17th...I tried to attach the historical contracts in Eviews but it couldnt be upload so I attached it in Excel.
Thank you
Last edited by d952 on Fri Feb 14, 2014 2:07 am, edited 1 time in total.

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: Create continuous future contracts

Postby EViews Glenn » Tue Dec 31, 2013 2:27 pm

Thanks. I think you're still going to have to be more precise about what you want done.

Your spreadsheet has a set of overlapping series with names like PC_CLJ1984, PC_CLK1984, etc. I'm assuming that the expiration dates are where the series end. Can you describe what you want using names where appropriate?

d952
Posts: 64
Joined: Tue Nov 22, 2011 6:30 am

Re: Create continuous future contracts

Postby d952 » Tue Dec 31, 2013 2:49 pm

ok
Last edited by d952 on Fri Feb 14, 2014 2:09 am, edited 1 time in total.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13312
Joined: Tue Sep 16, 2008 5:38 pm

Re: Create continuous future contracts

Postby EViews Gareth » Tue Dec 31, 2013 2:51 pm

I think it is probably best if you explain what you are trying to do in terms of columns of data. EViews knows nothing about contracts. It knows nothing about Quandl. Nor do we.

See if you can explain what you want to achieve just in terms of an abstract data set.
Follow us on Twitter @IHSEViews

d952
Posts: 64
Joined: Tue Nov 22, 2011 6:30 am

Re: Create continuous future contracts

Postby d952 » Sat Jan 04, 2014 2:49 pm

EViews Gareth wrote:I think it is probably best if you explain what you are trying to do in terms of columns of data. EViews knows nothing about contracts. It knows nothing about Quandl. Nor do we.

See if you can explain what you want to achieve just in terms of an abstract data set.


It seems that I really made you confused, sorry.
Last edited by d952 on Fri Feb 14, 2014 2:10 am, edited 1 time in total.

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: Create continuous future contracts

Postby EViews Glenn » Mon Jan 06, 2014 12:58 pm

We're going to have to do this in pieces to make sure I understand what's going on. First concatenation. Are all of the contract ends on a given day of the week? That is, are the last seven days always the same number of observations? If so, it's a bit easier to splice.

d952
Posts: 64
Joined: Tue Nov 22, 2011 6:30 am

Re: Create continuous future contracts

Postby d952 » Tue Jan 07, 2014 2:09 am

EViews Glenn wrote:We're going to have to do this in pieces to make sure I understand what's going on. First concatenation. Are all of the contract ends on a given day of the week? That is, are the last seven days always the same number of observations? If so, it's a bit easier to splice.


I looked at data, what I undrestand is that the contracts dont end exactly in the same date, it varies between 16th to 19th, but the last seven days should be the same number of observation at the end of each series.

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: Create continuous future contracts

Postby EViews Glenn » Tue Jan 07, 2014 1:58 pm

Then the first thing we can do is the splice of the first two series

Code: Select all

series pc_merged = @recode(pc_clm1983(5)<>na, pc_clm1983, pc_cln1983)

will do the join 5 observations before the missings at the dates you mentioned. You can then recursively join things to this pc_merged series in the same fashion. I don't know the order of series names for which you wish to do this, but you can take the list of unique parts of the series names in the order you want to do the join and write a loop that will do so over the list.

For example, the recursive loop for the series you listed is

Code: Select all

series pc_merged = pc_clm1983
for %s CLM CLN CLQ
   %name = "PC_" + %s + "1983"
   pc_merged = @recode(pc_merged(5)<>na, pc_merged, {%name})
next

d952
Posts: 64
Joined: Tue Nov 22, 2011 6:30 am

Re: Create continuous future contracts

Postby d952 » Wed Jan 08, 2014 7:41 am

Thank you very much. as i choose the data set from 1984-2013, so I tried to modify it for the whole sample as bellow:
Last edited by d952 on Fri Feb 14, 2014 2:11 am, edited 1 time in total.

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: Create continuous future contracts

Postby EViews Glenn » Wed Jan 08, 2014 2:03 pm

When I run your program with the data I get a bunch of error messages. Do all of these series exist in the workfile?

Code: Select all

PC_CLU2004 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLU2004)".
PC_CLV2004 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLV2004)".
PC_CLX2004 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLX2004)".
PC_CLZ2004 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLZ2004)".
PC_CLF2005 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLF2005)".
PC_CLG2005 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLG2005)".
PC_CLH2005 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLH2005)".
PC_CLJ2005 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLJ2005)".
PC_CLK2005 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLK2005)".
PC_CLM2005 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLM2005)".
PC_CLN2005 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLN2005)".
PC_CLQ2005 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLQ2005)".
PC_CLU2005 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>NA, PC_MERGED, PC_CLU2005)".
PC_CLV2005 is not defined in "GENR PC_MERGED = @RECODE(PC_MERGED(5)<>

Note also that I can shorted your code to

Code: Select all

series pc_merged = pc_clf1984

for !j = 1984 to 1988
   for %s f g h j k m n q u v x z
      %name = "PC_CL" + @upper(%s) + @str(!j)
      pc_merged = @recode(pc_merged(5)<>na, pc_merged, {%name})
   next
next

d952
Posts: 64
Joined: Tue Nov 22, 2011 6:30 am

Re: Create continuous future contracts

Postby d952 » Fri Jan 10, 2014 5:16 am

Thank you very much, its working perfectly.
Last edited by d952 on Fri Feb 14, 2014 2:12 am, edited 2 times in total.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 17 guests