lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


This is a stastical/backtest analysis application for the design of trading
systems. There are several statistical and financial functions bound by
GluaX.  Let me give you a typical script, so that you can get a feel for
what is being done.

---------------------------------------
function BacktestLogic()
  x20 = MovingAverage(20)
end
---------------------------------------
function BacktestSummaryInit()
  totalprofit = 0
end

-- I want to make definitions, such as the following, illegal within my
system;
-- All code needs to be contained within function definitions.
x = 5
---------------------------------------
function BacktestSummaryProcess()
  totalprofit = totalprofit + (exitprice - entryprice)
end
---------------------------------------

The application has a series of internal, predefined events. A list of
functions (e.g. BacktestLogic, BacktestSummaryInit, BacktestSummaryProcess)
and global values (e.g. x20) are presented to the end user.  Via an
interface, the user associates the 'BackTestSummaryInit' function to the
system event Backtest Summary Initialization and associates the
'BacktestSummaryProcess' function to the Backtest Processing event.  The
application now knows that when it comes time to generate the report, it
will execute the 'BacktestSummaryInit' for the report initialization event,
and 'BacktestSummaryProcess' for the generation of the report body.

What I am trying to disallow are definitions outside of function definitions
(e.g. the 'x = 5').   All logic needs to be contained within a function
definition before it can be mapped to an 'Event' within the application.  It
makes no sense for the user to define code outside of a function block, and
I am trying to find a way ignore it.

That is why I was seeking a means of loading all definitions and just being
selective on the logic I want to call.  If I could just load the above
definitions, I could perform a dostring() to execute the defined function
when the corresponding application event fires.

Jim

----- Original Message -----
From: "benjamin sunshine-hill" <bsunshin@usc.edu>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Wednesday, April 30, 2003 2:38 AM
Subject: Re: Load Compiled Script?


> > I think Curt is right.  Preappending a "do return end" will skip all of
my
> > function definitions.  Hmmm, so I guess I am back to my original
problem.
> > How do I load the compiled source and definitions without execution.
> >
> > I really appreciate everyone's help.
> >
> > Jim
>
> The problem is that The Lua Way to load in functions and definitions _is_
to execute them. Since a function doesn't have any "place" in a Lua state
unless it's referenced somewhere, there has to be code that puts it
there...so what you're asking is tantamount to "run parts of the code, but
not the other parts".
> What are you trying to do? why do you need this? I think some
clarification about your actual situation would really help us help you.
>
> Ben