Skip to main content

User Defined Functions

Create your own user definable functions in OpenDataDSL


You can create your own user defined functions and use them in your code, you can also create a library of functions in a script and import that script into other scripts to use those functions.


The syntax for creating a function is the following:

function name ( ((byref)? param (, (byref)? param)*)? )
  • A function has to have a valid name
  • A function can have 0 or more input parameters
  • Input parameters are passed 'by value' which can be over-ridden using the byef parameter modifier
  • A function can return a variable - simply set the variable to the name of the function
  • A function can call other functions, both user defined and built-in functions
  • If there is a comment above the function, then this becomes the description of the function which is shown when hovering over a call to the function


A function to generate a random number between 1 and 100

function random100()
random100 = toInt(random()*100 + 1)

A function that bootstraps and shapes an input curve

* Create an arbitrage free monthly curve from the input curve and use simple shaping
* @param input The input curve
function bootstrapAndShape(input)
boot = bootstrapCurve(input)
bootstrapAndShape = shape(boot)