COM Automation for ARMA

For questions regarding programming in the EViews programming language.

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

Rits
Posts: 6
Joined: Tue Jun 26, 2012 9:30 am

COM Automation for ARMA

Postby Rits » Tue Jun 26, 2012 10:00 am

I am using COM Automation to run EViews from C#. I got the point of being able to start and run EViews from C# and calculate ARMA forecasts and save in a CSV file. The problem occurs when I try to read the CSV file. At times (not always) the CSV would store an NA for the forecast even though the value exists in EViews workfile. Since it happens sporadically I am unable to pinpoint the issue. Below is the code I am using:


EViews.Manager mgr = new EViews.Manager();
app = mgr.GetApplication(EViews.CreateType.NewInstance);
app.Run("wfopen C:\\EViews7\\ES.wf1");
app.Run("smpl @all");
app.Run("series temp = @recode(chg<>na, @trend,na)+1");
app.Run("scalar last = @max(temp)");
app.Run("string lastdate = @otod(last)");
app.Run("smpl {lastdate}-5000 {lastdate}");
app.Run("LS CHG C MA(1) MA(2)");

app.Run("smpl {lastdate}+1 {lastdate}+1");
app.Run("FORCST YHAT");
app.Run("Genr Forcst = YHAT");
app.Run("Save C:\\EViews7\\ES.wf1");
app.Run("Output(v) C:\\Users\\Public\\ES1.csv");
app.Run("Print(p) FORCST");
app.Run("output off");
app.Run("close @all");
rngForecast.Value = helper.ReadForecast(b1.InstName); //Function to read last value of EViews output file into excel cell


What am I missing here? Any help is much appreciated!

Thanks!

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

Re: COM Automation for ARMA

Postby EViews Gareth » Tue Jun 26, 2012 10:06 am

Better off just using the wfsave command to create the CSV file, rather than messing around with output and print statements.

Rits
Posts: 6
Joined: Tue Jun 26, 2012 9:30 am

Re: COM Automation for ARMA

Postby Rits » Tue Jun 26, 2012 9:57 pm

Thanks for the response. So I tried using wfsave to create a csv. My best guess was this:

app.Run("wfsave (t=csv) C:\\Users\\Public\\ES1.csv @all @keep FORCST")

But clearly the problem here is how do I specify the workfile from which CSV will pull FORCST series data?

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

Re: COM Automation for ARMA

Postby EViews Gareth » Tue Jun 26, 2012 10:01 pm

I'm not sure I follow. WFSAVE saves the current workfile.

Rits
Posts: 6
Joined: Tue Jun 26, 2012 9:30 am

Re: COM Automation for ARMA

Postby Rits » Wed Jun 27, 2012 5:14 am

I thought we could specify the format for the file to be saved.
So since it cannot be done, my question is, what's the best way to copy/move certain series(or even just the most latest value) from the workfile and save it in a csv??
I need to do this programatically in COM Automation. Basically I want to be able to read the value of the FORCST series once the ARMA calculations are done.

Thanks...

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

Re: COM Automation for ARMA

Postby EViews Gareth » Wed Jun 27, 2012 7:48 am

I'm now totally confused.

You want to save a series from your workfile into a CSV file. This is done with the wfsave command. It is done exactly how showed with your best guess.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests