calculating returns of trading strategies

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

Laurel
Posts: 19
Joined: Mon May 04, 2020 2:39 pm

calculating returns of trading strategies

Postby Laurel » Mon May 04, 2020 4:39 pm

Hello! I have monthly pooled data for spot (s) and forward (f) exchange rates for ten countries and ten years. The forward rate is just the spot rate plus the interest rate differential. I would like to create a series of monthly excess returns = s(1)/f based on:

1. buying the currency with the maximum forward premium, max(f - s) and selling the one with the minimum forward premium, min(f – s), so the net return = rmax – rmin, and

2. buying the currency with the highest excess return in the previous period, max[s/f(-1)] and selling the one with the lowest excess return in the previous period, min [s/f(-1)].

What would be the best way to go about programming this? Thanks for your help!

Laurel
Posts: 19
Joined: Mon May 04, 2020 2:39 pm

Re: calculating returns of trading strategies

Postby Laurel » Wed May 06, 2020 2:15 pm

Let me rephrase the question. How do I generate a series from pooled data based on the maximum and minimum of some attribute in each time period?

For example, given monthly pooled data of 2 variables for 10 countries: a1, a2,...,a10 and b1, b2,..., b10. How do I command eviews to find for each month the countries with the biggest and smallest difference between a and b (a - b) and from them generate a series = a/b - a/b?

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

Re: calculating returns of trading strategies

Postby EViews Gareth » Wed May 06, 2020 2:35 pm

You lost me on the last bit, a/b-a/b = 0 ?

But, here's a rough idea that should work:

Code: Select all

'create some data and a pool wfcreate m 2000 2020 for !i=1 to 10 series a_{!i} = @nrnd series b_{!i} = @nrnd next pool p 1 2 3 4 5 6 7 8 9 10 'generate difference series p.genr dif_? = a_? - b_? 'group them group mydifs dif_? group as a* group bs b* 'create series containing the index of the minimum difference each month series mins = @rmini(mydifs) 'create a series with the ratio of a/b for the smallest difference each month series myratio = as(mins) / bs(mins)

Laurel
Posts: 19
Joined: Mon May 04, 2020 2:39 pm

Re: calculating returns of trading strategies

Postby Laurel » Wed May 06, 2020 2:42 pm

I meant a/b of the biggest (a - b) minus a/b of the smallest (a - b): a/b(max) - a/b(min). Thanks for the tip, I'll try it out!

Laurel
Posts: 19
Joined: Mon May 04, 2020 2:39 pm

Re: calculating returns of trading strategies

Postby Laurel » Sun May 10, 2020 7:53 pm

Thanks for the code, that was very helpful. Follow-up question:

What if given monthly pooled data of 2 variables for 10 countries: a1, a2,...,a10 and b1, b2,..., b10, I want eviews to find for each month the three countries with the three smallest difference between a and b (a - b) and from them generate a series = (ax*ay*az)/(bx*by*bz) where x, y, and z represent countries with the smallest, second smallest, and third smallest (a-b) respectively? How do I program this?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests