strategy

Backtest

class strategy.backtest.Backtest(strategy: strategy.strategies.AbstractStrategy, portfolio: Optional[strategy.portfolio.Portfolio] = None)
Backtest emulate portfolio behavior on historical data.
Collects and process portfolio state for each point in time.
Returns in a convenient form for analyzing the results
backtest(df_swaps: polars.internals.frame.DataFrame) Tuple[strategy.history.PortfolioHistory, strategy.history.RebalanceHistory, strategy.history.UniPositionsHistory]
1) Sends Portfolio and every market action to AbstractStrategy.rebalance
2) expected return of AbstractStrategy.rebalance is name of strategy action e.g.
‘init’, ‘rebalance’, ‘stop’, ‘some_cool_action’, None. When there is no strategy action prefer return None.
Add porfolio action to RebalanceHistory
3) Add Porfolio snapshot to PortfolioHistory
4) Add Porfolio snapshot to UniPositionsHistory

You can send anything you want to AbstractStrategy.rebalance cause it take *args, **kwargs,
but be sure to send raw=[(‘timestamp’, ‘price’)] and portfolio=self.portfolio
df_swaps

df with pool swaps, or df with market data. df format is [(‘timestamp’, ‘price’)]

Returns

History classes that store accumulated&processed results of backtesting.

PortfolioHistory - keeps metrics such as APY
RebalanceHistory - keeps information about portfolio actions, such as init ot rebalances
UniPositionsHistory - keeps information about open UniV3 positions

CrossValidation

class strategy.cross_validation.FolderSimple(n_folds: int = 5)

FolderSimple makes the splitting into equal folds.

n_folds

Number of folds.

generate_folds_by_index(data)

Split data into folds

Parameters

data – Uniswap exchancge data

get_fold(data, fold_name)

Get fold by name.

Parameters
  • data – Uniswap exchancge data

  • fold_name – Folds name

Returns

Fold data as PoolDataUniV3

class strategy.cross_validation.CrossValidation(folder, strategy)

CrossValidation backtests strategy on folds.

folder

Folder class that splits data on folds

strategy

Strategy to backtest

aggregate(folds_result)

Aggregate backtesting results from folds

Parameters

folds_result – History from folds

Returns

Dict of APY’s by folds

backtest(data)

Parallel backtesting on folded data

Parameters

data – Uniswap exchancge data

Returns

List of history dicts by folds

Data

class strategy.data.PoolDataUniV3(pool: strategy.primitives.Pool, mints: Optional[pandas.DataFrame] = None, burns: Optional[pandas.DataFrame] = None, swaps: Optional[pandas.DataFrame] = None)

PoolDataUniV3 contains data for backtesting.

pool

UniswapV3 Pool data

mints

UniswapV3 mints data.

burns

UniswapV3 burns data.

swaps

UniswapV3 swaps data.

class strategy.data.RawDataUniV3(pool: strategy.primitives.Pool, data_dir: Optional[pathlib.Path] = None)

Load data from folder, preprocess and Return PoolDataUniV3 instance.

load_burns() polars.internals.frame.DataFrame

Read burns from csv and preprocess

Returns

burns df

load_from_folder() strategy.data.PoolDataUniV3

Load mints, burns, swaps from folder, preprocess and create PoolDataUniV3 object.

Returns

