`
`eescene sheen
`
`Remi neethy tment9chnasaegmSeePanneInmincetAheeRAten urehetiemee te
`
`
`
`VOLUME2
`eebaideserenemeeeinaadantemheanehaatemtemtemsteneeeeeeereree
`
`NUMBER 6 © 1992
`
`(cid:6)(cid:8)(cid:7)(cid:4)(cid:1)(cid:2)(cid:3)(cid:5)(cid:10)(cid:11)(cid:9)(cid:12)
`ISSNLAF band
`1210-0582
`J
`eeeReneennBHANEOIRAPEenAeyAt etteA
`
`Paternational Journal an Neural and Mass~Parallel
`Camputing and liforma
`
`tion Systems
`
`didttor:
`
`Ad. Nowak
`
`VSP
`
`vod
`
`| oy fcmy
`GAIN CAPITAL- EXHIBIT 1031 oe
`
`GAIN CAPITAL - EXHIBIT 1031
`
`
`
`
`
`REAL-TIME TRADING MODELS
`
`FOR FOREIGN EXCHANGE RATES
`
`O.V. Pictet, M.M. Dacorogna, U.A, Miller, R.B. Olsen, J.R. Ward!
`
`
`
`Abstract: A set of real-time trading models offering analysis of foreign ex-
`change (FX) rate movements and providing explicit trading recommendations
`is presented. These models are based on the continuous collection and treat-
`ment of FX quotes from market makers operating around the clock, These
`data are processed by a distributed system of computers performing the tasks
`of data collection, data validation, indicator computation, rule-based analy-
`sis, communication and display generation. The out-of-sample performance
`of these models is typically close to 18% return per year with unleveraged
`positions and excluding any interest gains. Diversifying the exposure through
`a portfolio of currencies reduces the risk of using such modelsfor real trading.
`With a portfolio of three equally weighted FX rates the maximum drawdown
`is reduced from an average of 9% to 5% for a single trading model while
`keeping the annual return practically unchanged.
`
`Key words: Traiding models, exchange rates
`
`Received: September 80, 1992
`Accepted: October 20, 1992
`
`1. Introduction
`
`A prudent speculator believes he knows how prices will evolve. However,
`many market-makers also believe that markets are inherently efficient and
`hence that prices cannot be forecast. Although these are interesting questions,
`the purpose of this paper is not to discuss market efficiency. Rather, we wish
`to show that with a reasoned approach and high-quality data, it is possible to
`design practical and profitable trading models. Indeed, we have developed our
`own trading models which we present here. These anticipate price movements
`in the foreign exchange (FX) market sufficiently well to be profitable in the
`long term yet with acceptable risk behavior.
`
`10.V. Pictet, M.M. Dacorogna, U.A. Miiller, R.B. Olsen, J.R. Ward
`Olsen & Associates, Research Institute for Applied Economics, Seefeldstrasse 233,
`8008 Ziirich, Switzerland
`
`@IDG VSP 1992
`
`
`
`713
`
`
`
`Neural Network World 6/92, 713-744
`
`A clear distinction should be made between a price change forecast and
`an actual trading recommendation. A trading recommendation naturally in-
`chides some kind of price change forecast, but must also account for the spe-
`cific risk profile of the dealer or user of therespective trading model. Another
`distinction is that a trading model must take into account its past trading
`history while a price forecast is not biased by a position the trading model
`might be in. A trading model thus goes beyond predicting a price change: it
`must decide if a certain action has to be taken. This decision is subject to
`the specific risk profile, the trading history andinstitutional constraints such
`as business hours. This paper shows how these different parameters can be
`integrated into the decision-making process and how theyare important for
`constructing practical models for professional traders.
`Our trading models offer real-time analysis of FX-rate movements and
`generate explicit trading recommendations. These models are based on the
`continuous collection and treatment of FX quotes by market makers around
`the clock (up to 5000 non-equally spaced prices per day for the German mark
`agains the US dollar).
`Our models follow the FX market and imitate it as closely as possible.
`They do not deal directly but instead instruct human FX dealers to make
`specific trades.
`In order to imitate real-world trading accurately,
`they take
`into account transaction costs in their return computation, generally avoid
`trading outside market working hours and avoid trading too rapidly. In short,
`these models act realistically in a manner that a human dealer can easily
`follow.
`In the next section, the FX market is described together with the data
`that we collect and the actual implementation of the models in our real-time
`information system.
`In section 3 we present how a model, given a set of
`indicators, makes its decisions and what the rules governing these decisions
`are. The system architecture and the specially developed computer language
`forming the basis of the trading model implementation are also explained
`here. Section 4 describes the indicators used by the model to Getermine in
`which direction prices are heading, In section 5 we discuss the optimization
`procedure and introduce a new performance measure that includes a risk
`component. We analyze the model performance in section 6 by considering
`various risk measures such as the maximum drawdown or the profit over loss
`ratio and discuss the distinction between in and out-of-sample data.
`In the
`same section we also compare the results obtained with our model to a simple
`20 days moving average model and show the importanceof taking into account
`not only the total return but also the risk behavior of the model. Moreover, we
`show that the risk associated with these models can be considerably reduced
`by splitting the capital among a portfolio of currencies. Our conclusions are
`presented in section 7,
`
`714
`
`
`
`Pictet: Real-Time Trading Models
`
`~ and Processing Environment
`
`.cbange rate is the price at which one national currency can be ex-
`-or another, The most common currency value notion is the bilateral
`pate (or simply the FX rate) quoted by a FX trader or reported by
`endor. This is a nominal exchange rate because it is the number of
`_ currency offered in exchange for one unit of another. For example,
`an marks for 1 US dollar. The spot exchange rate is a particular ex-
`a nominal bilateral exchange rate where the transaction takes place
`ely. Another example is the forward exchange rate where the price
`now but the transaction takes place in the future. In this paper we
`only deals with spot exchange rates.
`yw describe how the FX market operates, what are the data wecollect
`awe process them.
`
`2 FX market and the data sources
`
`price is composed of two quantities: a price for the bid offer (termed
`rice) and a price for the ask offer (the ask price). The bid and ask
`siajor financial institutions are conveyed to dealers’ screens by quote
`such as Reuters, Telerate or Knight Ridder. Deals are negotiated
`zone. The FX market operates globally and around the clock. Any
`szaker may submit new bid/ask prices at any time and many larger
`mis have branches worldwide so that they can partake in continuous
`rig.
`ting the real world requires a system that collects all available price
`md that reacts in real-time to price movements. For our trading
`ye have used mainly Reuters data but other data suppliers provide
`4formation in their FX quotes. Using software developed in-house,
`t&, validate and store price quotes in our database for future use. Each
`’
`tick in the database contains the following items:
`
`time t; in GMT® (Greenwich Mean Time) at which this price has
`:¥i recorded in our database,
`
`bid price pes,
`ask price pi,
`name of the bank which issued theprice,
`
`location of the particular bank,
`
`1 the result of our validation filter.
`
`ricex j identifies individual database records. Reuters pages provide
`‘Tice p}" as a complete number, usually with five digits; peek is given
`
`715
`
`
`
`Neural Network World 6/92, 713-744
`
`with only the last two digits and is recomputed in full by our software. The
`granularity of the time steps ¢; is 2 seconds. The validation filter information
`ig computed by thefiltering algorithm described in [1].
`The tick frequency has varied since the beginning of our data collection.
`Currently the tick frequency for the USD/DEM is approximately 5000 ticks
`per business day, approximately 3000 ticks per day for the other major rates
`(USD/JPY, USD/CHF and GBP/USD)and around 1500 ticks per day for the
`minor rates (USD/FRF, USD/NLG and USD/ITL). Altogether, our database
`presently contains more than 12 million ticks for each of these rates.
`
`2.2. Trading hours and market holidays
`
`Although the FX market operates continuously, individual traders or in-
`stitutions generally partake of this market only for a portion of each day. Our
`models accommodate such users by incorporating the notion of business hours
`and holidays.
`Every trading model is associated with a local market that is identified
`with a corresponding geographical region.
`In turn,
`this is associated with
`generally accepted office hours and public vacation days. The local market
`is defined to be open at any time during office hours provided it is neither
`a weekend nor a public holiday. Our trading models presently support the
`Zurich, London and Frankfurt markets and it is straightforward to extend
`this set. Typical opening hours for a model are between 8:00 and 17:30 local
`time, the exact times depending on the particular local market.
`Except for closing an open position if the price hits a stop loss limit (de-
`serie in section 3.4), a model may not deal ? outside opening hours or during
`
`olidays.
`
`2.3. System overview
`
`the Olsen Information System (OIS), performs all actions
`Our system,
`required to operate a set of real-time trading models. These include data
`collection, data validation, generation of trading recommendations, commu-
`mecation of these recommendations to uset-agents residing at our customers
`and graphical presentation of these on the user-agents. Fig. 1 provides an
`example of how a trading model looks on a customer’s user-agent.
`The mostsignificant item displayed on a user-agent is the model’s present
`position or trading recommendation. The O&A trading models currently
`make gearing recommendations of 5—1.0, 5—0.5 (short positions), 0 (neutral),
`
`2
`
`.
`
`but in this nee We speak of a trading model “dealing” or “entering a new position”
`human denierc.eee our trading models do not deal directly but instead recommend a
`o make trades, In our pursuit of realism, however, we consider the decision-
`ming process of our models to be just as valid as any made by a “real-life” dealer. In
`* respect we are deliberately loose in our phraseology,
`
`716
`
`
`
`Pictet: Real-Time Trading Models
`
`Fig. 1 A trading model history page. The top section shows the position in
`which the trading model presently finds itself. The current (most recent) price
`is also shown here as is a percentage figure indicating the performance since
`the last deal (current return). The middle section shows a lisi of previous
`deals which may be scrolled up or down. The bottom section gives statistics
`collected since the trading model was started,
`
`717
`
`
`
`Neural Network World 6/82, 713-744
`
`L+0.5 and L+1.0 (long positions). For example, a gearing of S—0.5 means
`“go short with half the available capital”.
`
`2.4, Distributed architecture
`
`The OIS is not constructed as a single huge program with all the required
`functionality residing in that one entity. Rather it is constructed as a col-
`lection of separate programs, In computer-speak, the system is said to be a
`distributed system because the various programs run in parallel on several
`computers.
`|
`|
`Each such program performs one logical operation. For instance, a pro-
`pram termed the GTrader takes in collected and validated price data and
`uses this data to produce trading model recommendations. (Several trading
`models may reside independently of one another within one GTrader invoca-
`tion). Other programs in the system include a price collector for receiving
`data from the quote-vendors and a price database manager for storing this
`data for future use. Splitting up the system into several logical components
`confers several benefits :
`
`e A failure in one program is localized and does not affect other programs
`in the system. This increases the overall reliability. For example, if a
`GTrader program should crash — hopefully, a rare occurrence but one
`which may happen as a result of hardware failure — collection of raw
`price data remains unimpaired.
`
`¢ if a computer should fail, the programs running on that computer may
`be transferred to another machine. Again, this promotes reliability.
`
`e The performance of the system may be enhanced by adding extra hard-
`ware and moving some existing programs on to the new hardware.
`
`e Having separate programs perform logically distinct operations helps
`simplify the design and structure of the system. The modularity of the
`implementation is vouchsafed.
`.
`
`*
`
`3. The Decision Process of the O&A Trading Models
`3.1. Overview of the trading model implementation
`
`The overall structure and data-flow of an O&A trading model is depicted
`in Fig, 2,
`Indicator computations form a central part of an O&A trading model
`providing an analysis of past price movements.
`(A detailed analysis of the
`indicators is given in section 4). These indicators are mapped into actual
`
`718
`
`
`
`Pictet: Real-Time Trading Models
`
`Taw price data
`
`Price Collector
`
`prices
`
`fo
`
`Price Filter | Price Database
`
`deal recommendations
`
`
`
`
`
`ey meneame ame metereeevousesrarerueihdRALANLYetreeonesemisasheinsteinmrs
`
`
`
`
`filtered prices |
`
`
`
`Gearing Calculator
`Stop-loss Detector
`
`
`
`Deal Acceptor
`
`deal recommendations \
`
`Opportunity Catcher
`
`simulated deals
`
`Book-keeper
`
`O&A Headquarters
`
`Fig. 2. Data flow of prices and deal recommendations within a trading
`model
`
`719
`
`
`
`Neural Network World 6/92, 713-744
`
`i
`
`detail in section 3.2,
`
`i
`
`trading positions by applying various rules. For instance, 4 Sea enter
`a long position if an indicator exces’ a certain threshold.
`Such
`rule
`mare walesdetermine whether a deal may be made at all. Among various
`factors, these rules take the timing of the recommendation into consideration.
`Such authorization rules are discussed in section 3.3.
`A complete trading model thus consists of a set of indicator computations
`combined with a collection of rules. The former are functions of the price
`history. The latter determine the applicability of the indicator computations
`in generating trading recommendations,
`
`3.2. The gearing calculators
`A gearing calculator lies at the heart of an OLA trading model. The
`gearing calculator provides the trading model with its intelligence and the
`ability to capitalize on movements in the FX markets. The gearing calculator
`also provides the trading model with particular properties, These include the
`frequency of dealing and the circumstances under which positions may be
`entered.
`In other words, the gearing calculator is the real model. In contrast, the
`other trading model components form a shel! around the gearing calculator,
`providing it with price data, detecting if the stop-Joss is hit and examining
`the trading recommendations made by the gearing calculator, The gearing
`calculator reevaluates its position every time a new price datum is received
`from the quote-vendors.
`(As previously noted, a filter validates each price
`beforehand in order to eliminate outlyers and other implausible data).
`The gearing calculator employs two kinds of software ingredients: a set of
`indicators which are produced from the input price data (discussed in detail
`in section 4) and trading rules which are functions of the past dealing history,
`the current position and other quantities such as the current unrealized return
`of an open position.
`As the name suggests, an indicator provides a measure of whether a new
`position should be entered, These indicators are analyzed by the rules inside
`the gearing calculator to determine whether such a change of position should
`in fact take place.
`In the simplest form, an indicator crossing a predefined
`threshold may cause a rule to be activated that in turn causes such a change
`in position to occur. Thus the relative values of the indicators signify internal
`trading recommendations which are then refined through the application of
`various rules. Other, more complicated rules may modify the indicators’ basic
`recommendations in additional ways:
`
`1. By inhibiting a recommendation produced by the indicators. For exam-
`ple, if the price movements since the previous deal are too small in either
`direction, an indicator recommendation to reverse the present gearing
`is suppressed,
`
`720
`
`
`
`Pictet: Real-Time Trading Models
`
`2. By changing the indicator thresholds themselves. While the model is in
`a neutral position, such a rule may increase the threshold valnes.
`
`3. By choosing an opposite position to the one hinted at by the indicators,
`That is, by entering a “contrarian” position.
`(A contrarian positionis
`long when prices are declining or short when prices are climbing).
`
`4. By imposing new stop-loss values. A smaller stop-loss may be estab-
`lished if the recommended position is contrarian. The stop-loss is re-
`duced because a contrarian strategy is considered risky.
`
`The relative values of the indicators determine the gearing that should
`be used. That is, not only do the indicators determine the position to be
`entered (after subsequent transformation by the rules), they also determine
`the magnitude of the gearing to be used. As stated previously,
`the O&A
`models employ half-integral gearings in the range —1.0 to 1.0.
`The other trading model components surrounding the gearing calculator
`do so through a standardized interface. We are therefore able to “drop” new-
`ly developed gearing calculators into the trading model environment. At the
`time of writing, we have produced three separate gearing calculators (desig-
`nated classes 40, 50 and 60) each working with seven currencies (USD/DEM,
`USD/CHF, GBP/USD, USD/IPY, USD/ITL, USD/FRF and USD/NLG),
`These gearing calculators differ in their respective trading frequencies, risk
`profiles and other properties. Developing a new gearing calculator is thus
`akin to developing a new trading class while preserving the overall trading
`model structure. This allows us straightforwardly to customize existing gear-
`ing calculators or to experiment with new ones.
`
`3.3. The deal acceptor
`
`The fact that the gearing calculator’s indicators and rules suggest entering
`a new position does not necessarily mean that the model will make such a
`recommendation. Whether it does or not depends on various secondaryrules
`that then take effect.
`These rules comprise the deal acceptor. This determines whether the deal
`proposed by the indicators is allowed to be made, The prime constraint is the
`timing of the proposed deal. First, no deal other than a stop-loss deal (see
`section 3.4.) may take place within fifteen minutes of a deal already having
`occurred. This is to prevent overloading a human dealer who may be following
`the models. Second, the gearing calculator may make a recommendation to
`enter a new trading position but this recommendation can be followedonlyif
`the local market is open.
`The quality of the most recent price imposes another constraint. A strin-
`gent deal-filter determines if a given price is suitable for dealing. This is so
`that we can be sure that recommended deals are made only with genuine
`
`721
`
`
`
`Neural Network World 6/92, 713-744
`
`prices rather than extraneous data. The deal acceptor permits a new deal
`only with a price passing the deal-filter.
`If the gearing calculator suggests entering a new position but the deal
`acceptor decrees otherwise, the suggestion is simply ignored, Eventually, when
`timing and other factors are right, the gearing calculator will suggest entering
`a new position and the deal acceptor will approve.
`
`3.4. Stop-loss detection
`
`Besides being passed on to the gearing calculator, the filtered price quotes
`are also sent to the stop-loss detector.
`‘The stop-loss detector triggers if the market moves in the “wrong” direc-
`tion, ‘Thatis, if the model enters a trading position because it anticipates the
`market to move in a certain direction but in fact the market then moves the
`other way, the stop-loss may be hit.
`The trading model defines a stop-loss price when a position is entered. If
`the current price —— that is, the most recent price — moves below the stop-loss
`price (for a long position) or above the stop-loss price (for a short position),
`the stop-loss is said to be hit. Hitting the stop-loss causes a deal to a neutral
`position to be made. Ineffect, the stop-loss prevents excessive loss of capital
`should the market go the wrong way.
`‘The stop-loss price may change when a new position is entered or as the
`current price changes (see section 3.5.}. The current stop-loss price is dis-
`played on the user-agent.
`A stop-loss deal may occur at any time, even outside market hours. The
`assumption is that a position that is kept open outside market hours is handled
`by a colleague in the American or Far East markets who will deal appropriately
`if the stop-loss is hit. Should this happen, no further change in position occurs
`until the local market opens once again.
`
`3.5. Stop-profit
`
`‘The concept of stop-profit is associated with that of stop-loss. The stop-
`loss price starts fo move in parallel with the current price once a trading model
`hasachieved a potential profit (3% or slightly less) since entering the latest
`position, In other words, being in a situation whereby the model could realize
`such a gain by immediately entering a neutral position causes the stop-loss
`Aee ‘o start moving. The difference between the stop-loss and current. prices
`thatmentee as long as the current price continues moving in a direction
`vice ees - he potential profit of the open position. That is, the stop-loss
`einne Ta < ‘ in parallel with the current price. The stop price is
`alee hat only curing opening hours.
`It is never adjusted when the
`;
`ition
`i
`he model then enters a neutral position if it detects prices slipping back-
`
`Tl
`
`722
`
`
`
`Pictet: Real-Time Trading Models
`
`wards. This allows a model to save any profit it has generated rather than
`lose it when the market abruptly turns. This one-directional movementof the
`stop-loss price allows the model to capitalize on a price trend.
`
`3.6. The opportunity catcher
`
`The trading model may thus make a deal recommendation in two distinct
`ways. One, the gearing calculator may make a recommendation that is then
`authorized by the deal acceptor. Two, hitting the stop-loss price activates the
`stop-loss detector.
`Whichever way a deal comes about, the opportunity catcher is activated.
`The opportunity catcher manifests itself on the user-agent as an eye-catching
`signal for the FX dealer to buy or sell according to the recommendation.
`Whilehe is actively dealing, the opportunity catcher in the trading model
`collects the best price with which to deal, either the highest bid price if going
`from a longer position to a shorter one or the lowest ask price if going from a
`shorter position to a longer one. This search for the best price lasts for two or
`three minutes depending on the currency, the assumption being that a quoted
`price has a life-time of about two or three minutes even if it is superseded by
`later quotes.
`After the two or three minute search period, a second signal appears on the
`user-agent signifying that the trading model has made a simulated deal using
`the best price found by the opportunity catcher, The FX dealer then concludes
`his deal-making activities and waits until the trading model produces another
`recommendation.
`(As a point of detail, the opportunity catcher is not activated for a stop-
`loss deal occurring outside market hours. In this case the trading model deals
`directly. A human trader following the madel should then make a correspond-
`ing deal for himself as quickly as possible.)
`
`3.7. The book-keeper
`
`The book-keeper makes simulated deals on behalf of the trading model. It
`keeps track of all deals that have been made and evaluates statistics demon-
`strating the performance of the trading model.
`An important variable is the average price B paid for achieving the current
`gearing. After a new deal with index 1, this quantity depends on the type of
`transaction as follows:
`.
`
`723
`
`
`
`Neural Network World 6/92, 713-744
`
`Pie
`
`~~
`
`ae a + gat
`
`ti
`
`if
`
`‘
`
`if
`
`—]
`
`|gi]< oral A gege—1 > 0
`
`foe] > |ge-a] A gigi-1 > 0
`
`Pr
`
`if gigi-1 <0 V gr-p =0
`
`undefined
`
`if g:=0
`
`where g;.; and g; are the previous and current gearings respectively, p; is the
`current transaction price, and #,_, the average price before the deal. In the
`initial case, when the current gearing is neutral, the average price p is not yet
`defined,
`‘The average price B is needed to compute a quantity central to a trading
`model, the return of a deal:
`
`rr = (1-1 - )(— - 1)
`
`(3.2)
`
`Py}
`those starting from a neutral gearing,
`There are deals with no returns:
`gr-1 = 0, and those increasing the absolute value of the gearing while keeping
`its sign. In these cases, eq. 3.2 does not apply (whereas eq. 3.1 applies to all
`deals).
`Both above equations allow the computation of a set of other quantities
`that are important for the different trading rules and for the performance
`evaluation of the models and which are computed in the book-keeper. These
`are the following:
`
`e the current-return r,. This is the unrealized return of a transaction
`when the current position is off the equilibrium (g; 4 0).
`If pe is the
`current market price required for going back to neutral, generalizing
`eq. 3.2 yields the current-return,
`
`—
`
`Pp
`
`2
`
`Py
`@ the marimum return when open is the maximum value of r, from 4
`transaction ¢ to a transaction ¢-+ 1 reached during opening hours,
`ie minimum return when open is the minimum value of r, from a
`1919
`:
`ao.
`Tangaction ¢ to a transaction {+ 1 reached during opening hours,
`* the fotal return is a measure of the overall success of a trading model
`over a period T and is simply equal to,
`
`ta]
`
`Rr = >>;
`
`f=1
`
`(3.4)
`
`724
`
`
`
`Pictet: Real-Time Trading Models
`
`where n is the total number of transactions that generated a return
`during the period T. The total return expresses the amount of gains
`made by a trader who would always invest up to his initial capital or
`credit limit in his home currency.
`
`e the cumulated return is another measure of the overall success of a trad-
`ing model wherein the trader always reinvests up to his current capital
`including gains or losses,
`
`Cr = [la + r%;) —1
`
`i=l
`
`(3.5)
`
`This quantity is slightly more erratic than the total return.
`
`® the mazimum drawdown Dy over a certain period T = tm —ig. It is
`defined as:
`
`Dp = max(FR;, — Rifto Sta Sty < tz)
`
`(3.6)
`
`where R,, and R,, are the total returns of the periods from ty to tg and
`ty respectively.
`
`e the profit over loss ratio gives an idea of the type of strategy used by
`the model. Its definition is:
`
`Pr _ Nr(rifri > 0)
`( 7)
`Ly
`Ne(rilr; < 0)
`se EE
`where Nr is a function that gives the number of elements of a particular
`set of variables under certain conditions during a period T.
`
`3.
`
`The book-keeper also computes other quantities but they are less relevant
`to this paper. Another book-keeper function is to save the trading history of
`a particular model so it can be retrieved at any time on a user-agent.
`
`3.8. Status and simulation messages
`
`Status and simulation messages are occasionally issued to keep the FX
`dealer informed of the trading models’ states as well as of any likely deals.
`Status messages typically give advance warning of the market opening or
`closing or notification if the market is already closed. These messages also
`indicate whether the supply of raw price data from the commercial market
`quoters to the O&A trading models has been disrupted for any reason. Ideally,
`of course, this should never happen-but a slight possibility of some disruption
`outside the control of O&A does exist.
`
`725
`
`
`
`Neural Network World 6/92, 713-744
`
`Simulation messages give advance notification of a probable deal. A deal
`is considered to be probable if the market continues its present trend for half
`an hour or so,
`
`3.9. The G programming language
`
`The trading models are event-driven. This means that each model is
`implemented in termsof defined actions that are triggered when some external
`event occurs. An external event might be the receipt of a new price from the
`commercial quote-vendors or it might be a timer event such as a local market
`opening or closing,
`This event-driven characteristic of the trading models suggests an imple-
`mentation in terms of a data-flow paradigm. Reception of a new price or a
`timer event causes some defined actions to be triggered and these,
`in turn,
`cause other actions to be triggered. An action may, for example, be a calen-
`lation with a new input price, generation of a new trading recommendation
`or the transfer of computed data to the user-agents. This process contin-
`ues recursively, one action triggering others, until all dependent actions are
`executed.
`The O&A trading models are therefore implemented in a computer lan-
`guage that directly supports such a data-flow paradigm. This is “G” [2], a
`specialized prograrmming language developed at OWA for rule-based, real-time
`data analysis.
`The name G stands for glue because the G interpreter glues together
`disparate software components into a unified whole. In common with conven-
`tional programming languages, G provides syntactic constructs for defining
`variables, expressions and functions. It also include a data-driven knowledge-
`based component for problem solving. G provides means for data to be re-
`ceived from external sources such as a price stream or timer input. Other
`connections to the real world (file input and output, message-passing) are
`also supported.
`As noted above, G is a data flow language. The syntax is taken from
`the LisP programming language. Newcomers to G are often surprised by
`the preponderance of defined expressions and the relative lack of the more
`usual programming control constructs such as procedure calls, while and
`for loops. These do exist in G but their usage is infrequent. Rather the
`intention is that one or more input streams to G provide input in the form
`of variables being updated. Actions and expressions defined in terms of these
`variables are updated in turn and this process continues recursively until
`all dependent expressions are updated. The order in which expressions are
`evaluated may be precisely defined forfine control of this “trickle down”effect.
`Programming in G, therefore, comes down to defining expressions and their
`mutual dependence and this has quite a different flavor from programming in
`better-known languages.
`
`726
`
`
`
`Pictet: Real-Time Trading Models
`
`For example, the following G fragment defines two variables, a and b, and
`two expressions, el and e2. Expression ei is written in terms of a and b and
`expression 62 is written in terms of ef. Subsequently setting either variable,
`aor b, to a new value causes both e1 and e2 to be automatically reevaluated:
`
`; define variables a and b
`(defvar a (real 1.0)
`;
`..» With initial values
`b (real 2.0))
`; define expr 61 in terms of a and b
`(defexpr ei
`(+ a b)
`; define expr e2 in terms of ei
`e2 (* ei 7))
`;
`look at these values
`(print ab ei e2)
`1.000000 2.000000 3.000000 21.000000
`(set a 8.0)
`; give a new value to a
`(update)
`; evaluate dependent expressions
`{print a b ei e2)
`;
`look at these values once more
`8.000000 2.000000 10,000006 70.00000
`
`Other than the differences noted above, however, G shares many features
`with conventional programming languages. Strong typing, debugging support
`(break-pointing and tracing) and execution profiling are present in G.
`
`3.10. Rules and meta-rules
`
`An input stream to a G program provides price data and other input in the
`form of variables being updated. (Such variables are defined using language
`constructs that establish the connection between the input stream and the
`variables in question), Dependent expressions are then recursively evaluated
`before new price data is subsequently provided. However it is not possible to
`change the default order of evaluation within a set of G expressions which is
`that expressions are evaluated in their order of definition.
`For developing realistic models we need other language constructs allowing
`us to prevent confusion between the different clusters of knowledge which can
`come into operation as circumstances vary during trading model operation.
`These are implemented in G through theability to define rules with varying
`priorities and hence to change dynamically the order of their evaluation.
`A G rule definition specifies a condition to be matched, an action to be
`executed and a priority, given as an integer value. For example:
`
`(defrule rulename priority condition action)
`
`A rule is invo