Trade history

In [1]:
from areixio import CryptoDataFeed, Strategy,  BackTestBroker, BackTest, Statistic
from datetime import datetime, timedelta
import json
now = datetime.now()
In [2]:
# with open('records_trade.json', 'r') as f:
#     trade_history = json.load(f)
trade_history = [
    {
        "order_id": "aio-1689137399-2hucero93w3xpdpzzjbebp9gft-00485",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "OPEN LONG",
        "price": 19186.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 4.7965,
        "commission_asset": None,
        "traded_at": "2022-09-07 08:00:00+08:00",
        "actual_traded_at": "2022-09-08 10:20:00+08:00",
        "gross_amount": 1918.6,
        "net_amount": 1923.3965,
        "is_open": True,
        "avg_open_price": 19189.59161481,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -4.7965,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2kkrgxymbynvtna2ga8i7ty9u9-00486",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "CLOSE LONG",
        "price": 19251.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 4.812875,
        "commission_asset": None,
        "traded_at": "2022-09-07 08:00:00+08:00",
        "actual_traded_at": "2022-09-08 13:40:00+08:00",
        "gross_amount": 1925.15,
        "net_amount": 1920.337125,
        "is_open": False,
        "avg_open_price": 19189.59161481,
        "leverage": 5,
        "pnl": 30.954193,
        "pnl_net": 26.141318,
        "roi": 0.0032,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1wi2zsskzfb9aqq7bvi8xmtuid-00487",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "OPEN LONG",
        "price": 19176.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 4.794,
        "commission_asset": None,
        "traded_at": "2022-09-07 08:00:00+08:00",
        "actual_traded_at": "2022-09-08 13:45:00+08:00",
        "gross_amount": 1917.6,
        "net_amount": 1922.394,
        "is_open": True,
        "avg_open_price": 19185.06107654,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -4.794,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-237yef5tvazae9jzviif5gttk1-00488",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "CLOSE LONG",
        "price": 19225.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 4.806375,
        "commission_asset": None,
        "traded_at": "2022-09-07 08:00:00+08:00",
        "actual_traded_at": "2022-09-08 14:25:00+08:00",
        "gross_amount": 1922.55,
        "net_amount": 1917.743625,
        "is_open": False,
        "avg_open_price": 19185.06107654,
        "leverage": 5,
        "pnl": 20.219462,
        "pnl_net": 15.413087,
        "roi": 0.0021,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1pp5gsdo65x2phvhr4w1bioy9i-00489",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "OPEN LONG",
        "price": 19141.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 4.78525,
        "commission_asset": None,
        "traded_at": "2022-09-07 08:00:00+08:00",
        "actual_traded_at": "2022-09-08 14:25:00+08:00",
        "gross_amount": 1914.1,
        "net_amount": 1918.88525,
        "is_open": True,
        "avg_open_price": 19170.37405103,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -4.78525,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1m6r2ig66ttar56xadz9f5i4ah-00490",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "CLOSE LONG",
        "price": 19259.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 4.814875,
        "commission_asset": None,
        "traded_at": "2022-09-07 08:00:00+08:00",
        "actual_traded_at": "2022-09-08 19:30:00+08:00",
        "gross_amount": 1925.95,
        "net_amount": 1921.135125,
        "is_open": False,
        "avg_open_price": 19170.37405103,
        "leverage": 5,
        "pnl": 44.562975,
        "pnl_net": 39.7481,
        "roi": 0.0047,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1p2a9mzqevmzcjrdmt9a1znw81-00491",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "CLOSE LONG",
        "price": 20193.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.048375,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 04:00:00+08:00",
        "gross_amount": 2019.35,
        "net_amount": 2014.301625,
        "is_open": False,
        "avg_open_price": 19170.37405103,
        "leverage": 5,
        "pnl": 511.562975,
        "pnl_net": 506.5146,
        "roi": 0.0534,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-13ksyvxuv12jf8nuaf6sz25uxb-00492",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "CLOSE LONG",
        "price": 19993.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 4.99825,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 04:00:00+08:00",
        "gross_amount": 1999.3,
        "net_amount": 1994.30175,
        "is_open": False,
        "avg_open_price": 19170.37405103,
        "leverage": 5,
        "pnl": 411.312975,
        "pnl_net": 406.314725,
        "roi": 0.0429,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2kiog4roki7zpjqvs8bio1svse-00493",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "OPEN LONG",
        "price": 20322.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.0805,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 04:40:00+08:00",
        "gross_amount": 2032.2,
        "net_amount": 2037.2805,
        "is_open": True,
        "avg_open_price": 20322.0,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.0805,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1jt1drsub1bguwmx2mcyhmyejw-00494",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "CLOSE LONG",
        "price": 20333.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.08325,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 04:40:00+08:00",
        "gross_amount": 2033.3,
        "net_amount": 2028.21675,
        "is_open": False,
        "avg_open_price": 20322.0,
        "leverage": 5,
        "pnl": 5.5,
        "pnl_net": 0.41675,
        "roi": 0.0006,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1afbpk3rgjqbs4pdmefgkduuac-00495",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 20318.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.0795,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 04:50:00+08:00",
        "gross_amount": 2031.8,
        "net_amount": 2026.7205,
        "is_open": True,
        "avg_open_price": 20318.0,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.0795,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2nhq9naoh4576tao9s7czjae2j-00496",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 20894.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.2235,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 10:30:00+08:00",
        "gross_amount": 2089.4,
        "net_amount": 2084.1765,
        "is_open": True,
        "avg_open_price": 20606.0,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.2235,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2knwuu81yey9aca5smzk6893ix-00497",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21039.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.259875,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 10:55:00+08:00",
        "gross_amount": 2103.95,
        "net_amount": 2098.690125,
        "is_open": True,
        "avg_open_price": 20750.5,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.259875,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2bkt7phewcs3mrsanj54vsr21z-00498",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 20945.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.236375,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 11:10:00+08:00",
        "gross_amount": 2094.55,
        "net_amount": 2099.786375,
        "is_open": False,
        "avg_open_price": 20750.5,
        "leverage": 5,
        "pnl": -97.5,
        "pnl_net": -102.736375,
        "roi": -0.0094,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1nekho27ygv3hx9w72howotjpr-00499",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 20997.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.249375,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 11:30:00+08:00",
        "gross_amount": 2099.75,
        "net_amount": 2094.500625,
        "is_open": True,
        "avg_open_price": 20832.83333333,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.249375,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1qc9j5gusnqf8zy4jwv13h39ku-00500",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 20960.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.24,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 11:40:00+08:00",
        "gross_amount": 2096.0,
        "net_amount": 2101.24,
        "is_open": False,
        "avg_open_price": 20832.83333333,
        "leverage": 5,
        "pnl": -63.583333,
        "pnl_net": -68.823333,
        "roi": -0.0061,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2n6qrpfnwj877cx9a9n32wza8u-00501",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21004.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.251,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 12:10:00+08:00",
        "gross_amount": 2100.4,
        "net_amount": 2095.149,
        "is_open": True,
        "avg_open_price": 20889.88888889,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.251,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2r3jgi92wohuxwsdtv2sjnthif-00502",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21084.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.271,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 12:30:00+08:00",
        "gross_amount": 2108.4,
        "net_amount": 2103.129,
        "is_open": True,
        "avg_open_price": 20938.41666667,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.271,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-22hm4igubfsdrq96bf6kyxwzwu-00503",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21016.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.254125,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 13:00:00+08:00",
        "gross_amount": 2101.65,
        "net_amount": 2106.904125,
        "is_open": False,
        "avg_open_price": 20938.41666667,
        "leverage": 5,
        "pnl": -39.041667,
        "pnl_net": -44.295792,
        "roi": -0.0037,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1wnccmdarq9oz15oo8asj1spdz-00504",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 20965.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.241375,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 13:20:00+08:00",
        "gross_amount": 2096.55,
        "net_amount": 2101.791375,
        "is_open": False,
        "avg_open_price": 20938.41666667,
        "leverage": 5,
        "pnl": -13.541667,
        "pnl_net": -18.783042,
        "roi": -0.0013,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2rbv1a3yi73ajyycqno469f56r-00505",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21208.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.302,
        "commission_asset": None,
        "traded_at": "2022-09-08 08:00:00+08:00",
        "actual_traded_at": "2022-09-09 14:55:00+08:00",
        "gross_amount": 2120.8,
        "net_amount": 2115.498,
        "is_open": True,
        "avg_open_price": 21028.27777778,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.302,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-11d7w1w8zr3t4xemse849myzrs-00506",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21190.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.297625,
        "commission_asset": None,
        "traded_at": "2022-09-09 08:00:00+08:00",
        "actual_traded_at": "2022-09-10 00:30:00+08:00",
        "gross_amount": 2119.05,
        "net_amount": 2124.347625,
        "is_open": False,
        "avg_open_price": 21028.27777778,
        "leverage": 5,
        "pnl": -81.111111,
        "pnl_net": -86.408736,
        "roi": -0.0077,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2itr5uv3wq7wd4xtpwh7ymwqm6-00507",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21300.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.325,
        "commission_asset": None,
        "traded_at": "2022-09-09 08:00:00+08:00",
        "actual_traded_at": "2022-09-10 01:10:00+08:00",
        "gross_amount": 2130.0,
        "net_amount": 2124.675,
        "is_open": True,
        "avg_open_price": 21118.85185185,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.325,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-12tg8a7jj9kjtycote7hhfuy6e-00508",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21240.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.310125,
        "commission_asset": None,
        "traded_at": "2022-09-09 08:00:00+08:00",
        "actual_traded_at": "2022-09-10 02:10:00+08:00",
        "gross_amount": 2124.05,
        "net_amount": 2129.360125,
        "is_open": False,
        "avg_open_price": 21118.85185185,
        "leverage": 5,
        "pnl": -60.824074,
        "pnl_net": -66.134199,
        "roi": -0.0058,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1j1wtncbc1rx3ok1zs48p268ge-00509",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21345.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.33625,
        "commission_asset": None,
        "traded_at": "2022-09-09 08:00:00+08:00",
        "actual_traded_at": "2022-09-10 03:40:00+08:00",
        "gross_amount": 2134.5,
        "net_amount": 2129.16375,
        "is_open": True,
        "avg_open_price": 21194.2345679,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.33625,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2ffm8p1p4wy9ywhruusfqdxd94-00510",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21612.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.403,
        "commission_asset": None,
        "traded_at": "2022-09-09 08:00:00+08:00",
        "actual_traded_at": "2022-09-10 05:20:00+08:00",
        "gross_amount": 2161.2,
        "net_amount": 2155.797,
        "is_open": True,
        "avg_open_price": 21298.67592593,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.403,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2hn3y5j8mp8935jfpsuhhn22dj-00511",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21456.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.364125,
        "commission_asset": None,
        "traded_at": "2022-09-09 08:00:00+08:00",
        "actual_traded_at": "2022-09-10 06:45:00+08:00",
        "gross_amount": 2145.65,
        "net_amount": 2151.014125,
        "is_open": False,
        "avg_open_price": 21298.67592593,
        "leverage": 5,
        "pnl": -78.912037,
        "pnl_net": -84.276162,
        "roi": -0.0074,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1tjwg6dhjzxkjkppcar65dp3ts-00512",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21307.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.32675,
        "commission_asset": None,
        "traded_at": "2022-09-09 08:00:00+08:00",
        "actual_traded_at": "2022-09-10 10:30:00+08:00",
        "gross_amount": 2130.7,
        "net_amount": 2136.02675,
        "is_open": False,
        "avg_open_price": 21298.67592593,
        "leverage": 5,
        "pnl": -4.162037,
        "pnl_net": -9.488787,
        "roi": -0.0004,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-18mppebz5xreu27ppi6yaryqzs-00513",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21580.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.395,
        "commission_asset": None,
        "traded_at": "2022-09-10 08:00:00+08:00",
        "actual_traded_at": "2022-09-10 20:00:00+08:00",
        "gross_amount": 2158.0,
        "net_amount": 2152.605,
        "is_open": True,
        "avg_open_price": 21392.45061729,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.395,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-29oh1apd2pi85x4xmqjo38o84x-00514",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21529.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.38225,
        "commission_asset": None,
        "traded_at": "2022-09-10 08:00:00+08:00",
        "actual_traded_at": "2022-09-10 20:00:00+08:00",
        "gross_amount": 2152.9,
        "net_amount": 2158.28225,
        "is_open": False,
        "avg_open_price": 21392.45061729,
        "leverage": 5,
        "pnl": -68.274691,
        "pnl_net": -73.656941,
        "roi": -0.0064,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1cbg6m8qmy7zj71g49i974cyr5-00515",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21602.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.400625,
        "commission_asset": None,
        "traded_at": "2022-09-10 08:00:00+08:00",
        "actual_traded_at": "2022-09-11 04:20:00+08:00",
        "gross_amount": 2160.25,
        "net_amount": 2154.849375,
        "is_open": True,
        "avg_open_price": 21462.46707819,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.400625,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-16rhvdbx4pepm37a3x7xkxzrz3-00516",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21546.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.386625,
        "commission_asset": None,
        "traded_at": "2022-09-10 08:00:00+08:00",
        "actual_traded_at": "2022-09-11 05:25:00+08:00",
        "gross_amount": 2154.65,
        "net_amount": 2160.036625,
        "is_open": False,
        "avg_open_price": 21462.46707819,
        "leverage": 5,
        "pnl": -42.016461,
        "pnl_net": -47.403086,
        "roi": -0.0039,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1a8bwuvzboch2kxziwome21woa-00517",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21604.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.401,
        "commission_asset": None,
        "traded_at": "2022-09-10 08:00:00+08:00",
        "actual_traded_at": "2022-09-11 06:15:00+08:00",
        "gross_amount": 2160.4,
        "net_amount": 2154.999,
        "is_open": True,
        "avg_open_price": 21509.64471879,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.401,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-21pumhk6xsk6r1tzfw6szug4ip-00518",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21380.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.345125,
        "commission_asset": None,
        "traded_at": "2022-09-10 08:00:00+08:00",
        "actual_traded_at": "2022-09-11 06:35:00+08:00",
        "gross_amount": 2138.05,
        "net_amount": 2143.395125,
        "is_open": False,
        "avg_open_price": 21509.64471879,
        "leverage": 5,
        "pnl": 64.572359,
        "pnl_net": 59.227234,
        "roi": 0.006,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-268feppf93q91vp3ooidvtrewc-00519",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21644.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.411,
        "commission_asset": None,
        "traded_at": "2022-09-10 08:00:00+08:00",
        "actual_traded_at": "2022-09-11 11:10:00+08:00",
        "gross_amount": 2164.4,
        "net_amount": 2158.989,
        "is_open": True,
        "avg_open_price": 21554.42981253,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.411,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-19wspqzga9ze97gwh63xngirkx-00520",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21621.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.405375,
        "commission_asset": None,
        "traded_at": "2022-09-10 08:00:00+08:00",
        "actual_traded_at": "2022-09-11 11:10:00+08:00",
        "gross_amount": 2162.15,
        "net_amount": 2167.555375,
        "is_open": False,
        "avg_open_price": 21554.42981253,
        "leverage": 5,
        "pnl": -33.535094,
        "pnl_net": -38.940469,
        "roi": -0.0031,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-25oavzmhrpk8cxycdh1i8vg9v3-00521",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21676.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.419,
        "commission_asset": None,
        "traded_at": "2022-09-10 08:00:00+08:00",
        "actual_traded_at": "2022-09-11 11:20:00+08:00",
        "gross_amount": 2167.6,
        "net_amount": 2162.181,
        "is_open": True,
        "avg_open_price": 21594.95320835,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.419,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-244brxf48i5xnevky51xro4vii-00522",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21646.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.4115,
        "commission_asset": None,
        "traded_at": "2022-09-10 08:00:00+08:00",
        "actual_traded_at": "2022-09-11 11:25:00+08:00",
        "gross_amount": 2164.6,
        "net_amount": 2170.0115,
        "is_open": False,
        "avg_open_price": 21594.95320835,
        "leverage": 5,
        "pnl": -25.523396,
        "pnl_net": -30.934896,
        "roi": -0.0024,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1zuk6itynmn7r1i4dpcjqin6qd-00523",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21708.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.427,
        "commission_asset": None,
        "traded_at": "2022-09-11 08:00:00+08:00",
        "actual_traded_at": "2022-09-11 23:40:00+08:00",
        "gross_amount": 2170.8,
        "net_amount": 2165.373,
        "is_open": True,
        "avg_open_price": 21632.63547223,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.427,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2hxykqxtqm8gcm75u2fkvz2jh1-00524",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21623.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.40575,
        "commission_asset": None,
        "traded_at": "2022-09-11 08:00:00+08:00",
        "actual_traded_at": "2022-09-12 01:10:00+08:00",
        "gross_amount": 2162.3,
        "net_amount": 2167.70575,
        "is_open": False,
        "avg_open_price": 21632.63547223,
        "leverage": 5,
        "pnl": 4.817736,
        "pnl_net": -0.588014,
        "roi": 0.0005,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1kyj4iry3b1i7hzmhudhzvr1dv-00525",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21844.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.461,
        "commission_asset": None,
        "traded_at": "2022-09-11 08:00:00+08:00",
        "actual_traded_at": "2022-09-12 01:25:00+08:00",
        "gross_amount": 2184.4,
        "net_amount": 2178.939,
        "is_open": True,
        "avg_open_price": 21703.09031482,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.461,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1itcm3j2a1esfkpvng134uzaa3-00526",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21925.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.48125,
        "commission_asset": None,
        "traded_at": "2022-09-11 08:00:00+08:00",
        "actual_traded_at": "2022-09-12 01:40:00+08:00",
        "gross_amount": 2192.5,
        "net_amount": 2187.01875,
        "is_open": True,
        "avg_open_price": 21758.56773612,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.48125,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1q6nreusfazw7n5ij7tqk5y489-00527",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21832.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.458125,
        "commission_asset": None,
        "traded_at": "2022-09-11 08:00:00+08:00",
        "actual_traded_at": "2022-09-12 02:10:00+08:00",
        "gross_amount": 2183.25,
        "net_amount": 2188.708125,
        "is_open": False,
        "avg_open_price": 21758.56773612,
        "leverage": 5,
        "pnl": -36.966132,
        "pnl_net": -42.424257,
        "roi": -0.0034,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-2r97jktzekpbf1g2xt6ysi83yz-00528",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 21767.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.441875,
        "commission_asset": None,
        "traded_at": "2022-09-11 08:00:00+08:00",
        "actual_traded_at": "2022-09-12 02:15:00+08:00",
        "gross_amount": 2176.75,
        "net_amount": 2182.191875,
        "is_open": False,
        "avg_open_price": 21758.56773612,
        "leverage": 5,
        "pnl": -4.466132,
        "pnl_net": -9.908007,
        "roi": -0.0004,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1wnwkza5389fvbb5ogtzp7sf2r-00529",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 21813.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.45325,
        "commission_asset": None,
        "traded_at": "2022-09-11 08:00:00+08:00",
        "actual_traded_at": "2022-09-12 06:40:00+08:00",
        "gross_amount": 2181.3,
        "net_amount": 2175.84675,
        "is_open": True,
        "avg_open_price": 21776.71182408,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.45325,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1gp2r1ztvu56887vhb3ctye71u-00530",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 22206.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.5515,
        "commission_asset": None,
        "traded_at": "2022-09-11 08:00:00+08:00",
        "actual_traded_at": "2022-09-12 07:55:00+08:00",
        "gross_amount": 2220.6,
        "net_amount": 2215.0485,
        "is_open": True,
        "avg_open_price": 21884.03386806,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.5515,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1391ga6ehzhmdox5v8t72idkqf-00531",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 22143.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.535875,
        "commission_asset": None,
        "traded_at": "2022-09-11 08:00:00+08:00",
        "actual_traded_at": "2022-09-12 08:05:00+08:00",
        "gross_amount": 2214.35,
        "net_amount": 2219.885875,
        "is_open": False,
        "avg_open_price": 21884.03386806,
        "leverage": 5,
        "pnl": -129.733066,
        "pnl_net": -135.268941,
        "roi": -0.0118,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-191ihn4rfaf84h9qkt3e7bnt25-00532",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "OPEN SHORT",
        "price": 22256.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.564125,
        "commission_asset": None,
        "traded_at": "2022-09-11 08:00:00+08:00",
        "actual_traded_at": "2022-09-12 08:10:00+08:00",
        "gross_amount": 2225.65,
        "net_amount": 2220.085875,
        "is_open": True,
        "avg_open_price": 21977.15040105,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.564125,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1y9imxt9pupqaqg72k64vxgxj7-00533",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 20240.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.060125,
        "commission_asset": None,
        "traded_at": "2022-09-12 08:00:00+08:00",
        "actual_traded_at": "2022-09-13 19:20:00+08:00",
        "gross_amount": 2024.05,
        "net_amount": 2029.110125,
        "is_open": False,
        "avg_open_price": 21977.15040105,
        "leverage": 5,
        "pnl": 868.325201,
        "pnl_net": 863.265076,
        "roi": 0.079,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-12uux32gvnxtuscnhziqh78mfp-00534",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 20313.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.078375,
        "commission_asset": None,
        "traded_at": "2022-09-13 08:00:00+08:00",
        "actual_traded_at": "2022-09-14 08:35:00+08:00",
        "gross_amount": 2031.35,
        "net_amount": 2036.428375,
        "is_open": False,
        "avg_open_price": 21977.15040105,
        "leverage": 5,
        "pnl": 831.825201,
        "pnl_net": 826.746826,
        "roi": 0.0757,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1bug2942nzgkhjp9tw7vpiw7ep-00535",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 20156.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.039,
        "commission_asset": None,
        "traded_at": "2022-09-13 08:00:00+08:00",
        "actual_traded_at": "2022-09-14 14:25:00+08:00",
        "gross_amount": 2015.6,
        "net_amount": 2020.639,
        "is_open": False,
        "avg_open_price": 21977.15040105,
        "leverage": 5,
        "pnl": 910.575201,
        "pnl_net": 905.536201,
        "roi": 0.0829,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-1uzhkgvq9t7ntfaddi11zjqan6-00536",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "CLOSE SHORT",
        "price": 19970.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 4.9925,
        "commission_asset": None,
        "traded_at": "2022-09-13 08:00:00+08:00",
        "actual_traded_at": "2022-09-14 18:05:00+08:00",
        "gross_amount": 1997.0,
        "net_amount": 2001.9925,
        "is_open": False,
        "avg_open_price": 21977.15040105,
        "leverage": 5,
        "pnl": 1003.575201,
        "pnl_net": 998.582701,
        "roi": 0.0913,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-23kyp8jrvy9j1u4ionoxf9symq-00537",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "BUY",
        "position_side": "NET",
        "action": "OPEN LONG",
        "price": 20060.0,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.015,
        "commission_asset": None,
        "traded_at": "2022-09-14 08:00:00+08:00",
        "actual_traded_at": "2022-09-15 13:15:00+08:00",
        "gross_amount": 2006.0,
        "net_amount": 2011.015,
        "is_open": True,
        "avg_open_price": 20060.0,
        "leverage": 5,
        "pnl": 0,
        "pnl_net": -5.015,
        "roi": 0.0,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    },
    {
        "order_id": "aio-1689137399-22jynhmjufmnrmo53g89j8c989-00538",
        "symbol": "BTCUSDT",
        "code": "BTCUSDT",
        "quantity": 0.5,
        "side": "SELL",
        "position_side": "NET",
        "action": "CLOSE LONG",
        "price": 20132.5,
        "exchange": "BYBIT",
        "asset_type": "PERPETUAL",
        "execution_type": "TRADE",
        "commission": 5.033125,
        "commission_asset": None,
        "traded_at": "2022-09-14 08:00:00+08:00",
        "actual_traded_at": "2022-09-15 13:50:00+08:00",
        "gross_amount": 2013.25,
        "net_amount": 2008.216875,
        "is_open": False,
        "avg_open_price": 20060.0,
        "leverage": 5,
        "pnl": 36.25,
        "pnl_net": 31.216875,
        "roi": 0.0036,
        "aio_symbol": "BTCUSDT|BYBIT",
        "aio_position_id": "BTCUSDT|BYBIT|NET"
    }    
]
from copy import deepcopy
trade_history_raw = deepcopy(trade_history)