PoolDataUniV3` object

load_mints() polars.internals.frame.DataFrame

Read mints from csv and preprocess

Returns

mints df

load_swaps() polars.internals.frame.DataFrame

Read swaps from csv, preprocess, create sqrt_price_x96 column.

Returns

swaps df

class strategy.data.SyntheticData(pool, start_date: str = '1-1-2022', n_points: int = 365, init_price: float = 1, mu: float = 0, sigma: float = 0.1, seed=42)
SyntheticData generates UniswapV3 synthetic exchange data (swaps df).
Generates by sampling Geometric Brownian Motion.
pool

UniswapV3 Pool instance.

start_date

Generating starting date. (example ‘1-1-2022’)

n_points

Amount samples to generate.

init_price

Initial price.

mu

Expectation of normal distribution.

sigma

Variance of normal distribution.

seed

Seed for random generator.

generate_data()

Generate synthetic UniswapV3 exchange data.

Returns

PoolDataUniV3 instance with synthetic swaps data, mint is None, burn is None.

History

class strategy.history.PortfolioHistory
PortfolioHistory accumulate snapshots and can calculate stats over time from snapshots.
Each time add_snapshot method is called it remembers current state in time.
All tracked values then can be accessed via to_df method that will return a pd.Dataframe.
add_snapshot(snapshot: dict) None

Add portfolio snapshot to history.

Parameters

snapshot – Dict of portfolio params.

calculate_apy_for_col(df: polars.internals.frame.DataFrame, from_col: str, to_col: str, calculate_full: bool = False) polars.internals.frame.DataFrame

Calculate APY for metric

Parameters
  • df – dataframe with metrics

  • from_col – metric column name

  • to_col – name for new column with metric APY

  • calculate_full

    True: calculate APY from first day to last
    False: calculate APY from first day to current

Returns

dataframe consisting of ‘to_col’ column

calculate_fees(df: polars.internals.frame.DataFrame) polars.internals.frame.DataFrame
Calculate X and Y fees of Uniswap positions.
As sum over all positions
Parameters

df – Portfolio history DataFrame. return of PortfolioHistory.to_df()

Returns

dataframe consisting of two columns total_fees_x, total_fees_y

calculate_ils(df: polars.internals.frame.DataFrame) polars.internals.frame.DataFrame
Calculate impermanent loss separately in X and Y currencies.
As sum of positions IL.
Parameters

df – Portfolio history DataFrame. return of PortfolioHistory.to_df()

Returns

dataframe consisting of two columns total_il_x, total_il_y

calculate_returns(df: polars.internals.frame.DataFrame) polars.internals.frame.DataFrame
Calculate: returns for columns.
new columns:
portfolio_returns_x, hold_returns_x
portfolio_returns_y, hold_returns_y
vpn_returns
vpn_hold_returns
Parameters

df – Portfolio history DataFrame.

Returns

dataframe consisting of new columns

calculate_stats() polars.internals.frame.DataFrame

Calculate all statistics for portfolio. Main function of class.

Returns

Portfolio history data frame.

calculate_value_to(df: polars.internals.frame.DataFrame) polars.internals.frame.DataFrame
Calculate:
total_value_to_x - total_value denominated in X
total_fees_to_x - total_fees denominated in X
total_il_to_x - total_il denominated in X
hold_to_x - total_value denominated in X for hold strategy
corresponding columns with denomination in Y
vpn_value - total_value_to_x at last price p_n
vpn_hold - hold_to_x at last price p_n
Parameters

df – Portfolio history DataFrame with cols from PortfolioHistory.calculate_values, PortfolioHistory.calculate_ils, PortfolioHistory.calculate_fees

Returns

dataframe consisting of new columns

calculate_values(df: polars.internals.frame.DataFrame) polars.internals.frame.DataFrame

Calculate amount of X and amount of Y in Portfolio

Parameters

df – Portfolio history DataFrame. return of PortfolioHistory.to_df()

Returns

dataframe consisting of two columns total_value_x, total_value_y

to_df() polars.internals.frame.DataFrame

Transform list of portfolio snapshots to data frame.

Returns

Portfolio history data frame.

class strategy.history.RebalanceHistory
RebalanceHistory tracks porfolio actions (rebalances) over time.
Each time add_snapshot method is called class remembers action.
All tracked values except None! then can be accessed via to_df method that will return a pl.Dataframe.
add_snapshot(timestamp: datetime.datetime, portfolio_action: Optional[str])

Add portfolio action to memory

Parameters
  • timestamp – Timestamp of snapshot.

  • portfolio_action – name of portfolio action or None. Usually it takes from ‘’AbstractStrategy.rebalance`` output.

to_df() pandas.DataFrame
Transform list of portfolio actions to data frame.
Drop all None actions!
Returns

Data frame of porfolio actions, except None actions.

class strategy.history.UniPositionsHistory

UniPositionsHistory tracks Uniswap positions over time. Each time add_snapshot method is called it remembers all Uniswap positions at current time. All tracked values then can be accessed via to_df method that will return a pd.Dataframe.

add_snapshot(timestamp: datetime.datetime, positions: dict)

Add Uniswap position snapshot to history.

Parameters
  • timestamp – Timestamp of snapshot.

  • positions – List of Uniswap positions.

to_df() polars.internals.frame.DataFrame

Transform list of Uniswap positions snapshots to data frame.

Returns

Uniswap positions history data frame.

Data

class strategy.multi_strategy.MultiStrategy(name: Optional[str] = None, strategies: Optional[List[strategy.strategies.AbstractStrategy]] = None)

MultiStrategy is used for making composition of several strategies.

name

Unique name for the instance.

strategies

List of strategies.

append(strategy: strategy.strategies.AbstractStrategy) None

Add strategy to composition.

Parameters

strategy – Any AbstractStrategy.

rebalance(*args: list, **kwargs: dict) Hashable

Rebalance implementation for strategy composition.

Parameters
  • args – Any args.

  • kwargs – Any kwargs.

Returns: Rebalnaces status of each strategy in composition.

remove(name: str) None

Remove strategy from composition by name.

Parameters

name – Strategy name.

Portfolio

class strategy.portfolio.Portfolio(name: str, positions: Optional[List[strategy.positions.AbstractPosition]] = None)

Portfolio is a container for several open positions.

name

Unique name for the position.

positions

List of initial positions.

append(position: strategy.positions.AbstractPosition) None

Add position to portfolio.

Parameters

position – Any AbstractPosition instance.

get_last_position() strategy.positions.AbstractPosition

Get last position from portfolio.

Returns

Last position in portfolio.

get_position(name: str) strategy.positions.AbstractPosition

Get position from portfolio by name.

Parameters

name – Position name.

Returns

AbstractPosition instance.

position_names() List[str]

Get list of position names in portfolio.

Returns

List of all position names in portfolio.

positions_list() List[strategy.positions.AbstractPosition]

Get list of all positions in portfolio.

Returns

List of all positions in portfolio.

remove(name: str) None

Remove position from portfolio by its name.

Parameters

name – Position name.

rename_position(current_name: str, new_name: str) None

Rename position in portfolio by its name.

Parameters
  • current_name – Current name of position.

  • new_name – New name for position.

snapshot(timestamp: datetime.datetime, price: float) dict
Get portfolio snapshot.
Used in PortfolioHistory.add_snapshot() to collect backtest data.
Parameters
  • timestamp – Timestamp of snapshot

  • price – Current price of X in Y currency

Returns: Position snapshot

to_x(price: float) float

Get total value of portfolio denominated to X.

Parameters

price – Current price of X in Y currency

Returns

Total value of portfolio denominated in X

to_xy(price: float) Tuple[float, float]

Get amount of X and amount of Y in portfolio

Parameters

price – Current price of X in Y currency.

Returns

(amount of X, amount of Y)

to_y(price: float) float

Get total value of portfolio expressed in Y

Parameters

price – Current price of X in Y currency

Returns

Total value of portfolio denominated in Y

Positions

class strategy.positions.AbstractPosition(name: str)

AbstractPosition is an abstract class for Position and Portfolio classes.

name

Unique name for the position.

rename(new_name: str) None

Rename position.

Parameters

position. (New name for) –

abstract snapshot(timestamp: datetime.datetime, price: float) dict
Get a snapshot of the position. Used in Portfolio.snapshot to create a snapshot
of the entire portfolio when backtesting.
for linking in the backtest metrics, you can to add metrics here
Parameters
  • timestamp – Timestamp of snapshot

  • price – Current price of X in Y currency

Returns: Position snapshot

abstract to_x(price: float) float
Parameters

price – Current price of X in Y currency

Returns

Total value of vault expessed in X

abstract to_xy(price: float) Tuple[float, float]

Get amount of X and amount of Y in vault

Parameters

price – Current price of X in Y currency.

Returns

(amount of X, amount of Y)

abstract to_y(price: float) float
Parameters

price – Current price of X in Y currency.

Returns

Total value of vault expessed in Y.

class strategy.positions.BiCurrencyPosition(name: str, swap_fee: float, rebalance_cost: float, x: Optional[float] = None, y: Optional[float] = None, x_interest: Optional[float] = None, y_interest: Optional[float] = None)

BiCurrencyPosition is a class corresponding to currency pair vault.

name

Unique name for the position.

swap_fee

Exchange fee expressed as a percentage.

rebalance_cost

Rebalancing cost, expressed in Y currency.

x

Amount of asset X.

y

Amount of asset Y.

x_interest

Interest on currency X deposit expressed as a daily percentage yield.

y_interest

Interest on currency Y deposit expressed as a daily percentage yield.

deposit(x: float, y: float) None

Deposit X currency and Y currency to position.

Parameters
  • x – Value of X currency

  • y – Value of Y currency

interest_gain(date: datetime.datetime) None

Get interest on deposit X, deposit Y

Parameters

date – Gaining date.

rebalance(x_fraction: float, y_fraction: float, price: float) None

Rebalance bicurrency vault with respect to their proportion.

Parameters
  • x_fraction – Fraction of X after rebalance. from 0 to 1.

  • y_fraction – Fraction of Y after rebalance. from 0 to 1.

  • price – Current price of X in Y currency.

snapshot(timestamp: datetime.datetime, price: float) dict
Get a snapshot of the position. Used in Portfolio.snapshot to create a snapshot
of the entire portfolio when backtesting.
for linking in the backtest metrics, you can to add metrics here
Parameters
  • timestamp – Timestamp of snapshot

  • price – Current price of X in Y currency

Returns: Position snapshot

swap_x_to_y(dx: float, price: float) float

Swap some X to Y.

Parameters
  • dx – Amount of X to be swapped.

  • price – Current price of X in Y currency.

Returns

Amount of Y was getted

swap_y_to_x(dy: float, price: float) float

Swap some Y to X.

Parameters
  • dy – Amount of Y to be swapped.

  • price – Current price of X in Y currency.

Returns

Amount of X was getted

to_x(price: float) float
Parameters

price – Current price of X in Y currency

Returns

Total value of vault expessed in X

to_xy(price: float) Tuple[float, float]

Get amount of X and amount of Y in vault

Parameters

price – Current price of X in Y currency.

Returns

(amount of X, amount of Y)

to_y(price: float) float
Parameters

price – Current price of X in Y currency.

Returns

Total value of vault expessed in Y.

withdraw(x: float, y: float) Tuple[float, float]

Withdraw X currency and Y currency from position

Parameters
  • x – Value of X currency

  • y – Value of Y currency

Returns

X amount withdrawn, Y amount withdrawn

withdraw_fraction(fraction: float) Tuple[float, float]

Withdraw percent of X currency and percent of Y currency from position

Parameters

fraction – Fraction from 0 to 1.

Returns

X amount withdrawn, Y amount withdrawn

class strategy.positions.UniV3Position(name: str, lower_price: float, upper_price: float, fee_percent: float, rebalance_cost: float)

UniV3Position is a class corresponding to one open UniswapV3 interval. It’s defined by lower and upper bounds lower_price, upper_price and pool fee percent fee_percent.

name

Unique name for the position

lower_price

Lower bound of the interval (price)

upper_price

Upper bound of the interval (price)

fee_percent

Amount of fee expressed as a percentage

rebalance_cost

Rebalancing cost, expressed in currency

burn(liq: float, price: float) Tuple[float, float]

Burn some liquidity from UniswapV3 position.

Parameters
  • liq – Value of liquidity to burn.

  • price – Current price of X in Y currency.

Returns

(X received after burn, Y received after burn).

charge_fees(price_0: float, price_1: float)

Charge exchange fees.

Parameters
  • price_0 – Price before exchange.

  • price_1 – Price after exchange.

collect_fees() Tuple[float, float]

Collect all gained fees.

Returns

Value of X fees, value of Y fees.

deposit(x: float, y: float, price: float) None

Deposit X and Y to position.

Parameters
  • x – Value of X currency.

  • y – Value of Y currency.

  • price – Current price of X in Y currency.

impermanent_loss(price: float) Tuple[float, float]

Calculate impermanent loss separately in X and Y currencies.

Parameters

price – Current price of X in Y currency.

Returns

Value of X il, value of Y il.

impermanent_loss_to_x(price: float) float

Calculate impermanent loss denominated in X.

Parameters

price – Current price of X in Y currency.

Returns

Value of X il.

impermanent_loss_to_y(price: float) float

Calculate impermanent loss denominated in Y.

Parameters

price – Current price of X in Y currency.

Returns

Value of Y il.

mint(x: float, y: float, price: float) None

Mint X and Y to uniswapV3 interval.

Parameters
  • x – Value of X currency.

  • y – Value of Y currency.

  • price – Current price of X in Y currency.

snapshot(timestamp: datetime.datetime, price: float) dict
Get a snapshot of the position. Used in Portfolio.snapshot to create a snapshot
of the entire portfolio when backtesting.
for linking in the backtest metrics, you can to add metrics here
Parameters
  • timestamp – Timestamp of snapshot

  • price – Current price of X in Y currency

Returns: Position snapshot

swap_to_optimal(x: float, y: float, price: float) Tuple[float, float]

For price and amounts perform swap to token amounts that can be completely mint.

Parameters
  • x – number of tokens X

  • y – number of tokens X

  • price – current market price

Returns

(optimal number of tokens X, optimal number of tokens Y)

to_x(price: float) float

Get value of UniswapV3 position expessed in X.

Parameters

price – Current price of X in Y currency.

Returns

Total value of uniswapV3 position expessed in X.

to_xy(price) Tuple[float, float]

Get amount of X and amount of Y in position.

Parameters

price – Current price of X in Y currency.

Returns

amount of X and amount of Y in position.

to_y(price: float) float

Get value of UniswapV3 position expessed in Y.

Parameters

price – Current price of X in Y currency.

Returns

Total value of UniswapV3 position expessed in Y.

withdraw(price: float) Tuple[float, float]

Withdraw all liquidity from UniswapV3 position.

Parameters

price – Current price of X in Y currency.

Returns

X amount withdrawn, Y amount withdrawn

Primitives

class strategy.primitives.Fee(value)

Fee Enum class defines available fees for UniV3 pools. Currently 3 values are available: 0.05%, 0.3%, 1%. The actual enum values are fee * 1_000_000, i.e. 0.05% enum value is integer 500.

property percent: float

Returns: UniswapV3 fee in form of 0.0005, 0.003, 0.01.

property spacing: int

Returns: Tick spacing for this fee 10, 60 or 200

class strategy.primitives.Token(value)

Token represents one of mainnet tokens and contains some additional data line address and decimals. This class is ordered according to token address. E.g. Token.WBTC < Token.USDC.

property address: str

Returns: Mainnet address of the token.

property decimals: int

Returns: Decimals of the token.

class strategy.primitives.Pool(tokenA: strategy.primitives.Token, tokenB: strategy.primitives.Token, fee: strategy.primitives.Fee)

Pool represents a mainnet UniV3 pool.

tokenA

First token of the pool.

tokenB

Second token of the pool.

fee

Pool fee.

property address: str

Returns: Pool mainnet address.

property decimals_diff: int

Difference between token0 and token1 decimals. Used for conversion of price from wei to eth.

Returns

Decimal difference between Tokens.

property fee: strategy.primitives.Fee

Returns: Fee of the pool.

property l_decimals_diff: float

Used for conversion of liquidity from wei to eth.

Returns

Decimal difference between Tokens in Eth.

property name: str

Returns: Pool unique name for the pool.

property tick_diff: int

Used for conversion of tick from wei to eth.

Returns

Tick diff. tick(eth/btc) - tick(wei/satoshi)

property token0: strategy.primitives.Token

Returns: First token name.

property token1: strategy.primitives.Token

Returns: Second token name.

Strategies

class strategy.strategies.AbstractStrategy(name: Optional[str] = None)

AbstractStrategy is an abstract class for Strategies.

name

Unique name for the instance.

abstract rebalance(*args, **kwargs) Optional[str]

Rebalance implementation. :param args: Any args. :param kwargs: Any kwargs.

Returns

Name of event or None if there was no event.

UniswapUtils

class strategy.uniswap_utils.UniswapLiquidityAligner(lower_price, upper_price)

UniswapLiquidityAligner this is a class with standard uniswap V3 formulas and transformations related to liquidity on the interval.

lower_price

Left bound for the UniswapV3 interval.

upper_price

Right bound for the UniswapV3 interval.

check_xy_is_optimal(price, x, y)
Parameters
  • price – current market price

  • x – amount of X tokens

  • y – amount of Y tokens

Returns

is_optimal:

True: if given amount of X and given amount of Y token can be fully minted on given interval at given price False: otherwise

x_liq:

The amount of liquidity for the given price range and amount of tokens X

y_liq:

The amount of liquidity for the given price range and amount of tokens Y

Return type

(is_optimal, x_liq, y_liq)

liq_to_x(price, liq)
Parameters
  • price – current market price

  • liq – given amount of liquidity

Returns

The amount of token X for a given amount of liquidity and a price range

liq_to_xy(price, liq)
Parameters
  • price – current market price

  • liq – amount of liquidity to be allocated

Returns

The amount of X tokens and the amount of Y tokens that must be allocated to provide required amount of liquidity at a given interval and price

liq_to_y(price, liq)
Parameters
  • price – current market price

  • liq – given amount of liquidity

Returns

The amount of token Y for a given amount of liquidity and market price

real_price(price: float) float
Parameters

price – current price on market

Returns

real_price = y/x

x_to_liq(price, x)
Parameters
  • price – current market price

  • x – amount of X tokens

Returns

The amount of liquidity for the given price and amount of tokens X

xy_to_liq(price, x, y)
Parameters
  • price – current market price

  • x – amount of X tokens

  • y – amount of Y tokens

Returns

Maximum liquidity that can be obtained for amounts, interval and current price, without swap

y_to_liq(price, y)
Parameters
  • price – current market price

  • y – amount of Y tokens

Returns

The amount of liquidity for the given price and amount of tokens Y

Viewers

class strategy.viewers.PotrfolioViewer(portfolio_history: strategy.history.PortfolioHistory, pool: strategy.primitives.Pool, offset: int = 30)

PotrfolioViewer is class for backtest result visualisation.

portfolio_history

PortfolioHistory instance returned from backtest

pool

Pool

draw_performance_x(portfolio_df: pandas.DataFrame)

Plot portfolio value in X, portfolio APY in X.

Parameters

portfolio_df – result of PortfolioHistory.calculate_stats()

Returns

plotly plot

draw_performance_y(portfolio_df: pandas.DataFrame)

Plot portfolio value in Y, portfolio APY in Y.

Parameters

portfolio_df – result of PortfolioHistory.calculate_stats()

Returns

plotly plot

draw_portfolio()

Main function of the class. Create main plots to track portfolio behavior.

Returns: plotly plots
fig1: portfolio value in X, fees in X, IL in X
fig2: portfolio value in Y, fees in Y, IL in Y
fig3: portfolio value in X, portfolio APY in X
fig4: portfolio value in Y, portfolio APY in Y
fig5: amount of X asset in portfolio, amount of Y asset in portfolio
fig6: V@p_n in X, APY(V@p_n)
draw_portfolio_to_x(portfolio_df: polars.internals.frame.DataFrame)

Plot portfolio value in X, fees in X, IL in X. :param portfolio_df: result of PortfolioHistory.calculate_stats()

Returns

plotly plot

draw_portfolio_to_y(portfolio_df: pandas.DataFrame)

Plot portfolio value and fees in Y.

Parameters

portfolio_df – result of PortfolioHistory.calculate_stats()

Returns

plotly plot

draw_vpn_vs_hold_apy(portfolio_df: pandas.DataFrame)
Plot portfolio value in X in condition of price=last price (in code Vpn or V@p_n).
Plot APY of V@p_n. (btw APY(V@p_n in X) equals APY(V@p_n in Y))
Parameters

portfolio_df – result of PortfolioHistory.calculate_stats()

Returns

plotly plot

draw_x_y(portfolio_df: pandas.DataFrame)
Plot amount of X asset in portfolio
Plot amount of Y asset in portfolio
Parameters

portfolio_df – result of PortfolioHistory.calculate_stats()

Returns

plotly plot

class strategy.viewers.UniswapViewer(uni_postition_history: strategy.history.UniPositionsHistory)

UniswapViewer is class for visualizing UniswapV3 intervals in time.

uni_postition_history

Uniswap positions history instance.

draw_intervals(swaps_df)

Plot price and uniswap positions intervals in time.

Parameters

swaps_df – UniswapV3 exchange data.

Returns

Plot with UniswapV3 position intervals.

class strategy.viewers.RebalanceViewer(rebalance_history: strategy.history.RebalanceHistory)

RebalanceViewer class to visualize actions (rebalances) other than None that occurred during the backtest.

rebalance_history

RebalanceHistory instance returned from backtest.

draw_rebalances(swaps_df: pandas.DataFrame)

Draws a price chart with portfolio action points.

Parameters

swaps_df – price data. [(timestamp, price)].

Returns

Plot with portfolio actions.

class strategy.viewers.LiquidityViewer(pool_data: strategy.data.PoolDataUniV3)

LiquidityViewer is class for liquidity visualisation.

draw_plot()

Plot liquidity and price in pool in time.

Returns

Plot with Pool liquidity and price.