Double 7#

This is an example of an automated trading strategy how to trade on a single trading pair using daily closes and moving averages.

  • You can read more about the strategy on the The Chartist explanation page.

  • The strategy trades a single chosen token pair, in our case ETH-USD (using USDC stablecoin).

  • The strategy trades on Sushiswap and on Ethereum mainnet.

  • The backtesting is done using Backtrader backtesting framework.

  • The strategy is converted to Backtrader from its original Pine Script implementation.

  • Based on the backtesting, the strategy is real-life profitable.

  • The chosen parameters (50 days moving average, 7 days high, 7 days close, daily candles) were arbitrarily chosen and might be unfit for the crypto markets directly as such. It is necessary to modify and test a suitable timeframe and MA configuration for your chosen trading pair.

  • In this backtesting run, we do not consider transaction fees, trading fees or slippage for the sake of simplicity.

The original Double 7 Pine Script implementation#

Below is the original Double 7 Pine Script implementation that this strategy is based on.

//@version=4
strategy("Double 7's Strat.v1", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)

value1=input(7, title="Quantity of day low")
value2=input(7, title="Quantity of day high")
entry=lowest(close[1],value1)
exit=highest(close[1],value2)

mma100=sma(close,100)

plot(entry, title = '7 day low', color = color.blue,   linewidth = 1, style = plot.style_linebr)  // plot 7 day low
plot(exit, title = '7 day high', color = color.purple,   linewidth = 1, style = plot.style_linebr)  // plot 7 day high
plot(mma100, title = 'MMA100', color = color.orange,   linewidth = 2, style = plot.style_line)  // plot MMA100

