Professional Documents
Culture Documents
Settlement Templating Language (STL) : Release 1.2
Settlement Templating Language (STL) : Release 1.2
Settlement Templating Language (STL) : Release 1.2
Release 1.2
Algosport
1 Introduction 1
2 Samples 3
2.1 Contest phases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Time periods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Incidents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Defining settlements 7
3.1 Basic operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Aggregates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 Incident properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4 Sports 13
5 Examples 15
Index 19
i
ii
CHAPTER
ONE
INTRODUCTION
STL (Settlement Templating Language) is a domain-specific language used to define settlement rules within sports
betting. Separating the settlement rules from the underlying mathematical models enables much greater flexibility in
growing a sportsbook offering.
1. Automatic pricing of selections is performed by linking a model to the settlement rules. Whilst STL primarily
defines how a selection is to be settled we can easily recover the odds for a selection by calculating its expected
settlement over all possible match outcomes generated by the model.
2. New selections can be quickly and easily defined - and hence priced - by settlement rules entered by traders or
product managers without the required expertise of the quant and/or algorithm implementation teams.
3. New products can be innovated or replicated because we have the ability to directly interact with the structure
of the settlement rules for the bet.
(a) Bet builder allows customers to create their own individual bets by combining pre-existing selections. If
selections are already defined in STL then combining multiple selections into a single bet is incredibly
simple. For example, if a customer wishes to get a price for the combination of home win:
then we only need to request the price for the combined selection:
1
Settlement Templating Language (STL), Release 1.2
and we price the cost to edit the bet based on the expected payouts for:
and:
(c) Cash out is a special case of bet editor where all selections are removed from the initial bet.
2 Chapter 1. Introduction
CHAPTER
TWO
SAMPLES
Samples form the basis of all settlement rules in STL. They are expressed as a pair, <phase interval,
incident type>, where the two component parts are
1. Phase interval
A period of play within a contest, e.g.
• regulation time
• 11th frame
• 3rd quarter of regulation time
• last 10 minutes of over time
• first 5 points of 3rd game in 2nd set
2. Incident type
Actions that are recorded throughout the contest, e.g.
• goals
• sets
• yellow cards
• home team points
• aces
The permissible pairs of phase intervals and incident types in a a sample are determined by the structure of the sport.
How STL defines this structure is discussed in Contest phases. The ways in which samples may be manipulated to
build up settlement rules is discussed in Defining settlements.
Within STL, contests are organised into a collection of sport-specific phases. Each phase has a notion of time, sub-
phases, and a set of incidents associated with it. Not all phases will be present in every contest nor all sub-phases in
each phase. This is best understood through a few examples.
1. Football
Football contests are divided into timed phases
• regulation time; and
• extra time
3
Settlement Templating Language (STL), Release 1.2
both of which contain 1st and 2nd half sub-phases, and a point based phase
• penalties
which has no sub-phases with.
Regulation and extra time contain incidents such as goals, corners, cards and free-kicks. Penalty shootouts
consist solely of scored or missed penalties.
League matches will only consist of regulation time. Cup ties may contain one or both of extra time or penalties.
2. Basketball
In basketball, unlike football, the sub-phases of regulation time are dependent on contest format. Some leagues
play matches over 4 quarters and others play over 2 halves.
3. Tennis
The point-based scoring system means that the phases and sub-phases are also incidents within the contest. Sets
are both the top-level phases because they determine the rules for that period of play and the incidents that
determine the final score of the contest.
The sub-phases and incidents within a set are determined by its type.
• Advantage sets consist of game sub-phases made of point incidents.
• Tie-break sets add tie-break games to the phases and incidents of advantage sets.
• Super tie-break sets have no sub-phases and only points as incidents.
The passage of time may be measured in sets, games, points or some combination thereof dependent on the
phase that we are considering.
A time period is an interval within a phase. An interval may be either an entire named phase, or an interval defined
defined in terms of the time instants for that phase.
• regulation time - RT
• 4th quarter - Q4
• frame 11 - frames[11]
• 3rd game of set 2 - sets[2]:games[3]
or a sub-interval within a phase, for example
• 0:00 to 9:59 inclusive - [RT:0, RT:9:59] or [RT:0, RT:10)
Timed phases, often split into multiple timed sub-phases, are played against the clock. Whilst the behaviour of the
clock varies by sport, for example
• does the clock run continously is does it start and stop? e.g. football vs. ice hockey
• does a period end as soon as time has elpased, e.g. ice hockey, or can it run beyond, e.g. rugby union.
this doesn’t affect any STL definitions.
4 Chapter 2. Samples
Settlement Templating Language (STL), Release 1.2
A time instant within a timed phase is expressed as phase:minute:second. The seconds are optional and de-
faulted to zero if not present. For instance,
• 10 minutes through regulation time, named RT is RT:10
• 5 minutes and 30 seconds through the 3rd quarter, named Q3 is Q3:5:30
Time instants may be used to define the instant at which an incident occured, e.g. testing if the first goal happens
after 10:00 and before 20:00
ifExists(nth(1, <RT, goals>), i => RT:10 < $i.time <= RT:20, lose)
They are also used to define custom time periods which are used in Samples.
Incidents that occur within a timed period have a time property associated with them. Time within
• RT: regulation time
• H1: 1st half
• H2: 2nd half
2.3 Incidents
Each sport defines a set of incidents which each have an associated set of properties.
For football the current set of incidents are
• goals
– team: home or away
– player: id of the player who scored
2.3. Incidents 5
Settlement Templating Language (STL), Release 1.2
goals[team=home])
corners[team=away, type=yellow]
cards[player="123",type=yellow]
6 Chapter 2. Samples
CHAPTER
THREE
DEFINING SETTLEMENTS
STL supports three basic arithmetic operations which all act only on integer types:
• Addition (+)
• Multiplication (*)
• Subtraction (-)
These are useful for defining complex aggregates such as
• Multi-corners:
• Booking points:
STL also support unary negation, (-), which acts on any numeric type. This is most often seen when defining
• incidents in reverse order e.g. last goal:
7
Settlement Templating Language (STL), Release 1.2
even(total(<RT, goals>))
Settlement condtions may be combined using the logical operators and and or. This enables more complicated
settlement rules to be built up.
• Home wins from behind:
The unary function not may also be used to negate a settlement condition.
• Away team never leads:
3.1.5 Literals
settlement(w, v)
where 𝑤, 𝑣 ∈ [0.0, 1.0] such that 𝑤 + 𝑣 ≤ 1.0. As well as the general form above we define
– win = settlement(1.0, 0.0)
– void = settlement(0.0, 1.0)
– lose = settlement(0.0, 0.0)
which are useful when defining settlements dependent on the existence of an incident.
– Home first to score:
3.2 Aggregates
Aggregation functions take a statistic and perform some sort of calculation all the relevant incidents that have occured
within the specified time period.
total(statistic)
Total number of occurences of a particular statistic.
supremacy(statistic)
Supremacy (home total - away total) of a given statistic.
h2h(statistic)
Head-to-head score of a given statistic.
Using the example of the goals score beingn 2-1 during regulation time then the above functions would settle as wins
in the following scenarios
• Exactly 3 total goals:
total(<RT, goals>) = 3
3.2. Aggregates 9
Settlement Templating Language (STL), Release 1.2
asian(aggregate)
Convert the resulting rules on a integer based aggregate - total, supremacy and any combination thereof -
to asian based resulting.
e.g. Home wins draw no bet:
anytime(settlementCondition)
Is the settlement condition met at any point within the time period rather than just at the end of the interval. e.g.
home team win from behind:
As well as talking about the aggregation of a collection of incidents over a time period we can also refer to the nth
occurence of an incident within a time period.
nth(n, statistic)
The nth occurence of a given statistic. The count starts from 1, so the 2nd corner in the 2nd half would be given
by:
Conversely, you can count backwards with the last incident having n = -1, the penultimate having n = -2,
and so on. e.g. The last home goal in regular time would be:
raceTo(n, statistic)
Return the team (if it exists) who first reach a count of n occurences of a given statistic. Like nth() it may not
exist, e.g. first to 2 yellow cards:
• Home team win 3-way race to 5 corners in first half (lose if no-one reaches 5):
• Home team win 2-way race to 5 corners in first half (void if no-one reaches 5):
FOUR
SPORTS
13
Settlement Templating Language (STL), Release 1.2
14 Chapter 4. Sports
CHAPTER
FIVE
EXAMPLES
15
Settlement Templating Language (STL), Release 1.2
16 Chapter 5. Examples
Settlement Templating Language (STL), Release 1.2
17
Settlement Templating Language (STL), Release 1.2
18 Chapter 5. Examples
INDEX
A
anytime() (built-in function), 10
asian() (built-in function), 10
E
even() (built-in function), 7
H
h2h() (built-in function), 9
I
ifExists() (built-in function), 11
N
nth() (built-in function), 10
O
odd() (built-in function), 7
R
raceTo() (built-in function), 10
S
supremacy() (built-in function), 9
T
total() (built-in function), 9
19