verbs_examples.agents.uniswap_agent.Gbm#

class Gbm[source]#

Geometric brownian motion modelling the price of two tokens

Notes

We assume that token B is some stablecoin so its price remains constant.

__init__(mu: float, sigma: float, token_a_price: int, token_b_price: int, dt: float)[source]#
Parameters:
  • mu (float) – Drift of GBM

  • sigma (float) – Volatility of GBM

  • token_a_price (int) – Initial price of token A

  • token_b_price (int) – Initial price of token B

  • dt (float) – Time step of time discretisation for the SDE solver scheme

get_sqrt_price_token_a_x96() float[source]#

Get price of token A in terms of token B

Notes

We return the square root of the price times 296 for a fair comparison with the price values returned by the Uniswap contract.

Returns:

float – Square root of the price of token A in terms of token B times 296

get_sqrt_price_token_b_x96()[source]#

Get price of token B in terms of token A

Notes

We return the square root of the price times 296 for a fair comparison with the price values returned by the Uniswap contract.

Returns:

float – Square root of the price of token B in terms of token A times 296

update(rng: Generator, price_impact: float)[source]#

Update Gbm

Update GBM price using:

  • \(P^a_{t+dt} = P^a_t * exp((\mu-0.5*\sigma^2)dt + \sigma * (W_{t+dt} - W_{t}))\)

  • \(P^{a, impact}_{t+dt} = P^a_{t+dt} + price_impact\)

  • \(P^b\) is constant

Notes

We consider an impact on the price of token A. This impact can be modelled in different ways, e.g. as a transient price impact given by the trades.

Parameters:
  • rng (np.random.Generator) – Numpy random generator, used for any random sampling to ensure determinism of the simulation.

  • price_impact (float) – Network/EVM that the simulation interacts with.