from areixio import CryptoDataFeed, Strategy, BackTestBroker, BackTest, Statistic
from datetime import datetime, timedelta
import json
now = datetime.now()
# 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"]
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
btc.dataframe.tail(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
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()
stats = mytest.ctx.statistic.stats(interval=interval)
stats
mytest.ctx.statistic.plot()
["asset", "amount", "datetime", "inout"]
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.
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
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()
stats = mytest.ctx.statistic.stats(interval=interval)
stats