z׸      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                    None Safe  None      None !" "!   !" SafeNone%&9;<=Binary operatorsUnary operators-yA simple expression language of "observable values". An observable represents is a time-varying value (a function from 9 to a value).-Currently there are two types of observables:condition observables, type Obs Boolreal-valued observables, type  Obs Double8A variable name9"We use a continuous model of time.:2Convenience function to create a time from a date.;A constant observable.<*A named interal contract program variable.Usually you should use letin rather than this directly.='A named external real-valued observableExample: primVar "gas-price">%A named external condition observable?aAn observable that becomes true at a single given point in time and is false at all other times.@]An observable that becomes true after a given point in time and is false prior to that time.APAn observable that is true up to a given point in time and is false thereafter.B]An observable that is true between two given points in time and is false at all other times. 'between t1 t2 = time >= t1 && time < t2C6if..then..else for observables (returns an observable)DNegate a boolean observableR&Evaluate an observable at a given timeSdThe time horizon of an condition observable is earliest time that it guaranteed to become true (or Nothing if there is no such time)TReturn the earliest time horizon of a set of observables and the associate tag of the observable that has the earliest time horizon (or Nothing1 if none of the observables have a time horizon)UzCheck if an observable is known to be true at a given point in time, independent of knowledge of any external observablesV{Check if an observable is known to be false at a given point in time, independent of knowledge of any external observablesW=The next time that an observable is guaranteed to become trueX>The next time that an observable is guaranteed to become false]&XML parser for real-valued observables^$XML parser for condition observables_Create XML tagscDisplay tree instancesgFloating operationshDouble operationsi2Note that you can use ordinary Num operators like , ,  etc in observable expressions.jEqualityk)*+,     -./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij9),*+-/.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_9-./01234567;8=><9:?A@BGHIJKLMNOPQCDFE^]_R)*+,\UVWXZ[STY=)*+,      - ./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij G4H4I4J4K4L3M2N6O6P7Q7NoneI A variablelThe main contract data typey-Name of a third party mentioned in a contractzChoice label, used for options{"Scaling factor (used to scale the n contract)|Portfolio name~!Cashflow type, e.g. cash, premiumCurrency, e.g. EUR, USD, GBPLocation, e.g. UK, EUUnit, e.g. tonnes, MWh Commodity, e.g. Gas, Electricity2A duration is a span of time, measured in seconds.4A canonical tradeable element, physical or financialThe zero+ contract has no rights and no obligations.If you acquire one t* you immediately recieve one unit of the  t.>Swap the rights and obligations of the party and counterparty.;Make a contract with a named 3rd party as the counterparty.If you acquire c1  c2 you immediately acquire both c1 and c2.If you acquire c1  c2) you immediately acquire your choice of either c1 or c2.If you acquire cond obs c1 c2 then you acquire c1 if the observable obs is true at the moment of acquistion, and c2 otherwise.If you acquire  scale obs c, then you acquire c> at the same moment except that all the subsequent trades of c0 are multiplied by the value of the observable obs at the moment of acquistion.If you acquire  when obs c, you must acquire c as soon as observable obs subsequently becomes true.Once you acquire  anytime obs c, you may acquire c at any time the observable obs is true.Once acquired,  until obs c is exactly like c5 except that it /must be abandoned/ when observable obs becomes true.GObserve the value of an observable now and save its value to use later./Currently this requires a unique variable name.Example: *letin "count" (count-1) $ \count' -> ...Blmnopqrstuvwxyz{|}~A unique variable nameThe observable to observe now%The contract using the observed valueH-9;<=>?@ABCEFGHIJKLMNOPQlunqrmopstvwxyz{|}~Hlmnopqrstuvwx{~|}zy-;<=>9?A@BCFEGHIJKLMNOPQ-l mnopqrstuvwxyz{|}~None%&2M waiting for obs to become True!waiting for obs to become value vRemaining contract, 6 conditions, inherited scaling, and direction of trade$Current time, blocked, and runnable sA full decision tree A single step in a decision tree;Give the interpretation of a TradeDir as a combination of  and .Precompose a TradeDir with  to get a new combined TradeDir.That is, it respects the law: ?evalTradeDir (setThirdParty p dir) = evalTradeDir dir . party pPrecompose a TradeDir with  to get a new combined TradeDir.That is, it respects the law: 9evalTradeDir (flipTradeDir dir) = evalTradeDir dir . give2Return the two parties in a TradeDir in the order (recieving party, giving party).9+9!None%&2MNone9)*Insert an event into a TimedEvents series.JThis event is placed before the other simultaneous events in the sequence.**Insert an event into a TimedEvents series.IThis event is placed after the other simultaneous events in the sequence..JGeneric merging utility. For sorted input lists this is a full outer join.8      !"#$%&'()*+,-./0123456789:;<=>,      !"#$%&'()*+,-./0128! "#$%&>='()*+,-.<;:987     6543/012)      !"#$%&'()*+,-./0123456789:;<=>None2 NWhen in a wait state there are three different things that can happen one of the observables can become true, we can choose to take an ! option that is available to us.There are two ways an observable can become true, one is due to a change in a primitive/external ovservable, and the other is via the passage of time.JHence, overall, there are three events we are interested in while waiting.kprimitive real-valued obslprimitive bool-valued obsm options takenn  choices madepcontract reduced to q#stop time reached (in timeout mode)r*stopped at first wait point (in wait mode)sa non-terminating waitvreally an error}WTake all three sources of events we are interested in and produce a unified event listHDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{ start timeoptional stop timestop at first waitpoint|}"time series for real primitive obs"time series for bool primitive obs options takenoptional timeouts initial time#initial values of all primitive obs~<DEFGHJKILMNQOPRSTUVWX[YZ\]^_`abcdefghijklmnopqrstuvwxyz{|}~Hwxyzopqrstuvijklmn`abcdefgh\]^_WXYZ[{RSTUV|NOPQ}LM~HIJKFGDEDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ None(8A model has a start date/time and an exchange rate model!Start date and time for the modelExchange rate modelRandom variablesType for value processes-Truncates a (possibly infinite) value processbDetermines the number of time steps in a value process. Only terminates for finite value processestReturns True if every value in a value process is true, false otherwise. Only terminates for finite value processes.$Lift functions wih a single argumentLift functions with 2 arguments$Lift functions for binary operationsLift functions with 3 argumentsBA version of zipWith that handles input lists of different lengths<This is used to support lifted binary operations such as (+)2A simple model with a constant exchange rate modelEach currency has different parameters for the interest rate model. Since the model is not realistic, these parameters are currently entirely arbitrary.;Function to pick an exchange rate model from the above listConstant processGenerate an infinite listEvaluate a condition at date TThe primitive (disc t k) maps a real-valued random variable at date T, expressed in currency k, to its "fair" equivalent stochastic value process in the same currency k.A simplifying assumption is that at some point, the boolean-valued process becomes True for an entire RV. This provides a simple termination condition for the discounting process.dGiven a boolean-valued process o, the primitive absorbk(o,p) transforms the real-valued process p, expressed in currency k, into another real-valued process. For any state, the result is the expected value of receiving p's value if the region o will never be True, and receiving zero in the contrary. In states where o is True, the result is therefore zeroUNot currently implemented. The paper describes the following as a possible algorithm:,take the final column of the tree (horizon),discount it back one time step,Stake the maximum of that column with the corresponding column of the original tree,6then repeat that process all the way back to the root.qsnellk(o,p) is the smallest process q (under an ordering relation mention briefly at the end of B:4.6) such that: +forall o' . (o => o') => q >= snellk(o',q) iCalculates a previous slice in a lattice by averaging each adjacent pair of values in the specified sliceqConstructs a lattice containing possible interest rates given a starting rate and an increment per time step. This "unrealistically regular" model matches that shown in B:Fig.8. However, it is so simple that some interest rates go negative after a small number of time steps. A better model is needed for real applications. Don't use this to model your retirement fund!FEach node in a value process lattice is associated with a probability."...in our very simple setting the number of paths from the root to the node is proportional to the probability that the variable will take that value."The code for absorb above does not obviously deal with the expected value mentioned in the spec. This is because the expected value of each random variable is implicit in the value process lattice representation: each node in the lattice is associated with a probability, and the expected value at a particular date is simply the sum of the product of the value at each node and its associated probability. The following functions implement this calculation.#Evaluate a contract at a given timeEvaluate a constant observableThis code generates graphs which represent a value process lattice. Currently assumes Double values, constrained by showNode's formatting of the value.9Write out tree as Dot file and run Dot to generate image:3Supports interactive display of generated Dot code.(Write a value process out as a Dot file.dRun Dot on a file with the specified base name, and generate a graphic file with the specified type. Convert a  !% to a list of dot node relationships.2Convert lattice to list of dot node relationships.&Number each of the nodes in a lattice.FshowNodes returns a list of "primary" Dot representations of numbered  nodes, with each node's value specified as the node's label. These nodes can then be referenced repeatedly in the generated Dot code without specifying a label.5Generate Dot code for relationships between numbered  nodes. To use Equality operations on PRTo use Ord operations on PRTo use Num operations on PR303."   !"##$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~xe       !"#$%&'()*+,-./0123456789:;<==>>??@ABBCDEFGHIJKLLMNOPQRSTTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                          ?>   !"yz8    ! $netrium-0.6.0-CDbpbCp0uqiCWtPWe4xISA ObservableUnitsDB ObservableDBContract DecisionTreeDecisionTreeSimplify Observations Interpreter ValuationXmlUtils WriteDotGraphDisplaybaseGHC.NumnegateabsUnitDecl CommodityDecl LocationDecl CurrencyDeclCashFlowTypeDecl unUnitsDBcompileUnitsDB$fXmlContentUnitDecl$fHTypeableUnitDecl$fXmlContentUnitsDB$fHTypeableUnitsDB$fShowUnitDecl$fReadUnitDecl $fShowUnitsDB $fReadUnitsDBObservableTypeDoubleBoolObservableDeclunObservableDBcompileObservableDB$fXmlContentObservableType$fHTypeableObservableType$fXmlContentObservableDecl$fHTypeableObservableDecl$fXmlContentObservableDB$fHTypeableObservableDB$fShowObservableType$fReadObservableType$fShowObservableDecl$fReadObservableDecl$fShowObservableDB$fReadObservableDBSteps NeedNamedVal NeedNamedCondResultObsConstVarNamedVal NamedCondAtAfterBeforeUnOpBinOpIfThenVarNameTimemkdatekonstvarprimVarprimCondatafterbeforebetweenifthennotminmax%==%>%>=%<%<=%&&%||%+%-%*%/eval timeHorizonearliestTimeHorizonisTrueisFalsenextTrue nextFalsesimplifyWithinHorizon evermoreTrue evermoreFalsesubst parseObsReal parseObsCondprintObs $fDisplayObs $fShowBinOp $fShowUnOp $fShowObs$fDEqBinOpBinOp $fDEqUnOpUnOp $fDEqRepRep $fFloatingObs$fFractionalObs$fNumObs$fEqObs $fShowStepsZeroOneGivePartyAndOrCondScaleReadWhenAnytimeUntil PartyNameChoiceId ScaleFactor Portfolio CashFlowTypeCurrencyLocationUnit CommodityDuration TradeablePhysical Financialzeroonegivepartyandorcondscalereadwhenanytimeuntilletin$fXmlContentContract$fHTypeableContract$fXmlContentPortfolio$fHTypeablePortfolio$fXmlContentCashFlowType$fHTypeableCashFlowType$fXmlContentCurrency$fHTypeableCurrency$fXmlContentLocation$fHTypeableLocation$fXmlContentUnit$fHTypeableUnit$fXmlContentCommodity$fHTypeableCommodity$fXmlContentDuration$fHTypeableDuration$fXmlContentTradeable$fHTypeableTradeable$fDisplayContract $fEqDuration$fShowDuration $fNumDuration $fEqCommodity$fShowCommodity$fEqUnit $fShowUnit $fEqLocation$fShowLocation $fEqCurrency$fShowCurrency$fEqCashFlowType$fShowCashFlowType $fEqPortfolio$fShowPortfolio $fEqTradeable$fShowTradeable $fEqContract$fShowContract ObsConditionunObsConditionTradeDir TradeDir2To1 TradeDir1To2 TradeDirPTo1 TradeDirPTo2 TradeDir1ToP TradeDir2ToP TradeDirPToQ TradeDirQToPBlocked BlockedOnWhenBlockedOnAnytime ThreadStateTSt ProcessStatePSt FirstParty Counterparty ThirdParty DecisionStepDoneTradeChoose ObserveCond ObserveValueWaitunfoldDecisionTree decisionTreeinitialProcessStatecurrentContract decisionStepeach evalTradeDir setThirdParty flipTradeDirtradeDirParties$fXmlContentProcessState$fHTypeableProcessState$fXmlContentThreadState$fHTypeableThreadState$fXmlContentObsCondition$fHTypeableObsCondition$fXmlContentBlocked$fHTypeableBlocked$fXmlContentTradeDir$fHTypeableTradeDir$fXmlContentParty$fHTypeableParty$fDisplayDecisionTree$fShowDecisionStep $fEqParty $fShowParty $fShowBlocked $fEqBlocked$fShowTradeDir $fEqTradeDir$fShowThreadState$fEqThreadState$fShowProcessState$fEqProcessState$fFunctorDecisionStepdecisionTreeSimpledecisionStepWithTime simplifyWaitXMLTimedEvents XMLTimeSeries SeriesEnd UnboundedBoundedTimedChoiceOrChoice AnytimeChoice ChoiceSeriesObservationSeriesObservationsSeriesBoolObservationsSeriesDouble MergeResult OnlyInLeftInBoth OnlyInRight TimedEventsTEs TimeSeries SeriesEntry SeriesEndsSeriesUnboundedChoiceslookupTimeSeriespruneTimeSeries lookupChoicetimeSeriesEventsunTEs mapAccumTSlookupTimedEventinsertEventBeforeinsertEventAfterpruneTimedEvents mergeEventsmergeEventsBiasedmergeBy toTimedEventsfromTimedEvents toTimeSeriesfromTimeSeries$fXmlContentTimed$fHTypeableTimed$fXmlContentSeriesEnd$fHTypeableSeriesEnd$fXmlContentChoice$fXmlContentChoiceSeries$fHTypeableChoice$fHTypeableChoiceSeries$fXmlContentObservationSeries$fHTypeableObservationSeries$fMonoidTimedEvents$fFunctorTimedEvents$fShowTimeSeries$fReadTimeSeries$fShowTimedEvents$fReadTimedEvents$fEqTimedEvents WaitOption WaitCondition ObsResult ObsExhausted ObsMissingObsEnv WaitEvent TakeOption ObsChangedTimeout WaitResult WaitContinue WaitStopped WaitFinished WaitNonTermWaitInfowaitObs waitHorizon waitOptionsStopWaitNoStop StopFirstWait StopNextWait SimOutputssimTrace simOutputs simStopReason simStopTimesimStopContract simStopStatesimStopWaitInfoSimEnvvalueObservationscondObservations optionsTaken choicesMade StopReasonFinished StoppedTime StoppedWait WaitForeverChoiceRequiredObservationExhaustedObservationMissingOutput OptionUntil OptionForever runContractrunWaitmergeWaitEvents currentObsEnvevalObs$fXmlContentWaitOption$fHTypeableWaitOption$fXmlContentWaitCondition$fHTypeableWaitCondition$fXmlContentWaitInfo$fHTypeableWaitInfo$fXmlContentStopWait$fHTypeableStopWait$fXmlContentStopReason$fHTypeableStopReason$fXmlContentOutput$fHTypeableOutput $fEqOutput $fShowOutput$fEqStopReason$fShowStopReason$fShowStopWait $fEqStopWait$fShowWaitInfo $fEqWaitInfo$fShowSimOutputs$fEqSimOutputs $fShowObsEnv$fShowWaitEvent$fFunctorObsResult$fShowObsResultModel modelStartexchRVPRunPrtakePr horizonPrandPrliftPrlift2Pr lift2PrAlllift3Pr zipWithAll simpleModel rateModels rateModelbigK konstSlicescondPrdiscabsorbsnell prevSliceratesprobabilityLattice expectedValueexpectedValuePrevalCevalO latticeImage printTreewriteTreeAsDotrunDotprToDotrvsToDotdotExt assignIds numberList showNodes nodeLabel treeToDotdotJoindotGraph dotGraphHdr formatDotStmt$fEqPR$fOrdPR$fNumPR$fShowPRattrStrattrReadmkElemACreadText$fXmlContentUTCTime$fHTypeableUTCTime$fXmlContentDouble$fXmlContentBool labelTree treeToGraph writeDotFilerenderDotGraphheaderfootergraphDefaultAtribsnodeDefaultAtribsedgeDefaultAtribstoTree trimDepthdispdisp'containers-0.5.7.1 Data.TreeunfoldForestM_BFunfoldTreeM_BF unfoldForestM unfoldTreeM unfoldForest unfoldTreelevelsflatten drawForestdrawTreeTreeNode rootLabel subForestForest+-*DEqdeqTEqReflRepEqGtGteLtLteAddSubMulDivMinMaxNotNegAbsSqrtExpLogSinCosAsinAtanAcosSinhCoshAsinhAcoshAtanhisInfixevalUnOp evalBinOp Data.Foldableghc-prim GHC.Types