The above trade records are directly read from records_trade.json that generated by contest_output() function.

BUT the miniumnm fields for executing the trade history, are only required ["symbol", "quantity", "price", "datetime", "side"]

In [3]:
start_date = '2022-09-07'
end_date = '2022-09-16'
code = 'BTCUSDT'
exchange='bybit'
asset_type = 'perpetual'
interval = '4h'

btc = CryptoDataFeed(
    code=code,
    exchange=exchange,
    asset_type = asset_type,
    start_date=start_date,
    end_date=end_date,
    interval=interval,
    order_ascending=True,
)
btc
BTCUSDT[4h - BYBIT] data is up-to-date now. Current date range:2022-09-07 00:00:00+08:00 <=> 2022-09-16 00:00:00+08:00
Out[3]:
<DataFeed code:BTCUSDT, symbol:BTCUSDT, asset_type:AssetType.PERPETUAL, exchange:Exchange.BYBIT, start_date:2022-09-07 00:00:00, end_date:2022-09-16 00:00:00, interval:4h, min_volume:0.001, min_notional:None, tick_size:0.1, step_size:0.001, launch_date:2020-03-15 08:00:00+08:00, delivery_date:None, commission_rate:None, taker_commission_rate:0.00055, maker_commission_rate:0.0002, is_contract:True, consider_price:True, is_inverse:None >
In [4]:
btc.dataframe.tail(5)
Out[4]:
asset_type symbol exchange name interval turnover volume close open high low
datetime
2022-09-15 08:00:00+08:00 PERPETUAL BTCUSDT BYBIT BTCUSDT 4h 481815587.377500 24001.951000 20018.500000 20220.000000 20255.000000 19912.500000
2022-09-15 12:00:00+08:00 PERPETUAL BTCUSDT BYBIT BTCUSDT 4h 698524172.029000 34719.670000 20191.500000 20018.500000 20319.000000 19945.500000
2022-09-15 16:00:00+08:00 PERPETUAL BTCUSDT BYBIT BTCUSDT 4h 318241101.166000 15818.946000 20135.500000 20191.500000 20211.500000 20023.000000
2022-09-15 20:00:00+08:00 PERPETUAL BTCUSDT BYBIT BTCUSDT 4h 1264348708.518500 63722.224000 19731.000000 20135.500000 20180.000000 19472.000000
2022-09-16 00:00:00+08:00 PERPETUAL BTCUSDT BYBIT BTCUSDT 4h 539455976.326000 27254.921000 19774.500000 19731.000000 19940.500000 19645.500000
In [5]:
class TestStrategy(Strategy):


    def initialize(self):
        pass

    def on_trade_fail(self, order):
        self.error(f"Order [number {order['order_id']}] [{order['status'].name}]. Msg: {order['msg']}")

    def on_order_fill(self, trade):
        self.info(f"({trade.aio_position_id}) - {'OPEN' if trade.is_open else 'CLOSE'} {trade['side'].name} order [number {trade['order_id']}] executed [quantity {trade['quantity']}] [price ${trade['price']:2f}] [Cost ${trade['gross_amount']:2f}] [Commission: ${trade['commission']}] [Available balance: ${self.available_balance}] [Position: #{self.ctx.get_quantity(aio_position_id=trade['aio_position_id'])}] [Gross P&L: ${trade['pnl']}] [Net P&L: ${trade['pnl_net']}] ")

        if not trade['is_open']:
            self.info(f"========> Trade closed, pnl: {trade['pnl']}")

    def on_bar(self, tick):
        return

    def finish(self):
        pass
    