//Stop Loss input setting
longLossPerc = input(title="Long Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=1) * 0.01

// Determine stop loss price
longStopPrice  = strategy.position_avg_price * (1 - longLossPerc)

// Plot stop loss values for confirmation
plot(series=(strategy.position_size > 0) ? longStopPrice : na, color=color.red, style=plot.style_linebr, linewidth=2, title="Long Stop Loss")

// Test Period
testStartYear = input(2021, "Backtest Start Year")
testStartMonth = input(5, "Backtest Start Month")
testStartDay = input(17, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2022, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false

if testPeriod()
    if (close>mma100) and (close<entry)
        strategy.entry("RsiLE", strategy.long , comment="Open")

    if (close>exit)
        strategy.close_all()

// Submit exit orders based on calculated stop loss price
if (strategy.position_size > 0)
    strategy.exit(id="XL STOP", stop=longStopPrice)

Strategy and backtesting parameters#

Here we define all parameters that affect the backtesting outcome.

[1]:
import datetime

import pandas as pd
from tradingstrategy.timebucket import TimeBucket
from tradingstrategy.chain import ChainId

# Which pair we analyse
# https://analytics.sushi.com/pairs/0x06da0fd433c1a5d7a4faa01111c044910a184553
TARGET_PAIR = ("WETH", "USDC")

# The backtest only consider Ethereum mainnet
BLOCKCHAIN = ChainId.ethereum

# The backtest only considers Sushiswap v2 exchange
EXCHANGE = "sushi"

# Use daily candles for backtesting
CANDLE_KIND = TimeBucket.d1

# The moving average must be above of this number for us to buy
MOVING_AVERAGE_CANDLES = 50

# How many previous candles we sample for the low close value
LOW_CANDLES = 7

# How many previous candles we sample for the high close value
HIGH_CANDLES = 7

# If the price drops 5% we trigger a stop loss
STOP_LOSS = 0.95

# When do we start the backtesting - limit the candle set from the data dump from the server
BACKTESTING_BEGINS = pd.Timestamp("2020-10-1")

# When do we end backtesting
BACKTESTING_ENDS = pd.Timestamp("2021-09-1")

Initialising the Trading Strategy client#

This step will install necessary Python packages and the needed API keys.

[2]:
try:
    import tradingstrategy
except ImportError:
    %pip install trading-strategy
    import site
    site.main()

from tradingstrategy.client import Client

client = Client.create_jupyter_client()
Started Trading Strategy in Jupyter notebook environment, configuration is stored in /Users/moo/.tradingstrategy

Creating the strategy#

Here is the strategy defined for Backtrader.

[3]:
import backtrader as bt
from backtrader import indicators


class Double7(bt.Strategy):
    """An example of double-7 strategy for DEX spot trading.

    The original description: https://www.thechartist.com.au/double-7-s-strategy/
    """

    def start(self):
        # Set up indicators used in this strategy

        # Moving average that tells us when we are in the bull market
        self.moving_average = indicators.SMA(period=MOVING_AVERAGE_CANDLES)

        # The highest close price for the N candles
        # "exit" in pine script
        self.highest = indicators.Highest(self.data.close, period=HIGH_CANDLES, plot=False)

        # The lowest close price for the N candles
        # "entry" in pine script
        self.lowest = indicators.Lowest(self.data.close, period=LOW_CANDLES, plot=False)

        # Count ticks and some basic testing metrics
        self.ticks = self.enters = self.exits = 0

    def next(self):
        """Execute a decision making tick for each candle."""

        self.ticks += 1

        # Get the last value of the current candle close and indicators
        # More about self.data and self.lines of Backtrader
        # https://github.com/backtrader/backtrader-docs/blob/master/docs/concepts.rst#indexing-0-and--1
        # https://www.fatalerrors.org/a/backtrader-3-core-concept-lines.html.
        # Note that the value can be "nan" if we have not ticked enough days and
        # e.g. the moving average cannot be calculated.
        # Zero means "today" or the indicator value at the current candle.
        # Minus one means "yesterday" or the indicator value at the previous candle.
        # (Indexing might be different from the pine script)
        close = self.data.close[0]
        low = self.lowest[-1]
        high = self.highest[-1]
        avg = self.moving_average[0]

        # Print debug logs so that analysing the strategy internal thinking is easier
        print(f"Tick: {self.ticks}, close: {close}, avg: {avg}, low: {low}, high: {high}")

        if not all([close, low, high, avg]):
            # Do not try to make any decision if we have nan or zero data
            return

        # Enter when we are above moving average and the daily close was
        if close >= avg and close <= low and not self.position:
            print("Entered to a position")
            self.buy()

        # If the price closes above its 7 day high, exit from the markets
        if close >= high and self.position:
            print("Exited the position")
            self.close()

Setting up the strategy backtest#

This set ups the data sources and plumping for running the backtest (“boilerplate” in software development terms).

[4]:
from backtrader import analyzers

from tradingstrategy.chain import ChainId
from tradingstrategy.frameworks.backtrader import prepare_candles_for_backtrader, add_dataframes_as_feeds
from tradingstrategy.pair import PandasPairUniverse


# Operate on daily candles
strategy_time_bucket = CANDLE_KIND

exchange_universe = client.fetch_exchange_universe()
columnar_pair_table = client.fetch_pair_universe()
all_pairs_dataframe = columnar_pair_table.to_pandas()
pair_universe = PandasPairUniverse(all_pairs_dataframe)

# Filter down to pairs that only trade on Sushiswap
sushi_swap = exchange_universe.get_by_chain_and_slug(ChainId.ethereum, EXCHANGE)
pair = pair_universe.get_one_pair_from_pandas_universe(
    sushi_swap.exchange_id,
    TARGET_PAIR[0],
    TARGET_PAIR[1])

all_candles = client.fetch_all_candles(strategy_time_bucket).to_pandas()
pair_candles: pd.DataFrame = all_candles.loc[all_candles["pair_id"] == pair.pair_id]
pair_candles = prepare_candles_for_backtrader(pair_candles)

# We limit candles to a specific date range to make this notebook deterministic
pair_candles = pair_candles[(pair_candles.index >= BACKTESTING_BEGINS) & (pair_candles.index <= BACKTESTING_ENDS)]

print(f"Dataset size is {len(pair_candles)} candles")

# This strategy requires data for 100 days. Because we are operating on new exchanges,
# there simply might not be enough data there
assert len(pair_candles) > MOVING_AVERAGE_CANDLES, "We do not have enough data to execute the strategy"

# Create the Backtrader back testing engine "Cebebro"
cerebro = bt.Cerebro(stdstats=True)

# Add out strategy
cerebro.addstrategy(Double7)

# Add two analyzers for the strategy performance
# cerebro.addobserver(bt.observers.Value)
cerebro.addanalyzer(bt.analyzers.SharpeRatio, riskfreerate=0.0)
cerebro.addanalyzer(bt.analyzers.Returns)
cerebro.addanalyzer(bt.analyzers.DrawDown)



# Add our ETH-USDC price feed
add_dataframes_as_feeds(
    cerebro,
    pair_universe,
    [pair_candles],
    BACKTESTING_BEGINS,
    BACKTESTING_ENDS,
    strategy_time_bucket,
    plot=True)

Dataset size is 336 candles

Running the backtest#

Now when everything has been set up we execute the backtest. Because the dataset is small (~300 candles) this takes a fraction of a second.

[5]:
results = cerebro.run()
Tick: 1, close: 352.85247802734375, avg: nan, low: 3093.651123046875, high: 3815.57666015625
Tick: 2, close: 346.1255187988281, avg: nan, low: nan, high: nan
Tick: 3, close: 348.4530334472656, avg: nan, low: nan, high: nan
Tick: 4, close: 350.6174011230469, avg: nan, low: nan, high: nan
Tick: 5, close: 351.46832275390625, avg: nan, low: nan, high: nan
Tick: 6, close: 338.0306396484375, avg: nan, low: nan, high: nan
Tick: 7, close: 339.6888427734375, avg: nan, low: nan, high: nan
Tick: 8, close: 351.3641357421875, avg: nan, low: 338.0306396484375, high: 352.85247802734375
Tick: 9, close: 365.0035705566406, avg: nan, low: 338.0306396484375, high: 351.46832275390625
Tick: 10, close: 370.5841979980469, avg: nan, low: 338.0306396484375, high: 365.0035705566406
Tick: 11, close: 372.5084533691406, avg: nan, low: 338.0306396484375, high: 370.5841979980469
Tick: 12, close: 389.1968994140625, avg: nan, low: 338.0306396484375, high: 372.5084533691406
Tick: 13, close: 380.4424133300781, avg: nan, low: 338.0306396484375, high: 389.1968994140625
Tick: 14, close: 379.4508972167969, avg: nan, low: 339.6888427734375, high: 389.1968994140625
Tick: 15, close: 379.3881530761719, avg: nan, low: 351.3641357421875, high: 389.1968994140625
Tick: 16, close: 365.28955078125, avg: nan, low: 365.0035705566406, high: 389.1968994140625
Tick: 17, close: 367.0792236328125, avg: nan, low: 365.28955078125, high: 389.1968994140625
Tick: 18, close: 377.9938659667969, avg: nan, low: 365.28955078125, high: 389.1968994140625
Tick: 19, close: 379.7020568847656, avg: nan, low: 365.28955078125, high: 389.1968994140625
Tick: 20, close: 369.9563903808594, avg: nan, low: 365.28955078125, high: 380.4424133300781
Tick: 21, close: 394.1260070800781, avg: nan, low: 365.28955078125, high: 379.7020568847656
Tick: 22, close: 415.82427978515625, avg: nan, low: 365.28955078125, high: 394.1260070800781
Tick: 23, close: 410.3772888183594, avg: nan, low: 365.28955078125, high: 415.82427978515625
Tick: 24, close: 412.2218933105469, avg: nan, low: 367.0792236328125, high: 415.82427978515625
Tick: 25, close: 405.1052551269531, avg: nan, low: 369.9563903808594, high: 415.82427978515625
Tick: 26, close: 393.24267578125, avg: nan, low: 369.9563903808594, high: 415.82427978515625
Tick: 27, close: 403.2445068359375, avg: nan, low: 369.9563903808594, high: 415.82427978515625
Tick: 28, close: 389.14141845703125, avg: nan, low: 393.24267578125, high: 415.82427978515625
Tick: 29, close: 385.8215026855469, avg: nan, low: 389.14141845703125, high: 415.82427978515625
Tick: 30, close: 384.2471008300781, avg: nan, low: 385.8215026855469, high: 412.2218933105469
Tick: 31, close: 387.9945983886719, avg: nan, low: 384.2471008300781, high: 412.2218933105469
Tick: 32, close: 396.5770568847656, avg: nan, low: 384.2471008300781, high: 405.1052551269531
Tick: 33, close: 384.9324645996094, avg: nan, low: 384.2471008300781, high: 403.2445068359375
Tick: 34, close: 387.4696350097656, avg: nan, low: 384.2471008300781, high: 403.2445068359375
Tick: 35, close: 402.2596130371094, avg: nan, low: 384.2471008300781, high: 396.5770568847656
Tick: 36, close: 415.2890930175781, avg: nan, low: 384.2471008300781, high: 402.2596130371094
Tick: 37, close: 455.32965087890625, avg: nan, low: 384.2471008300781, high: 415.2890930175781
Tick: 38, close: 435.92938232421875, avg: nan, low: 384.9324645996094, high: 455.32965087890625
Tick: 39, close: 456.748291015625, avg: nan, low: 384.9324645996094, high: 455.32965087890625
Tick: 40, close: 445.5915832519531, avg: nan, low: 384.9324645996094, high: 456.748291015625
Tick: 41, close: 450.336181640625, avg: nan, low: 387.4696350097656, high: 456.748291015625
Tick: 42, close: 463.547119140625, avg: nan, low: 402.2596130371094, high: 456.748291015625
Tick: 43, close: 461.580322265625, avg: nan, low: 415.2890930175781, high: 463.547119140625
Tick: 44, close: 477.6199645996094, avg: nan, low: 435.92938232421875, high: 463.547119140625
Tick: 45, close: 463.12646484375, avg: nan, low: 435.92938232421875, high: 477.6199645996094
Tick: 46, close: 450.431640625, avg: nan, low: 445.5915832519531, high: 477.6199645996094
Tick: 47, close: 461.0333251953125, avg: nan, low: 445.5915832519531, high: 477.6199645996094
Tick: 48, close: 483.56475830078125, avg: nan, low: 450.336181640625, high: 477.6199645996094
Tick: 49, close: 480.4100036621094, avg: nan, low: 450.431640625, high: 483.56475830078125
Tick: 50, close: 471.991455078125, avg: 402.00621154785154, low: 450.431640625, high: 483.56475830078125
Tick: 51, close: 507.19659423828125, avg: 405.0930938720703, low: 450.431640625, high: 483.56475830078125
Tick: 52, close: 552.5305786132812, avg: 409.22119506835935, low: 450.431640625, high: 507.19659423828125
Tick: 53, close: 561.4409790039062, avg: 413.4809539794922, low: 450.431640625, high: 552.5305786132812
Tick: 54, close: 609.0250244140625, avg: 418.6491064453125, low: 461.0333251953125, high: 561.4409790039062
Tick: 55, close: 601.781005859375, avg: 423.65536010742187, low: 471.991455078125, high: 609.0250244140625
Tick: 56, close: 569.49560546875, avg: 428.28465942382815, low: 471.991455078125, high: 609.0250244140625
Tick: 57, close: 520.6714477539062, avg: 431.9043115234375, low: 471.991455078125, high: 609.0250244140625
Tick: 58, close: 518.4671630859375, avg: 435.2463720703125, low: 507.19659423828125, high: 609.0250244140625
Tick: 59, close: 539.7708129882812, avg: 438.7417169189453, low: 518.4671630859375, high: 609.0250244140625
Tick: 60, close: 575.6941528320312, avg: 442.843916015625, low: 518.4671630859375, high: 609.0250244140625
Tick: 61, close: 616.2930908203125, avg: 447.71960876464846, low: 518.4671630859375, high: 609.0250244140625
Tick: 62, close: 589.916259765625, avg: 451.7339959716797, low: 518.4671630859375, high: 616.2930908203125
Tick: 63, close: 597.0772705078125, avg: 456.0666931152344, low: 518.4671630859375, high: 616.2930908203125
Tick: 64, close: 616.1817626953125, avg: 460.8013104248047, low: 518.4671630859375, high: 616.2930908203125
Tick: 65, close: 571.200927734375, avg: 464.63756591796874, low: 518.4671630859375, high: 616.2930908203125
Tick: 66, close: 596.9078369140625, avg: 469.269931640625, low: 539.7708129882812, high: 616.2930908203125
Tick: 67, close: 603.2041015625, avg: 473.99242919921875, low: 571.200927734375, high: 616.2930908203125
Tick: 68, close: 589.9231567382812, avg: 478.23101501464845, low: 571.200927734375, high: 616.2930908203125
Tick: 69, close: 555.0480346679688, avg: 481.7379345703125, low: 571.200927734375, high: 616.1817626953125
Entered to a position
Tick: 70, close: 572.978515625, avg: 485.79837707519533, low: 555.0480346679688, high: 616.1817626953125
Tick: 71, close: 558.1599731445312, avg: 489.07905639648436, low: 555.0480346679688, high: 616.1817626953125
Tick: 72, close: 544.4681396484375, avg: 491.65193359375, low: 555.0480346679688, high: 603.2041015625
Tick: 73, close: 567.8553466796875, avg: 494.8014947509766, low: 544.4681396484375, high: 603.2041015625
Tick: 74, close: 590.3077392578125, avg: 498.3632116699219, low: 544.4681396484375, high: 603.2041015625
Tick: 75, close: 584.9246826171875, avg: 501.95960021972655, low: 544.4681396484375, high: 590.3077392578125
Tick: 76, close: 590.76904296875, avg: 505.9101275634766, low: 544.4681396484375, high: 590.3077392578125
Exited the position
Tick: 77, close: 639.3394775390625, avg: 510.63202697753906, low: 544.4681396484375, high: 590.76904296875
Tick: 78, close: 640.6546630859375, avg: 515.6622918701172, low: 544.4681396484375, high: 639.3394775390625
Tick: 79, close: 654.8704833984375, avg: 521.043271484375, low: 544.4681396484375, high: 640.6546630859375
Tick: 80, close: 661.98388671875, avg: 526.5980072021484, low: 567.8553466796875, high: 654.8704833984375
Tick: 81, close: 636.841064453125, avg: 531.5749365234375, low: 584.9246826171875, high: 661.98388671875
Tick: 82, close: 608.44970703125, avg: 535.8123895263672, low: 584.9246826171875, high: 661.98388671875
Tick: 83, close: 635.9616088867188, avg: 540.8329724121094, low: 590.76904296875, high: 661.98388671875
Tick: 84, close: 582.2228393554688, avg: 544.7280364990235, low: 608.44970703125, high: 661.98388671875
Entered to a position
Tick: 85, close: 613.4778442382812, avg: 548.9524011230469, low: 582.2228393554688, high: 661.98388671875
Tick: 86, close: 626.9740600585938, avg: 553.1861004638672, low: 582.2228393554688, high: 661.98388671875
Tick: 87, close: 637.4522705078125, avg: 556.8285528564453, low: 582.2228393554688, high: 661.98388671875
Tick: 88, close: 686.5142211914062, avg: 561.8402496337891, low: 582.2228393554688, high: 637.4522705078125
Exited the position
Tick: 89, close: 728.1359252929688, avg: 567.2680023193359, low: 582.2228393554688, high: 686.5142211914062
Tick: 90, close: 735.2276000976562, avg: 573.06072265625, low: 582.2228393554688, high: 728.1359252929688
Tick: 91, close: 753.3988647460938, avg: 579.1219763183594, low: 582.2228393554688, high: 735.2276000976562
Tick: 92, close: 734.8660888671875, avg: 584.5483557128906, low: 613.4778442382812, high: 753.3988647460938
Tick: 93, close: 729.6090087890625, avg: 589.9089294433594, low: 626.9740600585938, high: 753.3988647460938
Tick: 94, close: 772.933837890625, avg: 595.8152069091797, low: 637.4522705078125, high: 753.3988647460938
Tick: 95, close: 974.1026000976562, avg: 606.0347296142578, low: 686.5142211914062, high: 772.933837890625
Tick: 96, close: 1037.3663330078125, avg: 617.773423461914, low: 728.1359252929688, high: 974.1026000976562
Tick: 97, close: 1107.2362060546875, avg: 630.6974810791015, low: 729.6090087890625, high: 1037.3663330078125
Tick: 98, close: 1206.45458984375, avg: 645.155277709961, low: 729.6090087890625, high: 1107.2362060546875
Tick: 99, close: 1219.57568359375, avg: 659.9385913085938, low: 729.6090087890625, high: 1206.45458984375
Tick: 100, close: 1215.486328125, avg: 674.8084887695312, low: 729.6090087890625, high: 1219.57568359375
Tick: 101, close: 1281.0960693359375, avg: 690.2864782714844, low: 772.933837890625, high: 1219.57568359375
Tick: 102, close: 1255.24853515625, avg: 704.3408374023437, low: 974.1026000976562, high: 1281.0960693359375
Tick: 103, close: 1084.206298828125, avg: 714.7961437988281, low: 1037.3663330078125, high: 1281.0960693359375
Tick: 104, close: 1046.7899169921875, avg: 723.5514416503906, low: 1084.206298828125, high: 1281.0960693359375
Entered to a position
Tick: 105, close: 1130.773193359375, avg: 734.1312854003907, low: 1046.7899169921875, high: 1281.0960693359375
Tick: 106, close: 1224.1434326171875, avg: 747.2242419433594, low: 1046.7899169921875, high: 1281.0960693359375
Tick: 107, close: 1166.9871826171875, avg: 760.150556640625, low: 1046.7899169921875, high: 1281.0960693359375
Tick: 108, close: 1235.5675048828125, avg: 774.4925634765625, low: 1046.7899169921875, high: 1281.0960693359375
Tick: 109, close: 1232.2689208984375, avg: 788.3425256347656, low: 1046.7899169921875, high: 1255.24853515625
Tick: 110, close: 1260.0452880859375, avg: 802.0295483398437, low: 1046.7899169921875, high: 1235.5675048828125
Exited the position
Tick: 111, close: 1371.1070556640625, avg: 817.1258276367188, low: 1046.7899169921875, high: 1260.0452880859375
Tick: 112, close: 1377.8546142578125, avg: 832.8845947265625, low: 1130.773193359375, high: 1371.1070556640625
Tick: 113, close: 1113.4771728515625, avg: 843.2125927734374, low: 1166.9871826171875, high: 1377.8546142578125
Entered to a position
Tick: 114, close: 1238.14208984375, avg: 855.6517993164063, low: 1113.4771728515625, high: 1377.8546142578125
Tick: 115, close: 1226.7152099609375, avg: 868.7620849609375, low: 1113.4771728515625, high: 1377.8546142578125
Tick: 116, close: 1390.7669677734375, avg: 884.639267578125, low: 1113.4771728515625, high: 1377.8546142578125
Exited the position
Tick: 117, close: 1326.821044921875, avg: 899.1116064453125, low: 1113.4771728515625, high: 1390.7669677734375
Tick: 118, close: 1367.205322265625, avg: 914.6572497558594, low: 1113.4771728515625, high: 1390.7669677734375
Tick: 119, close: 1243.06103515625, avg: 928.417509765625, low: 1113.4771728515625, high: 1390.7669677734375
Tick: 120, close: 1338.0787353515625, avg: 943.7195141601562, low: 1113.4771728515625, high: 1390.7669677734375
Tick: 121, close: 1381.7852783203125, avg: 960.1920202636719, low: 1226.7152099609375, high: 1390.7669677734375
Tick: 122, close: 1373.296142578125, avg: 976.7685803222656, low: 1226.7152099609375, high: 1390.7669677734375
Tick: 123, close: 1312.8203125, avg: 991.6678796386718, low: 1243.06103515625, high: 1390.7669677734375
Tick: 124, close: 1372.9720458984375, avg: 1007.3211657714844, low: 1243.06103515625, high: 1381.7852783203125
Tick: 125, close: 1512.37646484375, avg: 1025.8702014160156, low: 1243.06103515625, high: 1381.7852783203125
Tick: 126, close: 1668.763916015625, avg: 1047.430098876953, low: 1243.06103515625, high: 1512.37646484375
Tick: 127, close: 1602.8670654296875, avg: 1066.7006506347657, low: 1312.8203125, high: 1668.763916015625
Tick: 128, close: 1713.110595703125, avg: 1088.1497692871094, low: 1312.8203125, high: 1668.763916015625
Tick: 129, close: 1676.3516845703125, avg: 1108.579393310547, low: 1312.8203125, high: 1713.110595703125
Tick: 130, close: 1616.95849609375, avg: 1127.6788854980468, low: 1312.8203125, high: 1713.110595703125
Tick: 131, close: 1742.1217041015625, avg: 1149.7844982910156, low: 1372.9720458984375, high: 1713.110595703125
Tick: 132, close: 1766.4183349609375, avg: 1172.9438708496093, low: 1512.37646484375, high: 1742.1217041015625
Tick: 133, close: 1752.53564453125, avg: 1195.2753515625, low: 1602.8670654296875, high: 1766.4183349609375
Tick: 134, close: 1776.8115234375, avg: 1219.1671252441406, low: 1602.8670654296875, high: 1766.4183349609375
Tick: 135, close: 1834.77978515625, avg: 1243.5931640625, low: 1616.95849609375, high: 1776.8115234375
Tick: 136, close: 1823.299072265625, avg: 1267.5196643066406, low: 1616.95849609375, high: 1834.77978515625
Tick: 137, close: 1804.1416015625, avg: 1290.8534509277345, low: 1616.95849609375, high: 1834.77978515625
Tick: 138, close: 1782.865966796875, avg: 1312.7804858398438, low: 1742.1217041015625, high: 1834.77978515625
Tick: 139, close: 1772.890625, avg: 1333.6755798339843, low: 1752.53564453125, high: 1834.77978515625
Tick: 140, close: 1840.19482421875, avg: 1355.7749243164062, low: 1752.53564453125, high: 1834.77978515625
Tick: 141, close: 1938.2950439453125, avg: 1379.4728479003907, low: 1772.890625, high: 1840.19482421875
Tick: 142, close: 1954.83154296875, avg: 1403.872156982422, low: 1772.890625, high: 1938.2950439453125
Tick: 143, close: 1920.5281982421875, avg: 1427.6905407714844, low: 1772.890625, high: 1954.83154296875
Tick: 144, close: 1927.30078125, avg: 1450.777879638672, low: 1772.890625, high: 1954.83154296875
Tick: 145, close: 1789.696533203125, avg: 1467.0897583007813, low: 1772.890625, high: 1954.83154296875
Tick: 146, close: 1574.2379150390625, avg: 1477.8271899414062, low: 1772.890625, high: 1954.83154296875
Entered to a position
Tick: 147, close: 1617.1561279296875, avg: 1488.0255883789061, low: 1574.2379150390625, high: 1954.83154296875
Tick: 148, close: 1482.1158447265625, avg: 1493.5388134765626, low: 1574.2379150390625, high: 1954.83154296875
Tick: 149, close: 1436.8006591796875, avg: 1497.8833129882812, low: 1482.1158447265625, high: 1954.83154296875
Tick: 150, close: 1466.50439453125, avg: 1502.9036743164063, low: 1436.8006591796875, high: 1927.30078125
Tick: 151, close: 1423.7117919921875, avg: 1505.7559887695313, low: 1436.8006591796875, high: 1927.30078125
Tick: 152, close: 1572.267822265625, avg: 1512.0963745117188, low: 1423.7117919921875, high: 1789.696533203125
Tick: 153, close: 1485.5440673828125, avg: 1520.1231298828125, low: 1423.7117919921875, high: 1617.1561279296875
Tick: 154, close: 1572.6031494140625, avg: 1530.63939453125, low: 1423.7117919921875, high: 1617.1561279296875
Tick: 155, close: 1532.6888427734375, avg: 1538.6777075195312, low: 1423.7117919921875, high: 1572.6031494140625
Tick: 156, close: 1526.453369140625, avg: 1544.72390625, low: 1423.7117919921875, high: 1572.6031494140625
Tick: 157, close: 1649.623779296875, avg: 1554.3766381835937, low: 1423.7117919921875, high: 1572.6031494140625
Exited the position
Tick: 158, close: 1723.138916015625, avg: 1564.12806640625, low: 1423.7117919921875, high: 1649.623779296875
Tick: 159, close: 1837.42919921875, avg: 1576.2312719726563, low: 1485.5440673828125, high: 1723.138916015625
Tick: 160, close: 1858.95361328125, avg: 1588.2094384765626, low: 1485.5440673828125, high: 1837.42919921875
Tick: 161, close: 1807.6932373046875, avg: 1596.941162109375, low: 1526.453369140625, high: 1858.95361328125
Tick: 162, close: 1832.8177490234375, avg: 1606.0404248046875, low: 1526.453369140625, high: 1858.95361328125
Tick: 163, close: 1773.0623779296875, avg: 1619.23212890625, low: 1526.453369140625, high: 1858.95361328125
Tick: 164, close: 1933.2110595703125, avg: 1633.1335083007812, low: 1649.623779296875, high: 1858.95361328125
Tick: 165, close: 1850.4996337890625, avg: 1645.6091967773436, low: 1723.138916015625, high: 1933.2110595703125
Tick: 166, close: 1792.4600830078125, avg: 1653.6430590820312, low: 1773.0623779296875, high: 1933.2110595703125
Tick: 167, close: 1804.58984375, avg: 1663.1984350585938, low: 1773.0623779296875, high: 1933.2110595703125
Tick: 168, close: 1814.626708984375, avg: 1672.1468627929687, low: 1773.0623779296875, high: 1933.2110595703125
Tick: 169, close: 1777.3580322265625, avg: 1682.832802734375, low: 1773.0623779296875, high: 1933.2110595703125
Tick: 170, close: 1805.40283203125, avg: 1692.1792846679687, low: 1773.0623779296875, high: 1933.2110595703125
Tick: 171, close: 1804.7816162109375, avg: 1700.6392114257812, low: 1777.3580322265625, high: 1933.2110595703125
Tick: 172, close: 1774.6051025390625, avg: 1708.665390625, low: 1777.3580322265625, high: 1850.4996337890625
Entered to a position
Tick: 173, close: 1689.195068359375, avg: 1716.1928857421874, low: 1774.6051025390625, high: 1814.626708984375
Tick: 174, close: 1668.7911376953125, avg: 1722.109267578125, low: 1689.195068359375, high: 1814.626708984375
Tick: 175, close: 1580.60986328125, avg: 1723.473935546875, low: 1668.7911376953125, high: 1814.626708984375
Tick: 176, close: 1598.1024169921875, avg: 1722.0607055664063, low: 1580.60986328125, high: 1805.40283203125
Tick: 177, close: 1700.6331787109375, avg: 1724.0160278320313, low: 1580.60986328125, high: 1805.40283203125
Tick: 178, close: 1712.47998046875, avg: 1724.0034155273438, low: 1580.60986328125, high: 1804.7816162109375
Tick: 179, close: 1676.6297607421875, avg: 1724.0089770507811, low: 1580.60986328125, high: 1774.6051025390625
Tick: 180, close: 1811.2628173828125, avg: 1727.8950634765624, low: 1580.60986328125, high: 1712.47998046875
Exited the position
Tick: 181, close: 1833.931884765625, avg: 1729.7312670898436, low: 1580.60986328125, high: 1811.2628173828125
Tick: 182, close: 1912.6085205078125, avg: 1732.6550708007812, low: 1580.60986328125, high: 1833.931884765625
Tick: 183, close: 1979.26953125, avg: 1737.1897485351562, low: 1598.1024169921875, high: 1912.6085205078125
Tick: 184, close: 2125.971435546875, avg: 1744.1729467773437, low: 1676.6297607421875, high: 1979.26953125
Tick: 185, close: 2008.2606201171875, avg: 1747.6425634765626, low: 1676.6297607421875, high: 2125.971435546875
Tick: 186, close: 2079.07861328125, avg: 1752.758154296875, low: 1676.6297607421875, high: 2125.971435546875
Tick: 187, close: 2107.008056640625, avg: 1758.8154833984374, low: 1811.2628173828125, high: 2125.971435546875
Tick: 188, close: 2109.185546875, avg: 1765.341875, low: 1833.931884765625, high: 2125.971435546875
Tick: 189, close: 1963.5430908203125, avg: 1769.1549243164063, low: 1912.6085205078125, high: 2125.971435546875
Tick: 190, close: 2069.53759765625, avg: 1773.7417797851563, low: 1963.5430908203125, high: 2125.971435546875
Tick: 191, close: 2069.621826171875, avg: 1776.3683154296875, low: 1963.5430908203125, high: 2125.971435546875
Tick: 192, close: 2130.754638671875, avg: 1779.88677734375, low: 1963.5430908203125, high: 2109.185546875
Tick: 193, close: 2137.19140625, avg: 1784.2200415039063, low: 1963.5430908203125, high: 2130.754638671875
Tick: 194, close: 2151.284423828125, avg: 1788.6997143554688, low: 1963.5430908203125, high: 2137.19140625
Tick: 195, close: 2289.309814453125, avg: 1798.6919799804687, low: 1963.5430908203125, high: 2151.284423828125
Tick: 196, close: 2417.96484375, avg: 1815.5665185546875, low: 1963.5430908203125, high: 2289.309814453125
Tick: 197, close: 2508.14013671875, avg: 1833.3861987304688, low: 2069.53759765625, high: 2417.96484375
Tick: 198, close: 2435.531005859375, avg: 1852.454501953125, low: 2069.621826171875, high: 2508.14013671875
Tick: 199, close: 2330.4619140625, avg: 1870.3277270507813, low: 2130.754638671875, high: 2508.14013671875
Tick: 200, close: 2230.4833984375, avg: 1885.6073071289063, low: 2137.19140625, high: 2508.14013671875
Tick: 201, close: 2170.525390625, avg: 1900.5435791015625, low: 2151.284423828125, high: 2508.14013671875
Tick: 202, close: 2333.894775390625, avg: 1915.7761181640626, low: 2170.525390625, high: 2508.14013671875
Tick: 203, close: 2359.331298828125, avg: 1933.2518627929687, low: 2170.525390625, high: 2508.14013671875
Tick: 204, close: 2402.05322265625, avg: 1949.8408642578124, low: 2170.525390625, high: 2508.14013671875
Tick: 205, close: 2371.036376953125, avg: 1966.6078149414063, low: 2170.525390625, high: 2435.531005859375
Tick: 206, close: 2207.252197265625, avg: 1980.2237915039063, low: 2170.525390625, high: 2402.05322265625
Tick: 207, close: 2308.857177734375, avg: 1993.4084594726562, low: 2170.525390625, high: 2402.05322265625
Tick: 208, close: 2523.3271484375, avg: 2009.4122241210937, low: 2170.525390625, high: 2402.05322265625
Tick: 209, close: 2665.10693359375, avg: 2025.9657788085938, low: 2207.252197265625, high: 2523.3271484375
Tick: 210, close: 2753.482177734375, avg: 2043.8563500976563, low: 2207.252197265625, high: 2665.10693359375
Tick: 211, close: 2769.08740234375, avg: 2063.0842333984374, low: 2207.252197265625, high: 2753.482177734375
Tick: 212, close: 2760.71826171875, avg: 2081.642243652344, low: 2207.252197265625, high: 2769.08740234375
Tick: 213, close: 2938.5439453125, avg: 2104.951875, low: 2207.252197265625, high: 2769.08740234375
Tick: 214, close: 2938.8642578125, avg: 2125.064938964844, low: 2308.857177734375, high: 2938.5439453125
Tick: 215, close: 3418.266845703125, avg: 2156.420283203125, low: 2523.3271484375, high: 2938.8642578125
Tick: 216, close: 3256.860595703125, avg: 2185.7082934570312, low: 2665.10693359375, high: 3418.266845703125
Tick: 217, close: 3513.30615234375, avg: 2219.8826196289065, low: 2753.482177734375, high: 3418.266845703125
Tick: 218, close: 3508.792724609375, avg: 2253.765939941406, low: 2760.71826171875, high: 3513.30615234375
Tick: 219, close: 3489.1865234375, avg: 2288.002509765625, low: 2760.71826171875, high: 3513.30615234375
Tick: 220, close: 3912.947265625, avg: 2330.1533984375, low: 2938.5439453125, high: 3513.30615234375
Tick: 221, close: 3936.052734375, avg: 2372.7788208007814, low: 2938.8642578125, high: 3912.947265625
Tick: 222, close: 3964.718505859375, avg: 2416.5810888671876, low: 3256.860595703125, high: 3936.052734375
Tick: 223, close: 4183.5517578125, avg: 2466.46822265625, low: 3256.860595703125, high: 3964.718505859375
Tick: 224, close: 3825.593505859375, avg: 2509.604270019531, low: 3489.1865234375, high: 4183.5517578125
Tick: 225, close: 3732.2548828125, avg: 2552.637170410156, low: 3489.1865234375, high: 4183.5517578125
Tick: 226, close: 4093.0732421875, avg: 2602.5365869140624, low: 3489.1865234375, high: 4183.5517578125
Tick: 227, close: 3628.124267578125, avg: 2641.086408691406, low: 3732.2548828125, high: 4183.5517578125
Entered to a position
Tick: 228, close: 3566.88671875, avg: 2678.174543457031, low: 3628.124267578125, high: 4183.5517578125
Tick: 229, close: 3292.621337890625, avg: 2710.494375, low: 3566.88671875, high: 4183.5517578125
Tick: 230, close: 3377.51708984375, avg: 2741.8194604492187, low: 3292.621337890625, high: 4183.5517578125
Tick: 231, close: 2448.775634765625, avg: 2754.1163354492187, low: 3292.621337890625, high: 4093.0732421875
Tick: 232, close: 2771.63671875, avg: 2771.2968994140624, low: 2448.775634765625, high: 4093.0732421875
Tick: 233, close: 2422.828125, avg: 2780.1680712890625, low: 2448.775634765625, high: 4093.0732421875
Tick: 234, close: 2288.02783203125, avg: 2783.40919921875, low: 2422.828125, high: 3628.124267578125
Tick: 235, close: 2114.04638671875, avg: 2785.5249145507814, low: 2288.02783203125, high: 3566.88671875
Tick: 236, close: 2656.09521484375, avg: 2797.0652465820312, low: 2114.04638671875, high: 3377.51708984375
Tick: 237, close: 2691.21533203125, avg: 2808.7493920898437, low: 2114.04638671875, high: 3377.51708984375
Tick: 238, close: 2875.767578125, avg: 2824.081032714844, low: 2114.04638671875, high: 2771.63671875
Exited the position
Tick: 239, close: 2737.115478515625, avg: 2839.55248046875, low: 2114.04638671875, high: 2875.767578125
Tick: 240, close: 2408.90380859375, avg: 2846.3398046875, low: 2114.04638671875, high: 2875.767578125
Tick: 241, close: 2291.33642578125, avg: 2850.7740966796873, low: 2114.04638671875, high: 2875.767578125
Tick: 242, close: 2384.20263671875, avg: 2855.843056640625, low: 2114.04638671875, high: 2875.767578125
Tick: 243, close: 2716.62939453125, avg: 2867.43181640625, low: 2291.33642578125, high: 2875.767578125
Tick: 244, close: 2644.74609375, avg: 2877.3010498046874, low: 2291.33642578125, high: 2875.767578125
Tick: 245, close: 2702.494384765625, avg: 2885.5647412109374, low: 2291.33642578125, high: 2875.767578125
Tick: 246, close: 2865.697021484375, avg: 2894.519384765625, low: 2291.33642578125, high: 2737.115478515625
Tick: 247, close: 2682.978759765625, avg: 2898.0161572265624, low: 2291.33642578125, high: 2865.697021484375
Tick: 248, close: 2630.857666015625, avg: 2901.9226904296875, low: 2291.33642578125, high: 2865.697021484375
Tick: 249, close: 2697.5146484375, avg: 2909.2637451171877, low: 2384.20263671875, high: 2865.697021484375
Tick: 250, close: 2577.902099609375, avg: 2916.212119140625, low: 2630.857666015625, high: 2865.697021484375
Tick: 251, close: 2506.339599609375, avg: 2922.9284033203126, low: 2577.902099609375, high: 2865.697021484375
Tick: 252, close: 2612.6953125, avg: 2928.5044140625, low: 2506.339599609375, high: 2865.697021484375
Tick: 253, close: 2480.669677734375, avg: 2930.931181640625, low: 2506.339599609375, high: 2865.697021484375
Tick: 254, close: 2343.142578125, avg: 2929.75296875, low: 2480.669677734375, high: 2697.5146484375
Tick: 255, close: 2381.01220703125, avg: 2929.9524853515627, low: 2343.142578125, high: 2697.5146484375
Tick: 256, close: 2513.51806640625, avg: 2936.077802734375, low: 2343.142578125, high: 2697.5146484375
Tick: 257, close: 2568.2431640625, avg: 2941.2655224609375, low: 2343.142578125, high: 2612.6953125
Tick: 258, close: 2544.38037109375, avg: 2941.6865869140624, low: 2343.142578125, high: 2612.6953125
Tick: 259, close: 2368.5, avg: 2935.7544482421877, low: 2343.142578125, high: 2612.6953125
Tick: 260, close: 2364.13037109375, avg: 2927.967412109375, low: 2343.142578125, high: 2568.2431640625
Tick: 261, close: 2235.540283203125, avg: 2917.2964697265625, low: 2343.142578125, high: 2568.2431640625
Tick: 262, close: 2178.801513671875, avg: 2905.658134765625, low: 2235.540283203125, high: 2568.2431640625
Tick: 263, close: 2232.743896484375, avg: 2891.5421337890625, low: 2178.801513671875, high: 2568.2431640625
Tick: 264, close: 1880.492919921875, avg: 2870.37470703125, low: 2178.801513671875, high: 2568.2431640625
Tick: 265, close: 1884.575439453125, avg: 2839.70087890625, low: 1880.492919921875, high: 2544.38037109375
Tick: 266, close: 1974.7591552734375, avg: 2814.0588500976564, low: 1880.492919921875, high: 2368.5
Tick: 267, close: 1981.17138671875, avg: 2783.4161547851563, low: 1880.492919921875, high: 2364.13037109375
Tick: 268, close: 1811.6553955078125, avg: 2749.473408203125, low: 1880.492919921875, high: 2235.540283203125
Tick: 269, close: 1821.4423828125, avg: 2716.118525390625, low: 1811.6553955078125, high: 2232.743896484375
Tick: 270, close: 1983.7396240234375, avg: 2677.5343725585935, low: 1811.6553955078125, high: 2232.743896484375
Tick: 271, close: 2082.6083984375, avg: 2640.465485839844, low: 1811.6553955078125, high: 1983.7396240234375
Tick: 272, close: 2157.7861328125, avg: 2604.3268383789064, low: 1811.6553955078125, high: 2082.6083984375
Tick: 273, close: 2280.143310546875, avg: 2566.2586694335937, low: 1811.6553955078125, high: 2157.7861328125
Tick: 274, close: 2107.4609375, avg: 2531.896018066406, low: 1811.6553955078125, high: 2280.143310546875
Tick: 275, close: 2143.107666015625, avg: 2500.113073730469, low: 1811.6553955078125, high: 2280.143310546875
Tick: 276, close: 2218.784423828125, avg: 2462.6272973632813, low: 1821.4423828125, high: 2280.143310546875
Tick: 277, close: 2321.436279296875, avg: 2436.493537597656, low: 1983.7396240234375, high: 2280.143310546875
Tick: 278, close: 2191.279052734375, avg: 2408.9813842773438, low: 2082.6083984375, high: 2321.436279296875
Tick: 279, close: 2327.529296875, avg: 2389.6795434570313, low: 2107.4609375, high: 2321.436279296875
Tick: 280, close: 2310.70361328125, avg: 2368.3432739257814, low: 2107.4609375, high: 2327.529296875
Tick: 281, close: 2114.87353515625, avg: 2361.6652319335935, low: 2107.4609375, high: 2327.529296875
Tick: 282, close: 2146.5283203125, avg: 2349.163063964844, low: 2114.87353515625, high: 2327.529296875
Tick: 283, close: 2122.02197265625, avg: 2343.1469409179685, low: 2114.87353515625, high: 2327.529296875
Tick: 284, close: 2147.53857421875, avg: 2340.337155761719, low: 2114.87353515625, high: 2327.529296875
Tick: 285, close: 2041.07080078125, avg: 2338.8776440429688, low: 2114.87353515625, high: 2327.529296875
Tick: 286, close: 1943.625732421875, avg: 2324.6282543945313, low: 2041.07080078125, high: 2327.529296875
Tick: 287, close: 1997.949462890625, avg: 2310.762937011719, low: 1943.625732421875, high: 2310.70361328125
Tick: 288, close: 1918.9427490234375, avg: 2291.6264404296876, low: 1943.625732421875, high: 2147.53857421875
Tick: 289, close: 1870.63916015625, avg: 2274.2969140625, low: 1918.9427490234375, high: 2147.53857421875
Tick: 290, close: 1893.6572265625, avg: 2263.991982421875, low: 1870.63916015625, high: 2147.53857421875
Tick: 291, close: 1890.7325439453125, avg: 2255.979904785156, low: 1870.63916015625, high: 2147.53857421875
Tick: 292, close: 1817.1904296875, avg: 2244.6396606445314, low: 1870.63916015625, high: 2041.07080078125
Tick: 293, close: 1781.06201171875, avg: 2225.928312988281, low: 1817.1904296875, high: 1997.949462890625
Tick: 294, close: 2002.282958984375, avg: 2213.0790502929685, low: 1781.06201171875, high: 1997.949462890625
Tick: 295, close: 2015.3248291015625, avg: 2199.3356591796874, low: 1781.06201171875, high: 2002.282958984375
Tick: 296, close: 2115.479248046875, avg: 2184.3313037109374, low: 1781.06201171875, high: 2015.3248291015625
Tick: 297, close: 2175.922607421875, avg: 2174.1901806640626, low: 1781.06201171875, high: 2115.479248046875
Tick: 298, close: 2198.818359375, avg: 2165.54939453125, low: 1781.06201171875, high: 2175.922607421875
Tick: 299, close: 2236.636474609375, avg: 2156.3318310546874, low: 1781.06201171875, high: 2198.818359375
Tick: 300, close: 2287.68798828125, avg: 2150.527548828125, low: 1781.06201171875, high: 2236.636474609375
Tick: 301, close: 2291.809326171875, avg: 2146.236943359375, low: 2002.282958984375, high: 2287.68798828125
Tick: 302, close: 2371.872314453125, avg: 2141.4204833984377, low: 2015.3248291015625, high: 2291.809326171875
Tick: 303, close: 2457.61279296875, avg: 2140.959345703125, low: 2115.479248046875, high: 2371.872314453125
Tick: 304, close: 2547.812255859375, avg: 2145.0527392578124, low: 2175.922607421875, high: 2457.61279296875
Tick: 305, close: 2556.748046875, avg: 2148.5674560546877, low: 2198.818359375, high: 2547.812255859375
Tick: 306, close: 2604.8173828125, avg: 2150.3934423828123, low: 2236.636474609375, high: 2556.748046875
Tick: 307, close: 2493.548828125, avg: 2148.8995556640625, low: 2287.68798828125, high: 2604.8173828125
Tick: 308, close: 2726.773193359375, avg: 2152.547412109375, low: 2291.809326171875, high: 2604.8173828125
Tick: 309, close: 2836.7431640625, avg: 2161.912275390625, low: 2371.872314453125, high: 2726.773193359375
Tick: 310, close: 2878.633544921875, avg: 2172.2023388671873, low: 2457.61279296875, high: 2836.7431640625
Tick: 311, close: 3171.605712890625, avg: 2190.9236474609374, low: 2493.548828125, high: 2878.633544921875
Tick: 312, close: 3005.310791015625, avg: 2207.4538330078126, low: 2493.548828125, high: 3171.605712890625
Tick: 313, close: 3170.44482421875, avg: 2226.2078515625, low: 2493.548828125, high: 3171.605712890625
Tick: 314, close: 3143.90869140625, avg: 2251.4761669921877, low: 2493.548828125, high: 3171.605712890625
Tick: 315, close: 3176.528076171875, avg: 2277.3152197265626, low: 2726.773193359375, high: 3171.605712890625
Tick: 316, close: 3035.422607421875, avg: 2298.528488769531, low: 2836.7431640625, high: 3176.528076171875
Tick: 317, close: 3329.08203125, avg: 2325.486701660156, low: 2878.633544921875, high: 3176.528076171875
Tick: 318, close: 3278.476806640625, avg: 2354.8231298828123, low: 3005.310791015625, high: 3329.08203125
Tick: 319, close: 3300.9580078125, avg: 2384.4134423828127, low: 3005.310791015625, high: 3329.08203125
Tick: 320, close: 3161.592041015625, avg: 2407.9704907226565, low: 3035.422607421875, high: 3329.08203125
Tick: 321, close: 3022.208251953125, avg: 2426.762487792969, low: 3035.422607421875, high: 3329.08203125
Entered to a position
Tick: 322, close: 3031.83447265625, avg: 2444.2434545898436, low: 3022.208251953125, high: 3329.08203125
Tick: 323, close: 3184.545166015625, avg: 2462.3314916992185, low: 3022.208251953125, high: 3329.08203125
Tick: 324, close: 3288.931884765625, avg: 2485.9609106445314, low: 3022.208251953125, high: 3329.08203125
Tick: 325, close: 3226.136474609375, avg: 2507.621486816406, low: 3022.208251953125, high: 3300.9580078125
Tick: 326, close: 3235.71826171875, avg: 2527.9601635742188, low: 3022.208251953125, high: 3300.9580078125
Tick: 327, close: 3314.27978515625, avg: 2547.8170336914063, low: 3022.208251953125, high: 3288.931884765625
Exited the position
Tick: 328, close: 3164.071044921875, avg: 2567.272873535156, low: 3022.208251953125, high: 3314.27978515625
Tick: 329, close: 3213.921875, avg: 2585.0007250976564, low: 3031.83447265625, high: 3314.27978515625
Tick: 330, close: 3093.651123046875, avg: 2600.6596752929686, low: 3164.071044921875, high: 3314.27978515625
Entered to a position
Tick: 331, close: 3263.108154296875, avg: 2623.6243676757813, low: 3093.651123046875, high: 3314.27978515625
Tick: 332, close: 3227.8505859375, avg: 2645.2508129882813, low: 3093.651123046875, high: 3314.27978515625
Tick: 333, close: 3215.328125, avg: 2667.1169360351564, low: 3093.651123046875, high: 3314.27978515625
Tick: 334, close: 3216.791259765625, avg: 2688.501989746094, low: 3093.651123046875, high: 3314.27978515625
Tick: 335, close: 3442.265869140625, avg: 2716.5258911132814, low: 3093.651123046875, high: 3263.108154296875
Exited the position
Tick: 336, close: 3815.57666015625, avg: 2753.9649096679686, low: 3093.651123046875, high: 3442.265869140625

Analyzing the strategy results#

After the strategy is run, we need to figure out how well it performs. We use Backtrader provided analysis tools to understand the strategy perforamnce.

[6]:
strategy: Double7 = results[0]

Key figures#

Some standard performance figures for quantative finance.

[7]:
print(f"Backtesting range {BACKTESTING_BEGINS.date()} - {BACKTESTING_ENDS.date()}")
print(f"Sharpe: {strategy.analyzers.sharperatio.get_analysis()['sharperatio']:.3f}")
print(f"Normalised annual return: {strategy.analyzers.returns.get_analysis()['rnorm100']:.2f}%")
print(f"Max drawdown: {strategy.analyzers.drawdown.get_analysis()['max']['drawdown']:.2f}%")
Backtesting range 2020-10-01 - 2021-09-01
Sharpe: 1.793
Normalised annual return: 4.69%
Max drawdown: 14.28%

Trade analysis and portfolio overall development#

The Backtrader default output chart will display the portfolio value develoment and when the individual trades were made.

[8]:
import datetime
import matplotlib.pyplot as pyplot

# Increase the size of the chart to be more readable,
# look better on high DPI monitor output
pyplot.rcParams['figure.figsize'] = [15, 7.5]

# We can cut the head period of the backtesting away,
# as there aren't any trades until the first moving average time period is complete
trading_begins_at = (BACKTESTING_BEGINS + MOVING_AVERAGE_CANDLES * datetime.timedelta(days=1)).date()

# Get all produced figures (one per strategy)
figs = cerebro.plot(iplot=True, start=trading_begins_at)

# Output the strategy overview figure
figs[0][0]
[8]:
../../_images/programming_old-strategies_double-7_18_2.png