Summary
• Artificial Intelligence and Finance
• Financial Environments
• Financial Data structures
• Rational Decisions and Cognitive Biases
Four fundamental types of data
Fundamental data
• Fundamental data encompasses information that can be found in regulatory
filings and business analytics.
• It is mostly accounting data, reported quarterly. A particular aspect of this
data is that it is reported with a lapse. You must confirm exactly when each
data point was released, so that your analysis uses that information only
after it was publicly available.
• A common beginner’s error is to assume that this data was published at the
end of the reporting period. That is never the case
• You could not believe how many papers are published every year using
misaligned, fundamental data
Fundamental data - 2
• Fundamental data is that it is often backfilled or reinstated
• “Backfilling” means that missing data is assigned a value, even if those values
were unknown at that time.
• A “reinstated value” is a corrected value that amends an incorrect initial
release.
• The problem is, the corrected values were not known on that first release
date. Some data vendors circumvent this problem by storing multiple release
dates and values for each variable.
• Still, it is very common to find studies that use the final released value and
assign it to the time of the first release, or even to the last day in the reporting
period.
Market data
• Market data includes all trading activity that takes place in an
exchange (like CME) or trading venue (like MarketAxess)
• Ideally, your data provider has given you a raw feed, with all
sorts of unstructured information, like FIX messages that allow
you to fully reconstruct the trading book, or the full collection of
BWIC (bids wanted in competition) responses
• Every market participant leaves a characteristic footprint in the
trading records, and with enough patience, you will find a way to
anticipate a competitor’s next move.
Market data - 2
• For example, TWAP algorithms leave a very particular footprint that is
used by predatory algorithms to front-run their end-of-day trading
(usually hedging) activity (Easley, L´opez de Prado, and O’Hara [2011])
• Human GUI traders often trade in round lots, and you can use this fact to
estimate what percentage of the volume is coming from them at a given
point in time, then associate it with a particular market behavior.
Analytics data
• You could think of analytics as derivative data, based on an original source,
which could be fundamental, market, alternative, or even a collection of other
analytics.
• What characterizes analytics is not the content of the information, but that it
is not readily available from an original source, and that it has been processed
for you in a particular way
• Investment banks and research firms sell valuable information that results
from in-depth analyses of companies’ business models, activities, competition,
outlook, etc.
• Some specialized firms sell statistics derived from alternative data, for
example, the sentiment extracted from news reports and social media.
Analytics data -2
• A positive aspect of analytics is that the signal has been extracted for you
from a raw source
• The negative aspects are that analytics may be costly, the methodology
used in their production may be biased or opaque, and you will not be the
sole consumer.
Alternative data
• Kolanovic and Krishnamachari [2017] differentiate among
alternative data produced by individuals (social media, news,
web searches, etc.), business processes (transactions, corporate
data, government agencies, etc.), and sensors (satellites,
geolocation, weather, CCTV, etc.)
• Some popular satellite image or video feeds include monitoring
of tankers, tunnel traffic activity, or parking lot occupancies
• What truly characterizes alternative data is that it is primary
information, that is, information that has not made it to the
other sources.
Alternative data
• Before a Petrol company reports increased earnings, before its
market price shot up, before analysts wrote their commentary of
their latest filings, before all of that,
• there were movements of tankers and drillers and pipeline traffic. They
happened months before those activities were reflected in the other
data types.
• Two problematic aspects of alternative data are: cost and
privacy concerns
• Capture those data may be very expensive, and the surveilled company
may object, not to mention bystanders.
Alternative data - 2
• Alternative data offers the opportunity to work with truly unique, hard-to-
process datasets.
• Remember, data that is hard to store, manipulate, and operate is always
the most promising.
• You will recognize that a dataset may be useful if it annoys your data
infrastructure team. Perhaps your competitors did not try to use it for
logistic reasons, gave up midway, or processed it incorrectly.
Assets and Data
• It is not hard to realize that each asset will demand different
data streams in order to be analyzed
• When analyzing many assets, it may be required to process a
significant amount of data volume
• That may bring the so called curse of dimensionality
• As dimensionality increases, the volume of the data space increases
so fast that the available data may become sparse
• This sparsity is problematic because the amount of data needed to
support result (in a significant way) will likely grow exponentially
with dimensionality
• In another hand, it is well known that diversification (a large
number of target assets) may provide a better risk-reward
relation in portfollios, by reducing the risks
Summary
• Artificial Intelligence and Finance
• Financial Environments
• Financial Data structures
• Rational Decisions and Cognitive Biases
Rational Decisions and
Cognitive Biases
[in Uncertainy Environments]
Prof. Paulo André Castro
pauloac@[Link]
[Link]/~pauloac
Sala 110, IEC-ITA
How people decide under uncertainty ?
• Let's check in Social Sciences: Economy and Psychology
• Economy's Point of View:
• “The agent of economic theory is rational, selfish, and his tastes do
not change.”
• Psychologist Comment:
• “..To a psychologist, it is self-evident that people are neither fully
rational nor completely selfish, and that their tastes are anything
but stable.
• “Our two disciplines seemed to be studying different
species,...behavioral economist Richard Thaler later dubbed Econs and
Humans”
• From Book Thinking Fast and Slow, D. Kahneman,
• Are human fully rational ?
• Econs decisions can be described by Utility Theory, Humans can
not...
• Let’s go deeper in Rationality with more formality
[Rational ] Decisions in Uncertain
Environments
• Rational Preferences and Rational Decisions
• Utility vs Money
• Decision Networks
Loterias
• Por loterias, descrevemos situações com prêmios (resultados)
incertos. Um agente que escolhe uma loteria pode receber
prêmios com uma respectiva probabilidade
Rational Preferences
• Idea: Preferences of rational agents must obey certain restrictions
• Rational Preferences → Maximization of Expected Utility
• Restrictions:
Breaking rational preferences leads to
very strange (“irrational?”) behaviour
• For example, an agent with intransitive preferences can be
persuated to give away all its money
Maximizing Expected Utility (MEU)
• Theorem(Ramsey, 1931, von Neumann and Morgenstern,
1944): Given preferences satisfying the rational
constrations there exists a real-valued function U such
that:
U ( A) U ( B ) A B
U ([ p1 , S 1 ;... p n , S n ])
i
p iU ( S i )
• Maximizing Expected Utility (MEU) principle:
• Choose the action that maximizes expected utiity
Utility Functions
• Note: an agent can be entirely rational (consitent with MEU)
without ever representing or manipulating utilities and
probaibilities
• E.g. a looup table for perfect tictactoe
• Note 2: if U(x) is a utility function, then aU(x)+b for any a>0
represents the same preferences!
• However, if U(A)=100, U(B)=10, U(C)=0 and U'(A)=1000
U'(B)=10 and U(C)=0 then U and U' represent different
preferences
Estimating Utility functions
Definindo Funções de Utilidades através
de loterias
• Dado o intervalo [0,1] entre a “pior catastrofe possível” e “o
melhor prêmio possível”, ao encontrar uma loteria [p,1;1-p,0]
que seja indiferente a uma situação S o número p é a
utilidade de S
• Em ambientes, com prêmios determinísticos pode-se apenas
estabelecer a ordem de preferências, nesse caso usa-se o
termo utilidades ordinais
• Funções de utilidades ordinais podem ser chamadas
de funções de valor e são invariantes para qualquer
transformação monotônica
Utilidade do dinheiro
• Preferências de um grupo sobre dinheiro certo (x) e loteria
[p,M;1-p,0] onde M=10.000
• Para cada valor de x, ajuste p até que a loteria e x se tornem
indeferentes (Uso da característica da continuidade!!)
Exercício
• Construa um esboço do seu gráfico
Utilidade vs Dinheiro, faça os pontos,
compare com y=x
• Eixo x = Ter x K (mil) R$
• Eixo y
• 0 - continuar como estar,
• 1 - Ganhar 1 milhão de reais
• -1 Ter uma dívida impagável
• Assuma utilidade igual a zero para x=0
• Faca:
1. Define a loteria a utilizar para estimar a
utilidade de um valor certo X
2. Calcule a utilidade para os pontos
x=5000 e 10.000
Exercício - (Parte Negativa)
• Construa um esboço da parte
negativa (x<0) do seu gráfico
Utilidade vs Dinheiro
• Eixo x = Ganhar X R$
• Eixo y
• 0 - continuar como estar,
• -1 Ter uma dívida de 1 milhão de
reais
• Faça:
1. Assuma utilidade igual a zero para
x=0
2. Calcule a utilidade para os pontos
x=-5000 e -10.000
Dinheiro vs Utilidade
• Dinheiro não tem uma relação linear (ou simples) com utilidade!
• Cada indivíduo, tem seu gráfíco de acordo com sua propensão
ou aversão ao risco (que é ligado ao patrimônio)
• Um gráfico típico de dinheiro ($) vs Utilidade (U)
The Saint Petersburg Paradox
• One of the first discussion about
• The paradox is named from Daniel Bernoulli's presentation of the
problem and his solution, published in 1738 in St. Petersburg
• A casino offers a game of chance for a single player in which a fair coin
is tossed at each stage. The pot starts at 1 dollar and is doubled every
time a head appears. The first time a tail appears, the game ends and
the player wins whatever is in the pot.
• Thus the player wins 1 dollar if a tail appears on the first toss, 2 dollars
if a head appears on the first toss and a tail on the second.
• Two questions:
• How much would you accept to pay for playing this game?
• What is the expected monetary value of the game?
Solution:
• What is the expected monetary value of the game?
• EMV=1*0,5+2*0,5^2+4*0,5^3+.... = Infinite!!!
• How much would you accept to pay for playing this game?
• Much [much] less than infinite!
The Saint Petersburg Paradox
• As Bernoulli stated:
• The determination of the value of an item must not
be based on the price, but rather on the utility it
yields…. There is no doubt that a gain of one
thousand ducats is more significant to the pauper
than to a rich man though both gain the same
amount
• Bernoulli proposed that utility of money should be logarithmic.
U(M)= a*log2(M)+b
• This makes EMV to be a finite value.
• But it’s always possible to recreate the paradox by changing the
function!!!
• Alternative theories may provide a better description model
(Prospect Theory)
Problemas na Teoria da maximização da
utilidade esperada
• A teoria da maximização da utilidade esperada é uma teoria
normativa. Ela descreve como um agente deve reagir.
Entretanto, não é uma teoria descritiva da tomada de
decisões reais por pessoas
• Há evidências experimentais que as pessoas violam
(sistematicamente) os axiomas da teoria da utilidade
Escolha A ou B
• A: 80% de chance de ganhar $4000
• B: 100% de chance de ganhar $3.000
Escolha C ou D
• C: 20% de chance de ganhar $4000
• D: 25% de chance de ganhar $3.000
Supondo U(0)=0
• Se maioria escolhe B em detrimento de A e C em detrimento
de D,
• De A e B, temos que 0,8*U(4000)<U(3000)
• De C e D temos que 0,8U(4000)>U(3000)
• Contraditório!!!!
Outro teste simples: leia o retângulo
esquerdo e o direito...mas, importante,
não leia o central !!!!!
Somos programados para Negligenciar a ambigüidade e Suprimir
a dúvida (ou pelo menos, parte de nós é...) Existem muitos outros
vieses como esse “programados” em nossas mentes
Thinking Fast and Slow. Daniel Kahneman
Teorias alternativas
• Em linhas gerais, as pessoas divergem da teoria da maximização da
utilidade esperada em situações de probabilidade muito alta e/ou
muito baixa e algumas outras situações
• Há algumas teorias alternativas que se propõem a descrever o
comportamento humano real. Uma das mais relevantes foi proposta
por Kahneman e Tversky. Esta teoria propõe um modelo alternativo
que descreve esse efeito “certeza” e outros. Kahneman recebeu o
prêmio Nobel de Economia por suas contribuições (Tversky faleceu
seis anos antes,
• Os estudos de Kahneman e Tversky tiveram grande impacto e junto
com o trabalho de outros (entre eles o nobel de Economia Richard
Thaler) deram origem a área chamada de Finanças
Comportamentais (Behavioral Finance)
• Abordaremos alguns trabalhos ligados a IA e Behavioral Finance ao longo do
curso
Sumário
• Funções de utilidades são úteis para representar preferências
de agentes ‘racionais’
• Podem ser também usadas para ilustrar preferências entre
diferenças unidades, inclusive para decisões considerando
vários critérios
• Encontrar o ‘melhor’ caminho entre origem e destino, pode ser o
caminho mais rápido, mais curto ou menor custo financeiro ou
algum tipo de balanço entre estes critérios.
• Mas se o agente obedece aos axiomas básicos existe uma função de
utilidade que representa sua preferência (não necessariamente linear
ou contínua)
• E se é conhecida uma função de utilidade, um agente racional irá
preferir sempre a opção com maior utilidade esperada
Some related work about Prospect
Theory in Finance
• CASTRO, P. A. L.; TEODORO, A.R.B., de CASTRO, L.I.; Parsons, S. Expected utility or
prospect theory: Which better fits agent-based modeling of markets? Journal of
Computational Science (1877-7503). v. 17. pp. 97-102. 2016
• Castro, P. A. L. and S. Parsons (2014). Modeling agent’s preferences based on
Prospect Theory. In. Proccedings of the 8th Multidisciplinary Workshop on Advance in
Preference Handling (MPREF 2014). pp. 32-36. co-located with AAAI-2014
• Abdellaoui, M., Bleichrodt, H. & Kammoun, H. Do financial professionals behave
according to prospect theory? An experimental study. Theory Decision Journal. 74,
411–429 (2013). [Link]
• D. Kahneman, A. Tversky, Prospect theory: an analysis of decision under risk,
Econometrica 47 (2) (1979) 263–291
Introduction to Game
Theory -
When Rational Agents encounter
each other
Prof. Paulo André Castro
pauloac@[Link]
[Link]/~pauloac
Sala 110, IEC-ITA
References
• Wooldridge, M.; An Introduction to Multiagent Systems; John
Wiley and Sons; 2002.
• Shoham, Y. and Leyton-Brown, K. Multiagent Systems
algorithmic, game-theoretic, and logical foundations. New
York: Cambridge Press. 2009.
Utilities and Preferences for Agents
• Assume we have just two agents: Ag = {i, j}
• Agents are assumed to be self-interested: they have
preferences over how the environment is
• Assume W {w1, w2, …}is the set of “outcomes” that agents
have preferences over
• We capture preferences by utility functions:
ui = W Ɽ
uj = W Ɽ
• Utility functions lead to preference orderings over outcomes:
w’ i w means ui(w) < ui(w’)
w j w’ means uj(w) > uj(w’)
Multiagent Encounters
• We need a model of the environment in which these agents
will act…
• agents simultaneously choose an action to perform, and
as a result of the actions they select, an outcome in W
will result
• the actual outcome depends on the combination of
actions
• Environment behavior may be given by state transformer
function:
Non-cooperative Game Theory
Defining Games
Normal (Strategic) Form Games
• Normal Form (Strategic Form): Outcome depends only on
agent’s actions
• Non-normal form: outcome may depends on environment
(randomnly)
Prisioner’s dilemma
• The players of the game are two prisoners suspected of a
crime
• The prisoners are taken to separate interrogation rooms, and
each can either “confess”to the crime or “deny” it (or,
alternatively, “cooperate” or “defect”)
• Their payoff values can be interpreted as the length of jail
term each of prisoner gets in each scenario
Prisioner’s dilemma
Prisoner’s dilemma
• Example: c=0> a=-1 > d=-3 > b=-4
Games of Pure Competition
Matching Pennies Game
• Each agent has a penny
• Each agent indenpeently chooses to display his/her penny
heads up or tails up
• Agent 1 (row) wins if both pennies are equal, so Player 2 loses
• Agent 2 (column) wins if pennies are different, so Player 1 loses
Games of Cooperation
Two drivers on a road and no rules
• Imagine two drivers driving towards each other in a country
having no traffic rules, and who must independently decide
whether to drive on the left or on the right.
• If the drivers choose the same side (left or right) they have
some high utility, and otherwise they have a low utility.
General Games
Battle of Sexes
• In this game, called Battle of the Sexes, a husband and wife
wish to go to the movies, and they can elect among two
movies:
• “Lethal Weapon (LW)” and “Wondrous Love (WL).”
• They much prefer to go together rather than to separate
movies, but while the wife (player 1=Row Player) prefers LW,
the husband (player 2) prefers WL.
• Let’s use:
• B - Wondrous Love (WL)
• F - Lethal Weapon
• Different options means they go separated
Game of Chicken
• The game of chicken models two drivers, both headed for a
single-lane bridge from opposite directions.
• The first to swerve away yields the bridge to the other. If
neither player swerves, the result is a costly deadlock in the
middle of the bridge or a potentially fatal head-on collision.
• In the presence of any opponent who attempts to learn the
protagonist agent’s strategy and play a best response, an
optimal strategy is to play the stationary policy of always
daring; this is the “I’m crazy, policy!”
Analyzing games
Pareto Optimatility
Pareto Optimatility in Some Examples -
Where they are?
• Remember:
• An outcome is Pareto-
optimal if there is NO
other outcome that
Pareto-dominates it
• An outcome 1 is Pareto-
dominated by 2, if in
outcome 2 there is some
agent who strictly prefers
2 and no agent strictly
prefers 1.
Pareto Optimatility in Examples
Pareto Optimatility and Prisioner’s
Dilemma
Best Response and Nash Equilibrium
Nash Equilibrium
Nash Equilibrium in Examples
• Remember:
• If you knew what everyone
else was going to do, the best
response would be an action X
if and only if your utility with
X would be higher or equal to
your other possibilties (not X)
• For Player 1 (row) the best
response is in choosing in
columns
• For Player 2 (column) the best
response is in choosing in
columns
• An outcome is a pure Nash
equilibrium if and only if for
all agents the outcome is their
best response
• Not all games have pure N.E.
Nash Equilibria in Examples