In [6]:
broker = BackTestBroker(
    balance=100_000,
    slippage=0.0
    )

mytest = BackTest(
    btc,
    TestStrategy,
    statistic=Statistic(),
    benchmark=None,
    store_path=None,
    broker=broker,
    trade_history=trade_history
)
mytest.start()
2022-09-08 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN BUY order [number aio-1706867619-2a1hkovp2j-00001] executed [quantity 0.5] [price $19186.000000] [Cost $9593.000000] [Commission: $5.27615] [Available balance: $99994.72385] [Position: #0.0] [Gross P&L: $0] [Net P&L: $-5.27615] 
2022-09-08 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE SELL order [number aio-1706867619-2hqn4o5t1y-00002] executed [quantity 0.5] [price $19251.500000] [Cost $9625.750000] [Commission: $5.2941625] [Available balance: $98103.5796875] [Position: #0.5] [Gross P&L: $32.75] [Net P&L: $27.455838] 
2022-09-08 08:00:00+08:00 [INFO] ========> Trade closed, pnl: 32.75
2022-09-08 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN BUY order [number aio-1706867619-22y5fbzyq8-00003] executed [quantity 0.5] [price $19176.000000] [Cost $9588.000000] [Commission: $5.2734] [Available balance: $100016.9062875] [Position: #0.0] [Gross P&L: $0] [Net P&L: $-5.2734] 
2022-09-08 12:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN BUY order [number aio-1706867619-123nrwy8zv-00004] executed [quantity 0.5] [price $19141.000000] [Cost $9570.500000] [Commission: $5.263775] [Available balance: $98094.04251249999] [Position: #0.5] [Gross P&L: $0] [Net P&L: $-5.263775] 
2022-09-08 12:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE SELL order [number aio-1706867619-2e612n8cma-00005] executed [quantity 0.5] [price $19225.500000] [Cost $9612.750000] [Commission: $5.2870125] [Available balance: $96208.1555] [Position: #1.0] [Gross P&L: $33.5] [Net P&L: $28.212988] 
2022-09-08 12:00:00+08:00 [INFO] ========> Trade closed, pnl: 33.5
2022-09-08 16:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE SELL order [number aio-1706867619-2cec8gn1nn-00006] executed [quantity 0.5] [price $19259.500000] [Cost $9629.750000] [Commission: $5.2963625] [Available balance: $98169.20913749999] [Position: #0.5] [Gross P&L: $50.5] [Net P&L: $45.203638] 
2022-09-08 16:00:00+08:00 [INFO] ========> Trade closed, pnl: 50.5
2022-09-09 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-123g9dd4s6-00007] executed [quantity 0.5] [price $19993.000000] [Cost $9996.500000] [Commission: $5.498075] [Available balance: $100079.5610625] [Position: #0.0] [Gross P&L: $0] [Net P&L: $-5.498075] 
2022-09-09 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-2fmmbfeabc-00008] executed [quantity 0.5] [price $20193.500000] [Cost $10096.750000] [Commission: $5.5532125] [Available balance: $98074.70784999999] [Position: #-0.5] [Gross P&L: $0] [Net P&L: $-5.553212] 
2022-09-09 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-27hyzuwjj6-00009] executed [quantity 0.5] [price $20333.000000] [Cost $10166.500000] [Commission: $5.591575] [Available balance: $96049.766275] [Position: #-1.0] [Gross P&L: $0] [Net P&L: $-5.591575] 
2022-09-09 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-16mb7ssj7a-00010] executed [quantity 0.5] [price $20322.000000] [Cost $10161.000000] [Commission: $5.58855] [Available balance: $93936.461058] [Position: #-1.5] [Gross P&L: $-74.416667] [Net P&L: $-80.005217] 
2022-09-09 00:00:00+08:00 [INFO] ========> Trade closed, pnl: -74.416667
2022-09-09 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-2dcdwwi2x9-00011] executed [quantity 0.5] [price $20318.000000] [Cost $10159.000000] [Commission: $5.58745] [Available balance: $95948.19027499999] [Position: #-1.0] [Gross P&L: $0] [Net P&L: $-5.58745] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1hbeidk32e-00012] executed [quantity 0.5] [price $20894.000000] [Cost $10447.000000] [Commission: $5.74585] [Available balance: $93910.64442499999] [Position: #-1.5] [Gross P&L: $0] [Net P&L: $-5.74585] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-2fxg8j97e8-00013] executed [quantity 0.5] [price $21039.500000] [Cost $10519.750000] [Commission: $5.7858625] [Available balance: $91815.45856249999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.785862] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-24bn8s3nzs-00014] executed [quantity 0.5] [price $20945.500000] [Cost $10472.750000] [Commission: $5.7600125] [Available balance: $89492.78188299999] [Position: #-2.5] [Gross P&L: $-212.966667] [Net P&L: $-218.726679] 
2022-09-09 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -212.966667
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1ugdpmgyk6-00015] executed [quantity 0.5] [price $20997.500000] [Cost $10498.750000] [Commission: $5.7743125] [Available balance: $91538.96423649999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.774312] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-18i7d4ztai-00016] executed [quantity 0.5] [price $20960.000000] [Cost $10480.000000] [Commission: $5.764] [Available balance: $89261.0269035] [Position: #-2.5] [Gross P&L: $-172.423333] [Net P&L: $-178.187333] 
2022-09-09 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -172.423333
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-267wrimhva-00017] executed [quantity 0.5] [price $21004.000000] [Cost $10502.000000] [Commission: $5.7761] [Available balance: $91316.76613749999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.7761] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-25dm2gg3r6-00018] executed [quantity 0.5] [price $21084.000000] [Cost $10542.000000] [Commission: $5.7981] [Available balance: $89210.5680375] [Position: #-2.5] [Gross P&L: $0] [Net P&L: $-5.7981] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-2jzsmj3kj5-00019] executed [quantity 0.5] [price $21016.500000] [Cost $10508.250000] [Commission: $5.7795375] [Available balance: $86967.18961099998] [Position: #-3.0] [Gross P&L: $-129.198889] [Net P&L: $-134.978426] 
2022-09-09 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -129.198889
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-27p6ufwz5b-00020] executed [quantity 0.5] [price $20965.500000] [Cost $10482.750000] [Commission: $5.7655125] [Available balance: $88933.5354315] [Position: #-2.5] [Gross P&L: $-103.698889] [Net P&L: $-109.464401] 
2022-09-09 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -103.698889
2022-09-09 12:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-25sov2t4ds-00021] executed [quantity 0.5] [price $21208.000000] [Cost $10604.000000] [Commission: $5.8322] [Available balance: $91003.5134535] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.8322] 
2022-09-09 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-1tkvo43pbs-00022] executed [quantity 0.5] [price $21190.500000] [Cost $10595.250000] [Commission: $5.8273875] [Available balance: $88705.67695499999] [Position: #-2.5] [Gross P&L: $-171.209111] [Net P&L: $-177.036498] 
2022-09-09 20:00:00+08:00 [INFO] ========> Trade closed, pnl: -171.209111
2022-09-09 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-25x575z13y-00023] executed [quantity 0.5] [price $21300.000000] [Cost $10650.000000] [Commission: $5.8575] [Available balance: $90784.62763299998] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.8575] 
2022-09-10 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-2ocrmzwx2c-00024] executed [quantity 0.5] [price $21240.500000] [Cost $10620.250000] [Commission: $5.8411375] [Available balance: $88497.76920649999] [Position: #-2.5] [Gross P&L: $-151.017289] [Net P&L: $-156.858426] 
2022-09-10 00:00:00+08:00 [INFO] ========> Trade closed, pnl: -151.017289
2022-09-10 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1rhee34z82-00025] executed [quantity 0.5] [price $21345.000000] [Cost $10672.500000] [Commission: $5.869875] [Available balance: $90585.74587349998] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.869875] 
2022-09-10 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-121tdp847x-00026] executed [quantity 0.5] [price $21612.000000] [Cost $10806.000000] [Commission: $5.9433] [Available balance: $88445.30257349998] [Position: #-2.5] [Gross P&L: $0] [Net P&L: $-5.9433] 
2022-09-10 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-2eks1iy9rb-00027] executed [quantity 0.5] [price $21456.500000] [Cost $10728.250000] [Commission: $5.9005375] [Available balance: $86109.19050999999] [Position: #-3.0] [Gross P&L: $-169.011526] [Net P&L: $-174.912063] 
2022-09-10 04:00:00+08:00 [INFO] ========> Trade closed, pnl: -169.011526
2022-09-10 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-1yo6nvfj2p-00028] executed [quantity 0.5] [price $21307.000000] [Cost $10653.500000] [Commission: $5.859425] [Available balance: $88120.91725399999] [Position: #-2.5] [Gross P&L: $-94.261526] [Net P&L: $-100.120951] 
2022-09-10 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -94.261526
2022-09-10 16:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1hqifg9h3y-00029] executed [quantity 0.5] [price $21580.000000] [Cost $10790.000000] [Commission: $5.9345] [Available balance: $90226.83044899999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.9345] 
2022-09-10 16:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-1g43werg5o-00030] executed [quantity 0.5] [price $21529.000000] [Cost $10764.500000] [Commission: $5.920475] [Available balance: $87903.80075299999] [Position: #-2.5] [Gross P&L: $-159.109221] [Net P&L: $-165.029696] 
2022-09-10 16:00:00+08:00 [INFO] ========> Trade closed, pnl: -159.109221
2022-09-11 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-15r1wmrrpb-00031] executed [quantity 0.5] [price $21602.500000] [Cost $10801.250000] [Commission: $5.9406875] [Available balance: $90018.93822049999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.940687] 
2022-09-11 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-15m6uzek79-00032] executed [quantity 0.5] [price $21546.500000] [Cost $10773.250000] [Commission: $5.9252875] [Available balance: $87724.07555699999] [Position: #-2.5] [Gross P&L: $-128.687376] [Net P&L: $-134.612663] 
2022-09-11 00:00:00+08:00 [INFO] ========> Trade closed, pnl: -128.687376
2022-09-11 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1ah4a5mrxh-00033] executed [quantity 0.5] [price $21604.000000] [Cost $10802.000000] [Commission: $5.9411] [Available balance: $89847.04698199999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.9411] 
2022-09-11 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-2img72d6x6-00034] executed [quantity 0.5] [price $21380.500000] [Cost $10690.250000] [Commission: $5.8796375] [Available balance: $87666.5674435] [Position: #-2.5] [Gross P&L: $-14.199901] [Net P&L: $-20.079538] 
2022-09-11 04:00:00+08:00 [INFO] ========> Trade closed, pnl: -14.199901
2022-09-11 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-16jrt4dneo-00035] executed [quantity 0.5] [price $21621.500000] [Cost $10810.750000] [Commission: $5.9459125] [Available balance: $89661.13165] [Position: #-2.0] [Gross P&L: $-134.699901] [Net P&L: $-140.645813] 
2022-09-11 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -134.699901
2022-09-11 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1x6utabm5j-00036] executed [quantity 0.5] [price $21644.000000] [Cost $10822.000000] [Commission: $5.9521] [Available balance: $91790.38957] [Position: #-1.5] [Gross P&L: $0] [Net P&L: $-5.9521] 
2022-09-11 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-2q7tg15yc3-00037] executed [quantity 0.5] [price $21676.000000] [Cost $10838.000000] [Commission: $5.9609] [Available balance: $89620.02867] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.9609] 
2022-09-11 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-2ben2biqqf-00038] executed [quantity 0.5] [price $21646.000000] [Cost $10823.000000] [Commission: $5.95265] [Available balance: $87361.10607899999] [Position: #-2.5] [Gross P&L: $-85.369941] [Net P&L: $-91.322591] 
2022-09-11 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -85.369941
2022-09-11 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1g13bwokqj-00039] executed [quantity 0.5] [price $21708.000000] [Cost $10854.000000] [Commission: $5.9697] [Available balance: $89502.66239099999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.9697] 
2022-09-11 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-1nkotie8w8-00040] executed [quantity 0.5] [price $21623.000000] [Cost $10811.500000] [Commission: $5.946325] [Available balance: $87275.320113] [Position: #-2.5] [Gross P&L: $-50.595953] [Net P&L: $-56.542278] 
2022-09-11 20:00:00+08:00 [INFO] ========> Trade closed, pnl: -50.595953
2022-09-11 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1di6e4tr8g-00041] executed [quantity 0.5] [price $21844.000000] [Cost $10922.000000] [Commission: $6.0071] [Available balance: $89421.49382199999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-6.0071] 
2022-09-11 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-141obwa62b-00042] executed [quantity 0.5] [price $21925.000000] [Cost $10962.500000] [Commission: $6.029375] [Available balance: $87231.064447] [Position: #-2.5] [Gross P&L: $0] [Net P&L: $-6.029375] 
2022-09-12 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-1kwmwamt1a-00043] executed [quantity 0.5] [price $21832.500000] [Cost $10916.250000] [Commission: $6.0039375] [Available balance: $84937.6632075] [Position: #-3.0] [Gross P&L: $-94.897302] [Net P&L: $-100.901239] 
2022-09-12 00:00:00+08:00 [INFO] ========> Trade closed, pnl: -94.897302
2022-09-12 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-1cieo25f4a-00044] executed [quantity 0.5] [price $21767.500000] [Cost $10883.750000] [Commission: $5.9860625] [Available balance: $87033.550383] [Position: #-2.5] [Gross P&L: $-62.397302] [Net P&L: $-68.383364] 
2022-09-12 00:00:00+08:00 [INFO] ========> Trade closed, pnl: -62.397302
2022-09-12 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1u93r8uqp5-00045] executed [quantity 0.5] [price $21813.000000] [Cost $10906.500000] [Commission: $5.998575] [Available balance: $89191.822347] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.998575] 
2022-09-12 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1r8op8hqbf-00046] executed [quantity 0.5] [price $22206.000000] [Cost $11103.000000] [Commission: $6.10665] [Available balance: $87004.41569699999] [Position: #-2.5] [Gross P&L: $0] [Net P&L: $-6.10665] 
2022-09-12 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-2e6ovm63er-00047] executed [quantity 0.5] [price $22143.500000] [Cost $11071.750000] [Commission: $6.0894625] [Available balance: $84588.46136649998] [Position: #-3.0] [Gross P&L: $-189.264868] [Net P&L: $-195.35433] 
2022-09-12 04:00:00+08:00 [INFO] ========> Trade closed, pnl: -189.264868
2022-09-12 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1gf24bduq5-00048] executed [quantity 0.5] [price $22256.500000] [Cost $11128.250000] [Commission: $6.1205375] [Available balance: $86758.83785599998] [Position: #-2.5] [Gross P&L: $0] [Net P&L: $-6.120537] 
2022-09-13 16:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-25c9xs9zb4-00049] executed [quantity 0.5] [price $20240.500000] [Cost $10120.250000] [Commission: $5.5661375] [Available balance: $85330.81766249999] [Position: #-3.0] [Gross P&L: $803.195944] [Net P&L: $797.629807] 
2022-09-13 16:00:00+08:00 [INFO] ========> Trade closed, pnl: 803.195944
2022-09-14 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-269pzxvs8p-00050] executed [quantity 0.5] [price $20313.500000] [Cost $10156.750000] [Commission: $5.5862125] [Available balance: $88276.61658199999] [Position: #-2.5] [Gross P&L: $766.695944] [Net P&L: $761.109732] 
2022-09-14 04:00:00+08:00 [INFO] ========> Trade closed, pnl: 766.695944
2022-09-14 12:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-17n383tv2b-00051] executed [quantity 0.5] [price $20156.000000] [Cost $10078.000000] [Commission: $5.5429] [Available balance: $91301.20881499999] [Position: #-2.0] [Gross P&L: $845.445944] [Net P&L: $839.903044] 
2022-09-14 12:00:00+08:00 [INFO] ========> Trade closed, pnl: 845.445944
2022-09-14 16:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-2ppr36jefj-00052] executed [quantity 0.5] [price $19970.000000] [Cost $9985.000000] [Commission: $5.49175] [Available balance: $94418.852198] [Position: #-1.5] [Gross P&L: $938.445944] [Net P&L: $932.954194] 
2022-09-14 16:00:00+08:00 [INFO] ========> Trade closed, pnl: 938.445944
2022-09-15 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867619-1igsjf31ae-00053] executed [quantity 0.5] [price $20060.000000] [Cost $10030.000000] [Commission: $5.5165] [Available balance: $97491.47083099998] [Position: #-1.0] [Gross P&L: $893.445944] [Net P&L: $887.929444] 
2022-09-15 08:00:00+08:00 [INFO] ========> Trade closed, pnl: 893.445944
2022-09-15 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867619-1mmr329mpa-00054] executed [quantity 0.5] [price $20132.500000] [Cost $10066.250000] [Commission: $5.5364375] [Available balance: $99670.62358149998] [Position: #-0.5] [Gross P&L: $0] [Net P&L: $-5.536437] 
In [7]:
stats = mytest.ctx.statistic.stats(interval=interval)
stats
Out[7]:
start                                                   2022-09-07 00:00:00+08:00
end                                                     2022-09-16 00:00:00+08:00
interval                                                                       4h
duration                                                          9 days 00:00:00
trading_instruments                                                     [BTCUSDT]
base_currency                                                                USDT
benchmark                                                                     N/A
beginning_balance                                                          100000
ending_balance                                                      103070.508710
available_balance                                                   101855.312770
holding_values                                                        1215.195940
capital                                                                    100000
additional_capitals                                                            {}
net_investment                                                       65540.675660
total_net_profit                                                      3070.508710
total_commission                                                       311.241290
total_turnover                                                      565893.250000
profit_factor                                                            1.328310
return_on_capital                                                        0.030705
return_on_initial_capital                                                0.030705
return_on_investment                                                     0.046849
annualized_return                                                        2.409355
total_return                                                             0.030705
max_return                                                               0.031140
min_return                                                              -0.043855
past_24hr_pnl                                                          191.197100
past_24hr_apr                                                            0.678535
past_24hr_roi                                                            0.001859
past_7d_roi                                                              0.029829
past_14d_roi                                                             0.030705
past_30d_roi                                                             0.030705
past_90d_roi                                                             0.030705
past_180d_roi                                                            0.030705
past_1yr_roi                                                             0.030705
trading_period                                    0 years 0 months 9 days 0 hours
avg_holding_period(hrs)                                                 11.900000
pct_time_in_market                                                       0.800000
number_trades                                                                  54
number_closed_trades                                                           26
number_winning_trades                                                           8
number_losing_trades                                                           18
number_winning_long_trades                                                      3
number_losing_long_trades                                                       0
number_winning_short_trades                                                     5
number_losing_short_trades                                                     18
number_liquidation_trades                                                       0
avg_daily_trades                                                         9.000000
avg_weekly_trades                                                       27.000000
avg_monthly_trades                                                      54.000000
win_ratio                                                                0.307692
loss_ratio                                                               0.692308
win_ratio_long                                                           1.000000
loss_ratio_long                                                          0.000000
win_ratio_short                                                          1.666667
loss_ratio_short                                                         6.000000
gross_trades_profit                                                   4363.979700
gross_trades_loss                                                    -2197.425700
gross_winning_trades_amount                                          79238.250000
gross_losing_trades_amount                                          192247.000000
avg_winning_trades_pnl                                                 545.497462
avg_losing_trades_pnl                                                 -122.079206
avg_winning_trades_amount                                             9904.781250
avg_losing_trades_amount                                              4402.125000
largest_profit_winning_trade                                           938.446000
largest_loss_losing_trade                                             -212.966700
avg_amount_per_trade                                                 10479.504600
avg_amount_per_open_trade                                            10514.571400
avg_amount_per_closed_trade                                          10441.740400
avg_amount_per_long_trade                                             9603.291700
avg_amount_per_short_trade                                           10589.031300
avg_pnl_per_trade($)                                                    83.329000
avg_pnl_per_trade                                                        0.000800
max_consecutive_win_trades                                                      5
max_consecutive_loss_trades                                                    18
payoff_ratio                                                            -4.468400
expected_value                                                          83.330000
standardized_expected_value                                              0.840000
win_days                                                                        3
loss_days                                                                       4
max_win_in_day                                                        1372.500000
max_loss_in_day                                                       -904.500000
max_consecutive_win_days                                                        2
max_consecutive_loss_days                                                       2
avg_daily_pnl($)                                                       341.167600
avg_daily_pnl                                                            0.003501
avg_weekly_pnl($)                                                     5272.252300
avg_weekly_pnl                                                           0.053910
avg_monthly_pnl($)                                                           None
avg_monthly_pnl                                                              None
avg_quarterly_pnl($)                                                         None
avg_quarterly_pnl                                                            None
avg_annualy_pnl($)                                                           None
avg_annualy_pnl                                                              None
var                                                                   1421.948000
risk_score                                                                      1
avg_daily_risk_score                                                     0.000000
avg_risk_score_past_7days                                                0.000000
monthly_avg_risk_score                               {'2022-09-16 00:00:00': 0.0}
frequently_traded               [{'symbol': 'BTCUSDT', 'asset_type': 'PERPETUA...
sharpe_ratio                                                             3.064182
sortino_ratio                                                            7.310267
annualized_volatility                                                    0.425172
omega_ratio                                                              1.342815
downside_risk                                                            0.176588
information_ratio                                                            None
beta                                                                         None
alpha                                                                        None
calmar_ratio                                                            42.517029
tail_ratio                                                               1.034608
common_sense_ratio                                                       1.374280
skew                                                                     4.303867
kurtosis                                                                26.631822
stability_of_timeseries                                                  0.069314
max_drawdown                                                             0.056668
max_drawdown_period             (2022-09-09 04:00:00+08:00, 2022-09-13 16:00:0...
max_drawdown_duration                                             4 days 12:00:00
max_runup                                                                0.078435
max_runup_period                (2022-09-13 16:00:00+08:00, 2022-09-15 20:00:0...
max_runup_duration                                                2 days 04:00:00
sqn                                                                      1.094557
rolling_sharpe                  {'2022-09-07 00:00:00': None, '2022-09-08 00:0...
monthly_changes                                      {'2022-09-16 00:00:00': 0.0}
daily_changes                   {'2022-09-07 00:00:00': 0.0, '2022-09-08 00:00...
drawdown_series                 {'2022-09-07 00:00:00': 0.0, '2022-09-07 04:00...
positions                       [PositionData(symbol='BTCUSDT', code='BTCUSDT'...
trades                          [TradeData(order_id='aio-1706867619-2a1hkovp2j...
pnl                             [{'available_balance': 100000.0, 'holding_valu...
Name: value, dtype: object
In [8]:
mytest.ctx.statistic.plot()
Loading BokehJS ...
Loading BokehJS ...

Transfer history

["asset", "amount", "datetime", "inout"]

In [ ]:
 
In [19]:
transfer_history = [
    {
        "asset": 'USDT', 
        "amount": 1000, 
        "datetime": '2022-09-09 10:20:00+08:00', 
        "inout": 'in'
    },
    {
        "asset": 'USDT', 
        "amount": 5000, 
        "datetime": '2022-09-10 10:20:00+08:00', 
        "inout": 'out'
    },
    {
        "asset": 'USDT', 
        "amount": 50000, 
        "datetime": '2022-09-14 10:20:00+08:00', 
        "inout": 'out'
    },
    {
        "asset": 'USDT', 
        "amount": 500.32, 
        "datetime": '2022-09-15 10:20:00+08:00', 
        "inout": 'in'
    },    
]

As mentioned before, the miniumnm fields for executing the trade history, are only required ["symbol", "quantity", "price", "datetime", "side"]

The backtest result will be different since the leverage field didnot use.

In [20]:
trade_history = []
for th in trade_history_raw:
    trade_history.append({
        "symbol" : th['symbol'], 
        "quantity" : th['quantity'],
        "price" : th['price'],
        "datetime" : th['actual_traded_at'],
        "side" : th['side'],
        "asset_type" : th['asset_type'],
    })
trade_history
Out[20]:
[{'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 19186.0,
  'datetime': '2022-09-08 10:20:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 19251.5,
  'datetime': '2022-09-08 13:40:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 19176.0,
  'datetime': '2022-09-08 13:45:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 19225.5,
  'datetime': '2022-09-08 14:25:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 19141.0,
  'datetime': '2022-09-08 14:25:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 19259.5,
  'datetime': '2022-09-08 19:30:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20193.5,
  'datetime': '2022-09-09 04:00:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 19993.0,
  'datetime': '2022-09-09 04:00:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20322.0,
  'datetime': '2022-09-09 04:40:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20333.0,
  'datetime': '2022-09-09 04:40:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20318.0,
  'datetime': '2022-09-09 04:50:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20894.0,
  'datetime': '2022-09-09 10:30:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21039.5,
  'datetime': '2022-09-09 10:55:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20945.5,
  'datetime': '2022-09-09 11:10:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20997.5,
  'datetime': '2022-09-09 11:30:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20960.0,
  'datetime': '2022-09-09 11:40:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21004.0,
  'datetime': '2022-09-09 12:10:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21084.0,
  'datetime': '2022-09-09 12:30:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21016.5,
  'datetime': '2022-09-09 13:00:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20965.5,
  'datetime': '2022-09-09 13:20:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21208.0,
  'datetime': '2022-09-09 14:55:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21190.5,
  'datetime': '2022-09-10 00:30:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21300.0,
  'datetime': '2022-09-10 01:10:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21240.5,
  'datetime': '2022-09-10 02:10:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21345.0,
  'datetime': '2022-09-10 03:40:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21612.0,
  'datetime': '2022-09-10 05:20:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21456.5,
  'datetime': '2022-09-10 06:45:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21307.0,
  'datetime': '2022-09-10 10:30:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21580.0,
  'datetime': '2022-09-10 20:00:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21529.0,
  'datetime': '2022-09-10 20:00:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21602.5,
  'datetime': '2022-09-11 04:20:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21546.5,
  'datetime': '2022-09-11 05:25:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21604.0,
  'datetime': '2022-09-11 06:15:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21380.5,
  'datetime': '2022-09-11 06:35:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21644.0,
  'datetime': '2022-09-11 11:10:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21621.5,
  'datetime': '2022-09-11 11:10:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21676.0,
  'datetime': '2022-09-11 11:20:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21646.0,
  'datetime': '2022-09-11 11:25:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21708.0,
  'datetime': '2022-09-11 23:40:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21623.0,
  'datetime': '2022-09-12 01:10:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21844.0,
  'datetime': '2022-09-12 01:25:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21925.0,
  'datetime': '2022-09-12 01:40:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21832.5,
  'datetime': '2022-09-12 02:10:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21767.5,
  'datetime': '2022-09-12 02:15:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 21813.0,
  'datetime': '2022-09-12 06:40:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 22206.0,
  'datetime': '2022-09-12 07:55:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 22143.5,
  'datetime': '2022-09-12 08:05:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 22256.5,
  'datetime': '2022-09-12 08:10:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20240.5,
  'datetime': '2022-09-13 19:20:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20313.5,
  'datetime': '2022-09-14 08:35:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20156.0,
  'datetime': '2022-09-14 14:25:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 19970.0,
  'datetime': '2022-09-14 18:05:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20060.0,
  'datetime': '2022-09-15 13:15:00+08:00',
  'side': 'BUY',
  'asset_type': 'PERPETUAL'},
 {'symbol': 'BTCUSDT',
  'quantity': 0.5,
  'price': 20132.5,
  'datetime': '2022-09-15 13:50:00+08:00',
  'side': 'SELL',
  'asset_type': 'PERPETUAL'}]
In [ ]:
 
In [21]:
broker = BackTestBroker(
    balance=100_000,
    slippage=0.0
    )

mytest = BackTest(
    btc,
    TestStrategy,
    statistic=Statistic(),
    benchmark=None,
    store_path=None,
    broker=broker,
    trade_history=trade_history,
    transfer_history=transfer_history,
)
mytest.start()
2022-09-08 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN BUY order [number aio-1706867703-1p9pfx1dms-00001] executed [quantity 0.5] [price $19186.000000] [Cost $9593.000000] [Commission: $5.27615] [Available balance: $99994.72385] [Position: #0.0] [Gross P&L: $0] [Net P&L: $-5.27615] 
2022-09-08 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE SELL order [number aio-1706867703-2fkn6rpin3-00002] executed [quantity 0.5] [price $19251.500000] [Cost $9625.750000] [Commission: $5.2941625] [Available balance: $90429.1796875] [Position: #0.5] [Gross P&L: $32.75] [Net P&L: $27.455838] 
2022-09-08 08:00:00+08:00 [INFO] ========> Trade closed, pnl: 32.75
2022-09-08 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN BUY order [number aio-1706867703-2db91nvs5p-00003] executed [quantity 0.5] [price $19176.000000] [Cost $9588.000000] [Commission: $5.2734] [Available balance: $100016.9062875] [Position: #0.0] [Gross P&L: $0] [Net P&L: $-5.2734] 
2022-09-08 12:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE SELL order [number aio-1706867703-2nnduc7aw6-00004] executed [quantity 0.5] [price $19225.500000] [Cost $9612.750000] [Commission: $5.2870125] [Available balance: $90448.36927499999] [Position: #0.5] [Gross P&L: $24.75] [Net P&L: $19.462988] 
2022-09-08 12:00:00+08:00 [INFO] ========> Trade closed, pnl: 24.75
2022-09-08 12:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN BUY order [number aio-1706867703-2nhh2hfuyb-00005] executed [quantity 0.5] [price $19141.000000] [Cost $9570.500000] [Commission: $5.263775] [Available balance: $100031.10549999999] [Position: #0.0] [Gross P&L: $0] [Net P&L: $-5.263775] 
2022-09-08 16:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE SELL order [number aio-1706867703-1tdqapfffq-00006] executed [quantity 0.5] [price $19259.500000] [Cost $9629.750000] [Commission: $5.2963625] [Available balance: $90514.5591375] [Position: #0.5] [Gross P&L: $59.25] [Net P&L: $53.953638] 
2022-09-08 16:00:00+08:00 [INFO] ========> Trade closed, pnl: 59.25
2022-09-09 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-2m3phe7qa3-00007] executed [quantity 0.5] [price $20193.500000] [Cost $10096.750000] [Commission: $5.5532125] [Available balance: $100079.50592499999] [Position: #0.0] [Gross P&L: $0] [Net P&L: $-5.553212] 
2022-09-09 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-259y5kwd2j-00008] executed [quantity 0.5] [price $19993.000000] [Cost $9996.500000] [Commission: $5.498075] [Available balance: $89977.25785] [Position: #-0.5] [Gross P&L: $0] [Net P&L: $-5.498075] 
2022-09-09 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-1q917vuwj1-00009] executed [quantity 0.5] [price $20322.000000] [Cost $10161.000000] [Commission: $5.58855] [Available balance: $79860.7943] [Position: #-1.0] [Gross P&L: $-114.375] [Net P&L: $-119.96355] 
2022-09-09 00:00:00+08:00 [INFO] ========> Trade closed, pnl: -114.375
2022-09-09 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-262w6sck96-00010] executed [quantity 0.5] [price $20333.000000] [Cost $10166.500000] [Commission: $5.591575] [Available balance: $89901.827725] [Position: #-0.5] [Gross P&L: $0] [Net P&L: $-5.591575] 
2022-09-09 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-28b5k61nna-00011] executed [quantity 0.5] [price $20318.000000] [Cost $10159.000000] [Commission: $5.58745] [Available balance: $79729.74027499999] [Position: #-1.0] [Gross P&L: $0] [Net P&L: $-5.58745] 
2022-09-09 08:00:00+08:00 [WARNING] The balance is added $ 1000.0
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-29m5fmamzn-00012] executed [quantity 0.5] [price $20894.000000] [Cost $10447.000000] [Commission: $5.74585] [Available balance: $70564.99442499998] [Position: #-1.5] [Gross P&L: $0] [Net P&L: $-5.74585] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-1wi1bqvvjc-00013] executed [quantity 0.5] [price $21039.500000] [Cost $10519.750000] [Commission: $5.7858625] [Available balance: $60112.20856249999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.785862] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-2of5uoggip-00014] executed [quantity 0.5] [price $20945.500000] [Cost $10472.750000] [Commission: $5.7600125] [Available balance: $49381.723549999995] [Position: #-2.5] [Gross P&L: $-204.975] [Net P&L: $-210.735012] 
2022-09-09 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -204.975
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-2d239t221n-00015] executed [quantity 0.5] [price $20997.500000] [Cost $10498.750000] [Commission: $5.7743125] [Available balance: $59643.7242375] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.774312] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-2i7fpu9z69-00016] executed [quantity 0.5] [price $20960.000000] [Cost $10480.000000] [Commission: $5.764] [Available balance: $48973.180237500004] [Position: #-2.5] [Gross P&L: $-166.03] [Net P&L: $-171.794] 
2022-09-09 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -166.03
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-1hqd9vc9ib-00017] executed [quantity 0.5] [price $21004.000000] [Cost $10502.000000] [Commission: $5.7761] [Available balance: $59281.3741375] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.7761] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-1mgpeq72jk-00018] executed [quantity 0.5] [price $21084.000000] [Cost $10542.000000] [Commission: $5.7981] [Available balance: $48773.5760375] [Position: #-2.5] [Gross P&L: $0] [Net P&L: $-5.7981] 
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-27zuaiigb7-00019] executed [quantity 0.5] [price $21016.500000] [Cost $10508.250000] [Commission: $5.7795375] [Available balance: $38100.859833] [Position: #-3.0] [Gross P&L: $-124.936667] [Net P&L: $-130.716204] 
2022-09-09 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -124.936667
2022-09-09 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-1cqnsz9sk5-00020] executed [quantity 0.5] [price $20965.500000] [Cost $10482.750000] [Commission: $5.7655125] [Available balance: $48378.9709865] [Position: #-2.5] [Gross P&L: $-99.436667] [Net P&L: $-105.202179] 
2022-09-09 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -99.436667
2022-09-09 12:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-112cumqycm-00021] executed [quantity 0.5] [price $21208.000000] [Cost $10604.000000] [Commission: $5.8322] [Available balance: $58756.45212049999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.8322] 
2022-09-09 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-2pehqosvu4-00022] executed [quantity 0.5] [price $21190.500000] [Cost $10595.250000] [Commission: $5.8273875] [Available balance: $47978.82539999999] [Position: #-2.5] [Gross P&L: $-167.799333] [Net P&L: $-173.62672] 
2022-09-09 20:00:00+08:00 [INFO] ========> Trade closed, pnl: -167.799333
2022-09-09 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-2b7t13tg7x-00023] executed [quantity 0.5] [price $21300.000000] [Cost $10650.000000] [Commission: $5.8575] [Available balance: $58400.418565999986] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.8575] 
2022-09-10 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-2n5ngdak15-00024] executed [quantity 0.5] [price $21240.500000] [Cost $10620.250000] [Commission: $5.8411375] [Available balance: $47596.28796149999] [Position: #-2.5] [Gross P&L: $-148.289467] [Net P&L: $-154.130604] 
2022-09-10 00:00:00+08:00 [INFO] ========> Trade closed, pnl: -148.289467
2022-09-10 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-1ar9ojzzih-00025] executed [quantity 0.5] [price $21345.000000] [Cost $10672.500000] [Commission: $5.869875] [Available balance: $58062.37862049999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.869875] 
2022-09-10 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-1cymbfy2t7-00026] executed [quantity 0.5] [price $21612.000000] [Cost $10806.000000] [Commission: $5.9433] [Available balance: $47383.93532049999] [Position: #-2.5] [Gross P&L: $0] [Net P&L: $-5.9433] 
2022-09-10 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-1xihbuyr5k-00027] executed [quantity 0.5] [price $21456.500000] [Cost $10728.250000] [Commission: $5.9005375] [Available balance: $36404.84180499999] [Position: #-3.0] [Gross P&L: $-167.192978] [Net P&L: $-173.093515] 
2022-09-10 04:00:00+08:00 [INFO] ========> Trade closed, pnl: -167.192978
2022-09-10 08:00:00+08:00 [WARNING] The balance is deducted $ -5000.0
2022-09-10 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-162dw8o92n-00028] executed [quantity 0.5] [price $21307.000000] [Cost $10653.500000] [Commission: $5.859425] [Available balance: $41867.596423999996] [Position: #-2.5] [Gross P&L: $-92.442978] [Net P&L: $-98.302403] 
2022-09-10 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -92.442978
2022-09-10 16:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-18g31yvngs-00029] executed [quantity 0.5] [price $21580.000000] [Cost $10790.000000] [Commission: $5.9345] [Available balance: $52422.71894599999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.9345] 
2022-09-10 16:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-1qtbitk8m7-00030] executed [quantity 0.5] [price $21529.000000] [Cost $10764.500000] [Commission: $5.920475] [Available balance: $41469.144088999994] [Position: #-2.5] [Gross P&L: $-157.654382] [Net P&L: $-163.574857] 
2022-09-10 16:00:00+08:00 [INFO] ========> Trade closed, pnl: -157.654382
2022-09-11 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-1vxcfob15y-00031] executed [quantity 0.5] [price $21602.500000] [Cost $10801.250000] [Commission: $5.9406875] [Available balance: $52070.049019499995] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.940687] 
2022-09-11 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-29671v68ca-00032] executed [quantity 0.5] [price $21546.500000] [Cost $10773.250000] [Commission: $5.9252875] [Available balance: $41135.35022599999] [Position: #-2.5] [Gross P&L: $-127.523506] [Net P&L: $-133.448793] 
2022-09-11 00:00:00+08:00 [INFO] ========> Trade closed, pnl: -127.523506
2022-09-11 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-1tyye86tp2-00033] executed [quantity 0.5] [price $21604.000000] [Cost $10802.000000] [Commission: $5.9411] [Available balance: $51775.13561999999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.9411] 
2022-09-11 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-2gny6dd28g-00034] executed [quantity 0.5] [price $21380.500000] [Cost $10690.250000] [Commission: $5.8796375] [Available balance: $40953.98717749999] [Position: #-2.5] [Gross P&L: $-13.268805] [Net P&L: $-19.148442] 
2022-09-11 04:00:00+08:00 [INFO] ========> Trade closed, pnl: -13.268805
2022-09-11 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-27uf2jgtkw-00035] executed [quantity 0.5] [price $21644.000000] [Cost $10822.000000] [Commission: $5.9521] [Available balance: $51625.0162725] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.9521] 
2022-09-11 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-2dg3xdjj2j-00036] executed [quantity 0.5] [price $21621.500000] [Cost $10810.750000] [Commission: $5.9459125] [Available balance: $40692.305316] [Position: #-2.5] [Gross P&L: $-104.765044] [Net P&L: $-110.710956] 
2022-09-11 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -104.765044
2022-09-11 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-2cb4dctagv-00037] executed [quantity 0.5] [price $21676.000000] [Cost $10838.000000] [Commission: $5.9609] [Available balance: $51392.32937299999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.9609] 
2022-09-11 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-14389yqb4j-00038] executed [quantity 0.5] [price $21646.000000] [Cost $10823.000000] [Commission: $5.95265] [Available balance: $40457.76468799999] [Position: #-2.5] [Gross P&L: $-90.612035] [Net P&L: $-96.564685] 
2022-09-11 08:00:00+08:00 [INFO] ========> Trade closed, pnl: -90.612035
2022-09-11 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-29uoznuub7-00039] executed [quantity 0.5] [price $21708.000000] [Cost $10854.000000] [Commission: $5.9697] [Available balance: $51184.18295299999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.9697] 
2022-09-11 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-1s87ez1dm9-00040] executed [quantity 0.5] [price $21623.000000] [Cost $10811.500000] [Commission: $5.946325] [Available balance: $40269.44699999999] [Position: #-2.5] [Gross P&L: $-54.789628] [Net P&L: $-60.735953] 
2022-09-11 20:00:00+08:00 [INFO] ========> Trade closed, pnl: -54.789628
2022-09-11 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-2furdjmw3z-00041] executed [quantity 0.5] [price $21844.000000] [Cost $10922.000000] [Commission: $6.0071] [Available balance: $51020.15027199999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-6.0071] 
2022-09-11 20:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-29ejieaqet-00042] executed [quantity 0.5] [price $21925.000000] [Cost $10962.500000] [Commission: $6.029375] [Available balance: $40092.12089699999] [Position: #-2.5] [Gross P&L: $0] [Net P&L: $-6.029375] 
2022-09-12 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-25ni2wzrh8-00043] executed [quantity 0.5] [price $21832.500000] [Cost $10916.250000] [Commission: $6.0039375] [Available balance: $29025.923874499997] [Position: #-3.0] [Gross P&L: $-97.693085] [Net P&L: $-103.697022] 
2022-09-12 00:00:00+08:00 [INFO] ========> Trade closed, pnl: -97.693085
2022-09-12 00:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-2ehg3r8zvd-00044] executed [quantity 0.5] [price $21767.500000] [Cost $10883.750000] [Commission: $5.9860625] [Available balance: $39773.30164099999] [Position: #-2.5] [Gross P&L: $-65.193085] [Net P&L: $-71.179147] 
2022-09-12 00:00:00+08:00 [INFO] ========> Trade closed, pnl: -65.193085
2022-09-12 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-26qfops2g3-00045] executed [quantity 0.5] [price $21813.000000] [Cost $10906.500000] [Commission: $5.998575] [Available balance: $50585.85998099999] [Position: #-2.0] [Gross P&L: $0] [Net P&L: $-5.998575] 
2022-09-12 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-1w23rcnmwq-00046] executed [quantity 0.5] [price $22206.000000] [Cost $11103.000000] [Commission: $6.10665] [Available balance: $39673.253330999985] [Position: #-2.5] [Gross P&L: $0] [Net P&L: $-6.10665] 
2022-09-12 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-1w181k5igr-00047] executed [quantity 0.5] [price $22143.500000] [Cost $11071.750000] [Commission: $6.0894625] [Available balance: $28373.03514549999] [Position: #-3.0] [Gross P&L: $-191.128723] [Net P&L: $-197.218185] 
2022-09-12 04:00:00+08:00 [INFO] ========> Trade closed, pnl: -191.128723
2022-09-12 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867703-19xa8cogp3-00048] executed [quantity 0.5] [price $22256.500000] [Cost $11128.250000] [Commission: $6.1205375] [Available balance: $39247.53588499999] [Position: #-2.5] [Gross P&L: $0] [Net P&L: $-6.120537] 
2022-09-13 16:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-2opr1ezbhv-00049] executed [quantity 0.5] [price $20240.500000] [Cost $10120.250000] [Commission: $5.5661375] [Available balance: $28915.36247749999] [Position: #-3.0] [Gross P&L: $801.64273] [Net P&L: $796.076593] 
2022-09-13 16:00:00+08:00 [INFO] ========> Trade closed, pnl: 801.64273
2022-09-14 04:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-1jhux4o2b5-00050] executed [quantity 0.5] [price $20313.500000] [Cost $10156.750000] [Commission: $5.5862125] [Available balance: $40596.811724999985] [Position: #-2.5] [Gross P&L: $765.14273] [Net P&L: $759.556518] 
2022-09-14 04:00:00+08:00 [INFO] ========> Trade closed, pnl: 765.14273
2022-09-14 08:00:00+08:00 [WARNING] The balance is deducted $ -50000.0
2022-09-14 12:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-232uwdokmh-00051] executed [quantity 0.5] [price $20156.000000] [Cost $10078.000000] [Commission: $5.5429] [Available balance: $2357.054284999984] [Position: #-2.0] [Gross P&L: $843.89273] [Net P&L: $838.34983] 
2022-09-14 12:00:00+08:00 [INFO] ========> Trade closed, pnl: 843.89273
2022-09-14 16:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867703-1h1v6k5y15-00052] executed [quantity 0.5] [price $19970.000000] [Cost $9985.000000] [Commission: $5.49175] [Available balance: $14210.347995999982] [Position: #-1.5] [Gross P&L: $936.89273] [Net P&L: $931.40098] 
2022-09-14 16:00:00+08:00 [INFO] ========> Trade closed, pnl: 936.89273
2022-09-15 08:00:00+08:00 [WARNING] The balance is added $ 500.32
2022-09-15 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - CLOSE BUY order [number aio-1706867704-1r9nuz8gw9-00053] executed [quantity 0.5] [price $20060.000000] [Cost $10030.000000] [Commission: $5.5165] [Available balance: $26518.936955999983] [Position: #-1.0] [Gross P&L: $891.89273] [Net P&L: $886.37623] 
2022-09-15 08:00:00+08:00 [INFO] ========> Trade closed, pnl: 891.89273
2022-09-15 08:00:00+08:00 [INFO] (BTCUSDT|BYBIT|NET) - OPEN SELL order [number aio-1706867704-285k3mmfh4-00054] executed [quantity 0.5] [price $20132.500000] [Cost $10066.250000] [Commission: $5.5364375] [Available balance: $37435.293249499984] [Position: #-0.5] [Gross P&L: $0] [Net P&L: $-5.536437] 
In [22]:
stats = mytest.ctx.statistic.stats(interval=interval)
stats
Out[22]:
start                                                   2022-09-07 00:00:00+08:00
end                                                     2022-09-16 00:00:00+08:00
interval                                                                       4h
duration                                                          9 days 00:00:00
trading_instruments                                                     [BTCUSDT]
base_currency                                                                USDT
benchmark                                                                     N/A
beginning_balance                                                          100000
ending_balance                                                      103070.508710
available_balance                                                   101856.865980
holding_values                                                        1213.642730
capital                                                                    100000
additional_capitals                                                            {}
net_investment                                                       65531.356380
total_net_profit                                                      3070.508710
total_commission                                                       311.241290
total_turnover                                                      565893.250000
profit_factor                                                            1.328310
return_on_capital                                                        0.030705
return_on_initial_capital                                                0.030705
return_on_investment                                                     0.046856
annualized_return                                                        2.409355
total_return                                                             0.030705
max_return                                                               0.031140
min_return                                                              -0.043855
past_24hr_pnl                                                          191.197100
past_24hr_apr                                                            0.678535
past_24hr_roi                                                            0.001859
past_7d_roi                                                              0.029829
past_14d_roi                                                             0.030705
past_30d_roi                                                             0.030705
past_90d_roi                                                             0.030705
past_180d_roi                                                            0.030705
past_1yr_roi                                                             0.030705
trading_period                                    0 years 0 months 9 days 0 hours
avg_holding_period(hrs)                                                 11.800000
pct_time_in_market                                                       0.800000
number_trades                                                                  54
number_closed_trades                                                           26
number_winning_trades                                                           8
number_losing_trades                                                           18
number_winning_long_trades                                                      3
number_losing_long_trades                                                       0
number_winning_short_trades                                                     5
number_losing_short_trades                                                     18
number_liquidation_trades                                                       0
avg_daily_trades                                                         9.000000
avg_weekly_trades                                                       27.000000
avg_monthly_trades                                                      54.000000
win_ratio                                                                0.307692
loss_ratio                                                               0.692308
win_ratio_long                                                           1.000000
loss_ratio_long                                                          0.000000
win_ratio_short                                                          1.666667
loss_ratio_short                                                         6.000000
gross_trades_profit                                                   4356.213700
gross_trades_loss                                                    -2188.106400
gross_winning_trades_amount                                          79238.250000
gross_losing_trades_amount                                          192247.000000
avg_winning_trades_pnl                                                 544.526713
avg_losing_trades_pnl                                                 -121.561467
avg_winning_trades_amount                                             9904.781250
avg_losing_trades_amount                                              4402.125000
largest_profit_winning_trade                                           936.892700
largest_loss_losing_trade                                             -204.975000
avg_amount_per_trade                                                 10479.504600
avg_amount_per_open_trade                                            10514.571400
avg_amount_per_closed_trade                                          10441.740400
avg_amount_per_long_trade                                             9603.291700
avg_amount_per_short_trade                                           10589.031300
avg_pnl_per_trade($)                                                    83.388800
avg_pnl_per_trade                                                        0.000800
max_consecutive_win_trades                                                      5
max_consecutive_loss_trades                                                    18
payoff_ratio                                                            -4.479400
expected_value                                                          83.390000
standardized_expected_value                                              0.840000
win_days                                                                        3
loss_days                                                                       4
max_win_in_day                                                        1372.500000
max_loss_in_day                                                       -904.500000
max_consecutive_win_days                                                        2
max_consecutive_loss_days                                                       2
avg_daily_pnl($)                                                       341.167600
avg_daily_pnl                                                            0.003501
avg_weekly_pnl($)                                                     5272.252300
avg_weekly_pnl                                                           0.053910
avg_monthly_pnl($)                                                           None
avg_monthly_pnl                                                              None
avg_quarterly_pnl($)                                                         None
avg_quarterly_pnl                                                            None
avg_annualy_pnl($)                                                           None
avg_annualy_pnl                                                              None
var                                                                   1421.948000
risk_score                                                                      1
avg_daily_risk_score                                                     0.000000
avg_risk_score_past_7days                                                0.000000
monthly_avg_risk_score                               {'2022-09-16 00:00:00': 0.0}
frequently_traded               [{'symbol': 'BTCUSDT', 'asset_type': 'PERPETUA...
sharpe_ratio                                                             3.064182
sortino_ratio                                                            7.310267
annualized_volatility                                                    0.425172
omega_ratio                                                              1.342815
downside_risk                                                            0.176588
information_ratio                                                            None
beta                                                                         None
alpha                                                                        None
calmar_ratio                                                            42.517029
tail_ratio                                                               1.034608
common_sense_ratio                                                       1.374280
skew                                                                     4.303867
kurtosis                                                                26.631822
stability_of_timeseries                                                  0.069314
max_drawdown                                                             0.056668
max_drawdown_period             (2022-09-09 04:00:00+08:00, 2022-09-13 16:00:0...
max_drawdown_duration                                             4 days 12:00:00
max_runup                                                                0.078435
max_runup_period                (2022-09-13 16:00:00+08:00, 2022-09-15 20:00:0...
max_runup_duration                                                2 days 04:00:00
sqn                                                                      1.098379
rolling_sharpe                  {'2022-09-07 00:00:00': None, '2022-09-08 00:0...
monthly_changes                                      {'2022-09-16 00:00:00': 0.0}
daily_changes                   {'2022-09-07 00:00:00': 0.0, '2022-09-08 00:00...
drawdown_series                 {'2022-09-07 00:00:00': 0.0, '2022-09-07 04:00...
positions                       [PositionData(symbol='BTCUSDT', code='BTCUSDT'...
trades                          [TradeData(order_id='aio-1706867703-1p9pfx1dms...
pnl                             [{'available_balance': 100000.0, 'holding_valu...
Name: value, dtype: object
In [ ]: