COM Automation for ARMA
Posted: 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.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!