Synthetic data w/stop loss backtesting example#
This is an example notebook how to create and run backtests where stop loss is being used. It is based on synthetic EMA example.
Synthetic trading data is used, as the purpose of this notebook is show how to stop loss functions
Stop loss is set to 95% when a position is opened with open_1x_long
Set up#
Set up strategy paramets that will decide its behavior
[1]:
import datetime
import pandas as pd
from tradingstrategy.chain import ChainId
from tradingstrategy.timebucket import TimeBucket
from tradeexecutor.strategy.cycle import CycleDuration
from tradeexecutor.strategy.strategy_module import TradeRouting, ReserveCurrency
trading_strategy_cycle = CycleDuration.cycle_1d
# Strategy keeps its cash in BUSD
reserve_currency = ReserveCurrency.busd
# How much of the cash to put on a single trade
position_size = 0.10
#
# Strategy thinking specific parameter
#
slow_ema_candle_count = 20
fast_ema_candle_count = 5
# How many candles to extract from the dataset once
batch_size = 90
# Set stop loss to 5% of opening price
stop_loss_pct = 0.95
# Range of backtesting and synthetic data generation.
# Because we are using synthetic data actual dates do not really matter -
# only the duration
start_at = datetime.datetime(2021, 6, 1)
start_at_data = datetime.datetime(2021,1,1)
end_at = datetime.datetime(2022, 1, 1)
Strategy logic and trade decisions#
decide_trades
function decide what trades to take. In this example, we calculate two exponential moving averages (EMAs) and make decisions based on those.
[2]:
from typing import List, Dict
from pandas_ta.overlap import ema
from tradingstrategy.universe import Universe
from tradeexecutor.state.visualisation import PlotKind
from tradeexecutor.state.trade import TradeExecution
from tradeexecutor.strategy.pricing_model import PricingModel
from tradeexecutor.strategy.pandas_trader.position_manager import PositionManager
from tradeexecutor.state.state import State
def decide_trades(
timestamp: pd.Timestamp,
universe: Universe,
state: State,
pricing_model: PricingModel,
cycle_debug_data: Dict) -> List[TradeExecution]:
"""The brain function to decide the trades on each trading strategy cycle."""
# The pair we are trading
pair = universe.pairs.get_single()
# How much cash we have in the hand
cash = state.portfolio.get_current_cash()
# Get OHLCV candles for our trading pair as Pandas Dataframe.
# We could have candles for multiple trading pairs in a different strategy,
# but this strategy only operates on single pair candle.
# We also limit our sample size to N latest candles to speed up calculations.
candles: pd.DataFrame = universe.candles.get_single_pair_data(timestamp, sample_count=batch_size)
# We have data for open, high, close, etc.
# We only operate using candle close values in this strategy.
close = candles["close"]
# Calculate exponential moving averages based on slow and fast sample numbers.
# https://github.com/twopirllc/pandas-ta
# https://github.com/twopirllc/pandas-ta/blob/bc3b292bf1cc1d5f2aba50bb750a75209d655b37/pandas_ta/overlap/ema.py#L7
slow_ema_series = ema(close, length=slow_ema_candle_count)
fast_ema_series = ema(close, length=fast_ema_candle_count)
if slow_ema_series is None or fast_ema_series is None:
# Cannot calculate EMA, because
# not enough samples in backtesting
return []
slow_ema = slow_ema_series.iloc[-1]
fast_ema = fast_ema_series.iloc[-1]
# Get the last close price from close time series
# that's Pandas's Series object
# https://pandas.pydata.org/docs/reference/api/pandas.Series.iat.html
current_price = close.iloc[-1]
# List of any trades we decide on this cycle.
# Because the strategy is simple, there can be
# only zero (do nothing) or 1 (open or close) trades
# decides
trades = []
# Create a position manager helper class that allows us easily to create
# opening/closing trades for different positions
position_manager = PositionManager(timestamp, universe, state, pricing_model)
if not position_manager.is_any_open():
if current_price >= slow_ema:
# Entry condition:
# Close price is higher than the slow EMA
buy_amount = cash * position_size
trades += position_manager.open_1x_long(pair, buy_amount, stop_loss_pct=stop_loss_pct)
else:
if fast_ema >= slow_ema:
# Exit condition:
# Fast EMA crosses slow EMA
trades += position_manager.close_all()
# Visualize strategy
# See available Plotly colours here
# https://community.plotly.com/t/plotly-colours-list/11730/3?u=miohtama
visualisation = state.visualisation
visualisation.plot_indicator(timestamp, "Slow EMA", PlotKind.technical_indicator_on_price, slow_ema, colour="darkblue")
visualisation.plot_indicator(timestamp, "Fast EMA", PlotKind.technical_indicator_on_price, fast_ema, colour="#003300")
return trades
Defining trading universe#
We create a trading universe with a single blockchain, exchange and trading pair. For the sake of easier understanding the code, we name this “Uniswap v2” like exchange with a single ETH-USDC trading pair.
The trading pair contains generated noise-like OHLCV trading data.
[3]:
import random
from tradeexecutor.state.identifier import AssetIdentifier, TradingPairIdentifier
from tradingstrategy.candle import GroupedCandleUniverse
from tradeexecutor.testing.synthetic_ethereum_data import generate_random_ethereum_address
from tradeexecutor.testing.synthetic_exchange_data import generate_exchange
from tradeexecutor.testing.synthetic_price_data import generate_ohlcv_candles
from tradeexecutor.strategy.trading_strategy_universe import TradingStrategyUniverse, \
create_pair_universe_from_code
def create_trading_universe() -> TradingStrategyUniverse:
# Set up fake assets
mock_chain_id = ChainId.ethereum
mock_exchange = generate_exchange(
exchange_id=random.randint(1, 1000),
chain_id=mock_chain_id,
address=generate_random_ethereum_address())
usdc = AssetIdentifier(ChainId.ethereum.value, generate_random_ethereum_address(), "USDC", 6, 1)
weth = AssetIdentifier(ChainId.ethereum.value, generate_random_ethereum_address(), "WETH", 18, 2)
weth_usdc = TradingPairIdentifier(weth, usdc, generate_random_ethereum_address(), mock_exchange.address, internal_id=random.randint(1, 1000), internal_exchange_id=mock_exchange.exchange_id, fee=0.0005)
time_bucket = TimeBucket.d1
pair_universe = create_pair_universe_from_code(mock_chain_id, [weth_usdc])
# Generate candle data with 15% daily movement
candles = generate_ohlcv_candles(
time_bucket,
start_at_data,
end_at,
pair_id=weth_usdc.internal_id,
daily_drift=(0.85, 1.15)
)
candle_universe = GroupedCandleUniverse.create_from_single_pair_dataframe(candles, time_bucket)
universe = Universe(
time_bucket=time_bucket,
chains={mock_chain_id},
exchanges={mock_exchange},
pairs=pair_universe,
candles=candle_universe,
liquidity=None
)
# As we are using synthetic data,
# we need to slip in stop loss data feed.
# In this case, it is the same as normal price feed,
# but usually should be finer granularity than our strategy candles.
# E.g. if strategy candles are 1h you can use 15m candles for stop loss.
return TradingStrategyUniverse(
universe=universe,
reserve_assets=[usdc],
backtest_stop_loss_time_bucket=universe.candles.time_bucket,
backtest_stop_loss_candles=universe.candles,
)
Running the backtest#
Run backtest using giving trading universe and strategy function.
Running the backtest outputs state
object that contains all the information on the backtesting position and trades.
[4]:
from tradeexecutor.testing.synthetic_exchange_data import generate_simple_routing_model
from tradeexecutor.backtest.backtest_runner import run_backtest_inline
universe = create_trading_universe()
# Check that synthetic trading data has price feed
# to check stop losses
assert universe.has_stop_loss_data()
start_candle, end_candle = universe.universe.candles.get_timestamp_range()
print(f"Our universe has synthetic candle data for the period {start_candle} - {end_candle}")
state, universe, debug_dump = run_backtest_inline(
name="Stop loss example with synthetic data",
start_at=start_at,
end_at=end_at,
client=None, # None of downloads needed, because we are using synthetic data
cycle_duration=trading_strategy_cycle,
decide_trades=decide_trades,
universe=universe,
initial_deposit=10_000,
reserve_currency=ReserveCurrency.busd,
trade_routing=TradeRouting.user_supplied_routing_model,
routing_model=generate_simple_routing_model(universe),
)
Our universe has synthetic candle data for the period 2021-01-01 00:00:00 - 2021-12-31 00:00:00
Examine backtest results#
Examine state
that contains all actions the trade executor took.
We plot out a chart that shows - The price action - When the strategy made buys or sells - When sell was a stop loss sell
[5]:
print(f"Positions taken: {len(list(state.portfolio.get_all_positions()))}")
print(f"Trades made: {len(list(state.portfolio.get_all_trades()))}")
stop_loss_trades = [t for t in state.portfolio.get_all_trades() if t.is_stop_loss()]
print(f"Trades w/stop loss triggered: {len(stop_loss_trades)}")
Positions taken: 89
Trades made: 178
Trades w/stop loss triggered: 27
[6]:
from tradeexecutor.visual.single_pair import visualise_single_pair
figure = visualise_single_pair(state, universe.universe.candles)
figure.show()
[7]:
# Set Jupyter Notebook output mode parameters
# Used to avoid warnings
from tradeexecutor.backtest.notebook import setup_charting_and_output
setup_charting_and_output()
# Needed to improve the resolution of matplotlib chart used here
%config InlineBackend.figure_format = 'svg'
from tradeexecutor.visual.equity_curve import calculate_equity_curve, calculate_returns
from tradeexecutor.visual.equity_curve import visualise_equity_curve
curve = calculate_equity_curve(state)
returns = calculate_returns(curve)
visualise_equity_curve(returns)
[7]:
Returns monthly breakdown#
Monthly returns
Best day/week/month/year
[8]:
from tradeexecutor.visual.equity_curve import visualise_returns_over_time
visualise_returns_over_time(returns)
[8]:
Benchmarking the strategy performance#
Here we benchmark the strategy performance against some baseline scenarios.
Buy and hold US dollar
Buy and hold the underlying trading pair base asset
[9]:
close = universe.universe.candles.get_single_pair_data()["close"]
[10]:
from tradeexecutor.visual.benchmark import visualise_benchmark
traded_pair = universe.universe.pairs.get_single()
fig = visualise_benchmark(
state.name,
portfolio_statistics=state.stats.portfolio,
all_cash=state.portfolio.get_initial_deposit(),
buy_and_hold_asset_name=traded_pair.base_token_symbol,
buy_and_hold_price_series=universe.universe.candles.get_single_pair_data()["close"],
)
fig.show()
Analysing the strategy success#
Here we calculate statistics on how well the strategy performed.
Won/lost trades
Timeline of taken positions with color coding of trade performance
[11]:
from tradeexecutor.analysis.trade_analyser import build_trade_analysis
analysis = build_trade_analysis(state.portfolio)
Strategy summary#
Overview of strategy performance
[12]:
from IPython.core.display_functions import display
summary = analysis.calculate_summary_statistics(TimeBucket.d1, state)
with pd.option_context("display.max_row", None):
summary.display()
Returns | |
---|---|
Annualised return % | 10.80% |
Lifetime return % | 6.30% |
Realised PnL | $630.02 |
Trade period | 213 days 0 hours |
Holdings | |
---|---|
Total assets | $10,630.02 |
Cash left | $10,630.02 |
Open position value | $0.00 |
Open positions | 0 |
Winning | Losing | Total | |
---|---|---|---|
Closed Positions | |||
Number of positions | 50 | 39 | 89 |
% of total | 56.18% | 43.82% | 100.00% |
Average PnL % | 7.04% | -7.37% | 0.72% |
Median PnL % | 6.81% | -6.14% | 1.16% |
Biggest PnL % | 14.76% | -14.98% | - |
Average duration | 1 bars | 1 bars | 1 bars |
Max consecutive streak | 5 | 4 | - |
Max runup / drawdown | 9.65% | -4.40% | - |
Stop losses | Take profits | |
---|---|---|
Position Exits | ||
Triggered exits | 27 | 0 |
Percent winning | 0.00% | - |
Percent losing | 100.00% | - |
Percent of total | 30.34% | 0.00% |
Risk Analysis | |
---|---|
Biggest realized risk | 0.50% |
Average realized risk | -0.74% |
Max pullback of capital | -4.04% |
Sharpe Ratio | 104.48% |
Sortino Ratio | 156.59% |
Profit Factor | 121.46% |
Performance metrics#
Here is an example how to use Quantstats library to calculate the tearsheet metrics for the strategy with advanced metrics. The metrics include popular risk-adjusted return comparison metrics.
This includes metrics like:
Sharpe
Sortino
Max drawdown
Note: These metrics are based on equity curve and returns. Analysis here does not go down to the level of an individual trade or a position. Any consecutive wins and losses are measured in days, not in trade or candle counts.
[13]:
from tradeexecutor.visual.equity_curve import calculate_equity_curve, calculate_returns
from tradeexecutor.analysis.advanced_metrics import visualise_advanced_metrics, AdvancedMetricsMode
equity = calculate_equity_curve(state)
returns = calculate_returns(equity)
metrics = visualise_advanced_metrics(returns, mode=AdvancedMetricsMode.full)
with pd.option_context("display.max_row", None):
display(metrics)
Strategy | |
---|---|
Start Period | 2021-06-01 |
End Period | 2021-12-31 |
Risk-Free Rate | 0.0% |
Time in Market | 77.0% |
Cumulative Return | 6.31% |
CAGR﹪ | 11.06% |
Sharpe | 1.04 |
Prob. Sharpe Ratio | 78.8% |
Smart Sharpe | 0.93 |
Sortino | 1.57 |
Smart Sortino | 1.39 |
Sortino/√2 | 1.11 |
Smart Sortino/√2 | 0.98 |
Omega | 1.21 |
Max Drawdown | -4.4% |
Longest DD Days | 75 |
Volatility (ann.) | 10.52% |
Calmar | 2.51 |
Skew | 0.08 |
Kurtosis | 1.58 |
Expected Daily | 0.03% |
Expected Monthly | 0.88% |
Expected Yearly | 6.31% |
Kelly Criterion | 5.75% |
Risk of Ruin | 0.0% |
Daily Value-at-Risk | -0.88% |
Expected Shortfall (cVaR) | -0.88% |
Max Consecutive Wins | 2 |
Max Consecutive Losses | 7 |
Gain/Pain Ratio | 0.21 |
Gain/Pain (1M) | 1.65 |
Payoff Ratio | 2.52 |
Profit Factor | 1.21 |
Common Sense Ratio | 1.22 |
CPC Index | 1.0 |
Tail Ratio | 1.0 |
Outlier Win Ratio | 4.17 |
Outlier Loss Ratio | 4.9 |
MTD | 2.21% |
3M | -1.41% |
6M | 5.8% |
YTD | 6.31% |
1Y | 6.31% |
3Y (ann.) | 11.06% |
5Y (ann.) | 11.06% |
10Y (ann.) | 11.06% |
All-time (ann.) | 11.06% |
Best Day | 1.49% |
Worst Day | -1.58% |
Best Month | 3.11% |
Worst Month | -3.89% |
Best Year | 6.31% |
Worst Year | 6.31% |
Avg. Drawdown | -1.14% |
Avg. Drawdown Days | 13 |
Recovery Factor | 1.44 |
Ulcer Index | 0.02 |
Serenity Index | 0.77 |
Avg. Up Month | 1.7% |
Avg. Down Month | -3.89% |
Win Days | 32.52% |
Win Month | 85.71% |
Win Quarter | 66.67% |
Win Year | 100.0% |
Position and trade timeline#
Display all positions and how much profit they made.
[14]:
from tradeexecutor.analysis.trade_analyser import expand_timeline
timeline = analysis.create_timeline()
expanded_timeline, apply_styles = expand_timeline(
universe.universe.exchanges,
universe.universe.pairs,
timeline)
# Do not truncate the row output
with pd.option_context("display.max_row", None):
display(apply_styles(expanded_timeline))
Remarks | Type | Opened at | Duration | Exchange | Base asset | Quote asset | Position max value | PnL USD | PnL % | Open mid price USD | Close mid price USD | Trade count | LP fees |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SL | Long | 2021-06-01 | 1 days | WETH | USDC | $1,000.00 | $-53.31 | -5.33% | $1,038.733888 | $983.362118 | 2 | $0.97 | |
Long | 2021-06-02 | 1 days | WETH | USDC | $994.67 | $135.96 | 13.67% | $984.345972 | $1,118.896189 | 2 | $1.06 | ||
SL | Long | 2021-06-04 | 1 days | WETH | USDC | $1,008.27 | $-77.09 | -7.65% | $1,089.178511 | $1,005.900911 | 2 | $0.97 | |
SL | Long | 2021-06-05 | 1 days | WETH | USDC | $1,000.56 | $-94.01 | -9.40% | $1,006.907315 | $912.303452 | 2 | $0.95 | |
Long | 2021-06-11 | 1 days | WETH | USDC | $991.16 | $104.67 | 10.56% | $971.047911 | $1,073.593633 | 2 | $1.04 | ||
Long | 2021-06-13 | 1 days | WETH | USDC | $1,001.62 | $91.32 | 9.12% | $1,037.029583 | $1,131.578690 | 2 | $1.05 | ||
Long | 2021-06-15 | 1 days | WETH | USDC | $1,010.75 | $142.43 | 14.09% | $1,148.099988 | $1,309.883866 | 2 | $1.08 | ||
Long | 2021-06-17 | 1 days | WETH | USDC | $1,025.00 | $-45.01 | -4.39% | $1,339.743679 | $1,280.914277 | 2 | $1.00 | ||
Long | 2021-06-19 | 1 days | WETH | USDC | $1,020.50 | $-31.79 | -3.11% | $1,260.006535 | $1,220.759206 | 2 | $1.00 | ||
SL | Long | 2021-06-21 | 1 days | WETH | USDC | $1,017.32 | $-91.29 | -8.97% | $1,219.157483 | $1,109.754553 | 2 | $0.97 | |
Long | 2021-06-23 | 1 days | WETH | USDC | $1,008.19 | $2.30 | 0.23% | $1,143.579011 | $1,146.192404 | 2 | $1.01 | ||
Long | 2021-06-25 | 1 days | WETH | USDC | $1,008.42 | $146.35 | 14.51% | $1,262.506834 | $1,445.736726 | 2 | $1.08 | ||
SL | Long | 2021-06-27 | 1 days | WETH | USDC | $1,023.05 | $-153.25 | -14.98% | $1,499.296416 | $1,274.709522 | 2 | $0.95 | |
Long | 2021-06-28 | 1 days | WETH | USDC | $1,007.73 | $-29.62 | -2.94% | $1,275.984870 | $1,238.476696 | 2 | $0.99 | ||
Long | 2021-06-30 | 1 days | WETH | USDC | $1,004.77 | $-3.20 | -0.32% | $1,326.680911 | $1,322.453181 | 2 | $1.00 | ||
Long | 2021-07-02 | 1 days | WETH | USDC | $1,004.45 | $37.91 | 3.77% | $1,382.848000 | $1,435.037168 | 2 | $1.02 | ||
Long | 2021-07-04 | 1 days | WETH | USDC | $1,008.24 | $94.27 | 9.35% | $1,558.202663 | $1,703.900389 | 2 | $1.06 | ||
Long | 2021-07-06 | 1 days | WETH | USDC | $1,017.67 | $12.48 | 1.23% | $1,585.146741 | $1,604.582636 | 2 | $1.02 | ||
Long | 2021-07-08 | 1 days | WETH | USDC | $1,018.91 | $2.12 | 0.21% | $1,598.740005 | $1,602.068093 | 2 | $1.02 | ||
Long | 2021-07-10 | 1 days | WETH | USDC | $1,019.13 | $1.17 | 0.11% | $1,533.996581 | $1,535.756736 | 2 | $1.02 | ||
SL | Long | 2021-07-12 | 1 days | WETH | USDC | $1,019.24 | $-89.94 | -8.82% | $1,492.061664 | $1,360.394095 | 2 | $0.97 | |
Long | 2021-07-17 | 1 days | WETH | USDC | $1,010.25 | $32.19 | 3.19% | $1,454.391535 | $1,500.739380 | 2 | $1.03 | ||
Long | 2021-07-22 | 1 days | WETH | USDC | $1,013.47 | $-21.74 | -2.14% | $1,528.614795 | $1,495.826996 | 2 | $1.00 | ||
Long | 2021-07-25 | 1 days | WETH | USDC | $1,011.29 | $68.17 | 6.74% | $1,550.752417 | $1,655.283075 | 2 | $1.05 | ||
Long | 2021-07-27 | 1 days | WETH | USDC | $1,018.11 | $64.81 | 6.37% | $1,670.157745 | $1,776.481218 | 2 | $1.05 | ||
SL | Long | 2021-07-29 | 1 days | WETH | USDC | $1,024.59 | $-60.75 | -5.93% | $1,639.817745 | $1,542.588992 | 2 | $0.99 | |
Long | 2021-07-30 | 1 days | WETH | USDC | $1,018.52 | $-3.35 | -0.33% | $1,544.132353 | $1,539.054073 | 2 | $1.02 | ||
Long | 2021-08-10 | 2 days | WETH | USDC | $1,018.18 | $135.22 | 13.28% | $1,380.498600 | $1,563.831445 | 2 | $1.09 | ||
Long | 2021-08-13 | 1 days | WETH | USDC | $1,031.70 | $126.88 | 12.30% | $1,743.865378 | $1,958.326698 | 2 | $1.10 | ||
SL | Long | 2021-08-15 | 1 days | WETH | USDC | $1,044.39 | $-116.86 | -11.19% | $2,057.209139 | $1,827.017945 | 2 | $0.99 | |
Long | 2021-08-16 | 1 days | WETH | USDC | $1,032.71 | $124.65 | 12.07% | $1,828.845877 | $2,049.594964 | 2 | $1.10 | ||
SL | Long | 2021-08-18 | 1 days | WETH | USDC | $1,045.17 | $-120.88 | -11.57% | $2,261.297524 | $1,999.769933 | 2 | $0.98 | |
Long | 2021-08-19 | 1 days | WETH | USDC | $1,033.08 | $41.54 | 4.02% | $2,001.770703 | $2,082.268249 | 2 | $1.05 | ||
Long | 2021-08-21 | 1 days | WETH | USDC | $1,037.24 | $39.71 | 3.83% | $2,300.471368 | $2,388.533659 | 2 | $1.06 | ||
Long | 2021-08-23 | 1 days | WETH | USDC | $1,041.21 | $27.20 | 2.61% | $2,206.648994 | $2,264.291110 | 2 | $1.06 | ||
Long | 2021-08-25 | 1 days | WETH | USDC | $1,043.93 | $-46.96 | -4.50% | $2,307.529708 | $2,203.720350 | 2 | $1.02 | ||
Long | 2021-08-27 | 1 days | WETH | USDC | $1,039.23 | $65.47 | 6.30% | $2,457.470282 | $2,612.291900 | 2 | $1.07 | ||
SL | Long | 2021-08-29 | 1 days | WETH | USDC | $1,045.78 | $-110.43 | -10.56% | $2,812.755918 | $2,515.751594 | 2 | $0.99 | |
Long | 2021-08-30 | 1 days | WETH | USDC | $1,034.74 | $108.18 | 10.45% | $2,518.268604 | $2,781.538957 | 2 | $1.09 | ||
Long | 2021-09-01 | 1 days | WETH | USDC | $1,045.55 | $150.83 | 14.43% | $3,045.816324 | $3,485.210075 | 2 | $1.12 | ||
Long | 2021-09-03 | 1 days | WETH | USDC | $1,060.64 | $64.95 | 6.12% | $3,429.406388 | $3,639.397371 | 2 | $1.09 | ||
SL | Long | 2021-09-05 | 1 days | WETH | USDC | $1,067.13 | $-133.54 | -12.51% | $3,669.825369 | $3,210.584472 | 2 | $1.00 | |
Long | 2021-09-06 | 1 days | WETH | USDC | $1,053.78 | $72.41 | 6.87% | $3,213.796662 | $3,434.625003 | 2 | $1.09 | ||
SL | Long | 2021-09-08 | 1 days | WETH | USDC | $1,061.02 | $-63.47 | -5.98% | $3,741.888557 | $3,518.058846 | 2 | $1.03 | |
Long | 2021-09-09 | 1 days | WETH | USDC | $1,054.67 | $17.02 | 1.61% | $3,521.578664 | $3,578.404981 | 2 | $1.06 | ||
SL | Long | 2021-09-11 | 1 days | WETH | USDC | $1,056.37 | $-126.21 | -11.95% | $3,886.763491 | $3,422.394029 | 2 | $0.99 | |
Long | 2021-09-12 | 1 days | WETH | USDC | $1,043.75 | $151.62 | 14.53% | $3,425.818135 | $3,923.463888 | 2 | $1.12 | ||
Long | 2021-09-14 | 1 days | WETH | USDC | $1,058.91 | $104.18 | 9.84% | $4,164.548167 | $4,574.282168 | 2 | $1.11 | ||
Long | 2021-09-16 | 1 days | WETH | USDC | $1,069.33 | $-50.62 | -4.73% | $4,400.766595 | $4,192.437159 | 2 | $1.04 | ||
SL | Long | 2021-09-18 | 1 days | WETH | USDC | $1,064.27 | $-65.39 | -6.14% | $4,593.148773 | $4,310.933162 | 2 | $1.03 | |
Long | 2021-09-19 | 1 days | WETH | USDC | $1,057.73 | $77.72 | 7.35% | $4,315.246252 | $4,632.331047 | 2 | $1.10 | ||
SL | Long | 2021-09-21 | 1 days | WETH | USDC | $1,065.50 | $-56.13 | -5.27% | $4,148.354476 | $3,929.825552 | 2 | $1.04 | |
Long | 2021-09-22 | 1 days | WETH | USDC | $1,059.89 | $-7.51 | -0.71% | $3,933.757343 | $3,905.890370 | 2 | $1.06 | ||
Long | 2021-09-24 | 1 days | WETH | USDC | $1,059.14 | $132.99 | 12.56% | $4,460.789041 | $5,020.888717 | 2 | $1.13 | ||
Long | 2021-09-26 | 1 days | WETH | USDC | $1,072.44 | $90.19 | 8.41% | $5,061.664027 | $5,487.349581 | 2 | $1.12 | ||
Long | 2021-09-28 | 1 days | WETH | USDC | $1,081.46 | $-32.66 | -3.02% | $5,264.740330 | $5,105.756204 | 2 | $1.07 | ||
Long | 2021-09-30 | 1 days | WETH | USDC | $1,078.19 | $59.43 | 5.51% | $5,160.125680 | $5,444.536400 | 2 | $1.11 | ||
SL | Long | 2021-10-02 | 1 days | WETH | USDC | $1,084.13 | $-147.26 | -13.58% | $4,934.306769 | $4,264.064638 | 2 | $1.01 | |
Long | 2021-10-13 | 1 days | WETH | USDC | $1,069.41 | $78.03 | 7.30% | $4,262.432327 | $4,573.425127 | 2 | $1.11 | ||
Long | 2021-10-15 | 1 days | WETH | USDC | $1,077.21 | $94.56 | 8.78% | $4,560.250759 | $4,960.555216 | 2 | $1.12 | ||
SL | Long | 2021-10-17 | 1 days | WETH | USDC | $1,086.67 | $-66.43 | -6.11% | $5,488.598251 | $5,153.063478 | 2 | $1.05 | |
SL | Long | 2021-10-18 | 1 days | WETH | USDC | $1,080.02 | $-124.06 | -11.49% | $5,158.219119 | $4,565.683263 | 2 | $1.02 | |
Long | 2021-10-19 | 1 days | WETH | USDC | $1,067.62 | $77.92 | 7.30% | $4,570.251230 | $4,903.809236 | 2 | $1.11 | ||
Long | 2021-10-21 | 1 days | WETH | USDC | $1,075.41 | $12.47 | 1.16% | $5,014.696964 | $5,072.867776 | 2 | $1.08 | ||
SL | Long | 2021-10-23 | 1 days | WETH | USDC | $1,076.66 | $-64.99 | -6.04% | $4,938.250137 | $4,640.142854 | 2 | $1.04 | |
Long | 2021-10-24 | 1 days | WETH | USDC | $1,070.16 | $14.96 | 1.40% | $4,644.785318 | $4,709.737295 | 2 | $1.08 | ||
Long | 2021-10-26 | 1 days | WETH | USDC | $1,071.65 | $20.10 | 1.88% | $4,907.738626 | $4,999.774878 | 2 | $1.08 | ||
Long | 2021-10-28 | 1 days | WETH | USDC | $1,073.66 | $127.23 | 11.85% | $5,660.187394 | $6,330.949614 | 2 | $1.14 | ||
Long | 2021-10-30 | 1 days | WETH | USDC | $1,086.39 | $-42.56 | -3.92% | $6,115.636331 | $5,876.078293 | 2 | $1.07 | ||
Long | 2021-11-01 | 1 days | WETH | USDC | $1,082.13 | $-48.27 | -4.46% | $5,593.520191 | $5,344.010907 | 2 | $1.06 | ||
SL | Long | 2021-11-08 | 1 days | WETH | USDC | $1,077.30 | $-120.71 | -11.20% | $5,519.988238 | $4,901.488134 | 2 | $1.02 | |
Long | 2021-11-12 | 1 days | WETH | USDC | $1,065.23 | $157.21 | 14.76% | $5,259.303669 | $6,035.509288 | 2 | $1.14 | ||
SL | Long | 2021-11-14 | 1 days | WETH | USDC | $1,080.95 | $-129.64 | -11.99% | $5,763.701634 | $5,072.463456 | 2 | $1.02 | |
SL | Long | 2021-11-16 | 1 days | WETH | USDC | $1,067.99 | $-71.88 | -6.73% | $5,339.000452 | $4,979.647570 | 2 | $1.03 | |
SL | Long | 2021-11-18 | 1 days | WETH | USDC | $1,060.80 | $-132.30 | -12.47% | $5,519.750911 | $4,831.339210 | 2 | $0.99 | |
SL | Long | 2021-11-25 | 2 days | WETH | USDC | $1,047.57 | $-85.83 | -8.19% | $5,009.159746 | $4,598.729368 | 2 | $1.00 | |
Long | 2021-11-28 | 1 days | WETH | USDC | $1,038.99 | $11.58 | 1.11% | $5,191.377565 | $5,249.256949 | 2 | $1.05 | ||
Long | 2021-11-30 | 1 days | WETH | USDC | $1,040.15 | $63.26 | 6.08% | $5,794.229383 | $6,146.617706 | 2 | $1.07 | ||
Long | 2021-12-02 | 1 days | WETH | USDC | $1,046.47 | $143.25 | 13.69% | $5,590.362475 | $6,355.593756 | 2 | $1.12 | ||
Long | 2021-12-04 | 1 days | WETH | USDC | $1,060.80 | $61.07 | 5.76% | $5,691.761715 | $6,019.429342 | 2 | $1.09 | ||
Long | 2021-12-06 | 1 days | WETH | USDC | $1,066.90 | $32.74 | 3.07% | $5,786.273400 | $5,963.845120 | 2 | $1.08 | ||
SL | Long | 2021-12-08 | 1 days | WETH | USDC | $1,070.18 | $-56.87 | -5.31% | $6,317.561909 | $5,981.812956 | 2 | $1.04 | |
Long | 2021-12-09 | 1 days | WETH | USDC | $1,064.49 | $98.46 | 9.25% | $5,987.797762 | $6,541.628419 | 2 | $1.11 | ||
SL | Long | 2021-12-11 | 1 days | WETH | USDC | $1,074.34 | $-116.95 | -10.89% | $6,535.857547 | $5,824.387220 | 2 | $1.02 | |
Long | 2021-12-12 | 1 days | WETH | USDC | $1,062.64 | $11.30 | 1.06% | $5,830.214520 | $5,892.227701 | 2 | $1.07 | ||
Long | 2021-12-14 | 1 days | WETH | USDC | $1,063.77 | $20.48 | 1.93% | $6,225.055971 | $6,344.905057 | 2 | $1.07 | ||
Long | 2021-12-18 | 1 days | WETH | USDC | $1,065.82 | $31.24 | 2.93% | $5,896.996175 | $6,069.848152 | 2 | $1.08 | ||
SL | Long | 2021-12-21 | 1 days | WETH | USDC | $1,068.94 | $-136.46 | -12.77% | $6,232.739865 | $5,437.066801 | 2 | $1.00 | |
Long | 2021-12-29 | 2 days | WETH | USDC | $1,055.30 | $77.03 | 7.30% | $5,610.205605 | $6,019.736085 | 2 | $1.09 |
Finishing notes#
Print out a line to signal the notebook finished the execution successfully.
[15]:
print("All ok")
All ok