From 26f043a95535f567489a2afe44394c3494caa8a6 Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Tue, 14 Jan 2025 19:44:48 +0900 Subject: [PATCH 01/13] Create `bybit-statement-account-uta` csv format --- csvs/bybit-statement-account-uta.json | 193 ++++++++++++++++++ .../bybit-statement-account-uta-result.json | 102 +++++++++ tests/csv/bybit-statement-account-uta.csv | 9 + 3 files changed, 304 insertions(+) create mode 100644 csvs/bybit-statement-account-uta.json create mode 100644 tests/csv/bybit-statement-account-uta-result.json create mode 100644 tests/csv/bybit-statement-account-uta.csv diff --git a/csvs/bybit-statement-account-uta.json b/csvs/bybit-statement-account-uta.json new file mode 100644 index 00000000000..b04a193047b --- /dev/null +++ b/csvs/bybit-statement-account-uta.json @@ -0,0 +1,193 @@ +{ + "id": "bybit-statement-account-uta", + "service": "bybit", + "formatter": { + "Currency": ["string"], + "Contract": ["string"], + "Type": ["string"], + "Direction": ["string"], + "Quantity": ["string"], + "Position": ["string"], + "Filled Price": ["string"], + "Funding": ["string"], + "Fee Paid": ["string"], + "Cash Flow": ["big-decimal"], + "Change": ["big-decimal"], + "Wallet Balance": ["big-decimal"], + "Action": ["string"], + "Time(UTC)": ["iso8601"] + }, + "parser": { + "parsers": [ + { + "description": "AUTO_DEDUCTION", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Type" + }, + "pattern": "AUTO_DEDUCTION" + } + ], + "generators": [ + { + "type": "transfer", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_uta-account_", + { "type": "cell", "column": "Time(UTC)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Time(UTC)" + }, + "comment": { + "type": "join", + "values": [ + "Type: ", + { "type": "cell", "column": "Type" }, + " / ", + { "type": "cell", "column": "Cash Flow" }, + " ", + { "type": "cell", "column": "Currency" } + ] + }, + "transfers": [ + { + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Cash Flow" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "cell", + "column": "Currency" + } + } + } + ] + } + ] + }, + { + "description": "INTEREST", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Type" + }, + "pattern": "INTEREST" + } + ], + "generators": [ + { + "type": "interest-fee", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_uta-account_", + { "type": "cell", "column": "Time(UTC)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Time(UTC)" + }, + "comment": { + "type": "join", + "values": [ + "Type: ", + { "type": "cell", "column": "Type" }, + " / ", + { "type": "cell", "column": "Cash Flow" }, + " ", + { "type": "cell", "column": "Currency" } + ] + }, + "transfers": [ + { + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Cash Flow" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "cell", + "column": "Currency" + } + } + } + ] + } + ] + }, + { + "description": "ignore", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Type" + }, + "pattern": { + "type": "in", + "values": [ + "--", + "DELIVERY", + "SETTLEMENT", + "TRADE", + "TRANSFER_IN", + "TRANSFER_OUT" + ] + } + } + ], + "generators": [ + { + "type": "ignore", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_uta-account_", + { "type": "cell", "column": "Time(UTC)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Time(UTC)" + }, + "comment": { + "type": "join", + "values": [ + "Type: ", + { "type": "cell", "column": "Type" }, + " / ", + { "type": "cell", "column": "Cash Flow" }, + " ", + { "type": "cell", "column": "Currency" } + ] + }, + "transfers": [] + } + ] + } + ] + } +} diff --git a/tests/csv/bybit-statement-account-uta-result.json b/tests/csv/bybit-statement-account-uta-result.json new file mode 100644 index 00000000000..4177db41512 --- /dev/null +++ b/tests/csv/bybit-statement-account-uta-result.json @@ -0,0 +1,102 @@ +[ + { + "source": "bybit-statement-account-uta_uta-account_1734697083000", + "order": 0, + "type": "ignore", + "timestamp": 1734697083000, + "evidence": "system-rule", + "comment": "Type: TRANSFER_OUT / \"-750\" USDT", + "transfers": [] + }, + { + "source": "bybit-statement-account-uta_uta-account_1734695168000", + "order": 0, + "type": "ignore", + "timestamp": 1734695168000, + "evidence": "system-rule", + "comment": "Type: TRADE / \"-235.76\" USDC", + "transfers": [] + }, + { + "source": "bybit-statement-account-uta_uta-account_1734428387000", + "order": 0, + "type": "transfer", + "timestamp": 1734428387000, + "evidence": "system-rule", + "comment": "Type: AUTO_DEDUCTION / \"-0.8473\" GGM", + "transfers": [ + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "monster-galaxy", + "name": "Monster Galaxy", + "symbol": "ggm", + "icon": "https://coin-images.coingecko.com/coins/images/22740/large/izylmhLV_400x400.png?1696522045", + "market": { "coingeckoId": "monster-galaxy", "marketCapUsd": 0 }, + "updatedAt": 1719984459107 + }, + "amount": "0.8473" + } + ] + }, + { + "source": "bybit-statement-account-uta_uta-account_1733789113000", + "order": 0, + "type": "ignore", + "timestamp": 1733789113000, + "evidence": "system-rule", + "comment": "Type: TRANSFER_IN / \"3000\" MOZ", + "transfers": [] + }, + { + "source": "bybit-statement-account-uta_uta-account_1733395978000", + "order": 0, + "type": "ignore", + "timestamp": 1733395978000, + "evidence": "system-rule", + "comment": "Type: -- / \"749\" ZRC", + "transfers": [] + }, + { + "source": "bybit-statement-account-uta_uta-account_1731081600000", + "order": 0, + "type": "ignore", + "timestamp": 1731081600000, + "evidence": "system-rule", + "comment": "Type: SETTLEMENT / \"0\" USDT", + "transfers": [] + }, + { + "source": "bybit-statement-account-uta_uta-account_1730880001000", + "order": 0, + "type": "ignore", + "timestamp": 1730880001000, + "evidence": "system-rule", + "comment": "Type: DELIVERY / \"44.28859773\" USDC", + "transfers": [] + }, + { + "source": "bybit-statement-account-uta_uta-account_1730876700000", + "order": 0, + "type": "interest-fee", + "timestamp": 1730876700000, + "evidence": "system-rule", + "comment": "Type: INTEREST / \"-0.000736807350132681\" USDC", + "transfers": [ + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "usd-coin", + "name": "USDC", + "symbol": "usdc", + "icon": "https://coin-images.coingecko.com/coins/images/6319/large/usdc.png?1696506694", + "market": { "coingeckoId": "usd-coin", "marketCapUsd": 35031669445 }, + "updatedAt": 1728782536762 + }, + "amount": "0.000736807350132681" + } + ] + } +] diff --git a/tests/csv/bybit-statement-account-uta.csv b/tests/csv/bybit-statement-account-uta.csv new file mode 100644 index 00000000000..5fa22674673 --- /dev/null +++ b/tests/csv/bybit-statement-account-uta.csv @@ -0,0 +1,9 @@ +Currency,Contract,Type,Direction,Quantity,Position,Filled Price,Funding,Fee Paid,Cash Flow,Change,Wallet Balance,Action,Time(UTC) +USDT,,TRANSFER_OUT,--,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,-750.00000000000000000000,-750.00000000000000000000,1918.30212743718025504800,--,2024-12-20 12:18:03 +USDC,USDCUSDT,TRADE,SELL,-235.76000000000000000000,0.00000000000000000000,1.00140000000000000000,0.00000000000000000000,0.00000000000000000000,-235.76000000000000000000,-235.76000000000000000000,0.00307603264986731900,--,2024-12-20 11:46:08 +GGM,,AUTO_DEDUCTION,--,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,-0.84730000000000000000,-0.84730000000000000000,0.00000000000000000000,--,2024-12-17 09:39:47 +MOZ,,TRANSFER_IN,--,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,3000.00000000000000000000,3000.00000000000000000000,3000.00000000000000000000,--,2024-12-10 00:05:13 +ZRC,,--,--,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,749.00000000000000000000,749.00000000000000000000,749.00000000000000000000,--,2024-12-05 10:52:58 +USDT,TONUSDT,SETTLEMENT,BUY,--,1633.30000000000000000000,--,-1.29004476000000000000,0.00000000000000000000,0.00000000000000000000,-1.29004476000000000000,2038.22376764778430000000,SETTLEMENT,2024-11-08 16:00:00 +USDC,BTC-6NOV24-74000-P,DELIVERY,SELL,0.20000000000000000000,0.00000000000000000000,73778.55701135000000000000,0.00000000000000000000,0.00000000000000000000,44.28859773000000000000,44.28859773000000000000,-30.19122283735013268100,CLOSE,2024-11-06 08:00:01 +USDC,,INTEREST,--,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,0.00000000000000000000,-0.00073680735013268100,-0.00073680735013268100,-74.47982056735013268100,--,2024-11-06 07:05:00 \ No newline at end of file From fe1b7db10699d45be8888cfa6741c35c4655ce4b Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 11:20:25 +0900 Subject: [PATCH 02/13] Create `bybit-statement-account-spot` csv format --- csvs/bybit-statement-account-spot.json | 187 ++++++++++++++++++ .../bybit-statement-account-spot-result.json | 109 ++++++++++ tests/csv/bybit-statement-account-spot.csv | 10 + 3 files changed, 306 insertions(+) create mode 100644 csvs/bybit-statement-account-spot.json create mode 100644 tests/csv/bybit-statement-account-spot-result.json create mode 100644 tests/csv/bybit-statement-account-spot.csv diff --git a/csvs/bybit-statement-account-spot.json b/csvs/bybit-statement-account-spot.json new file mode 100644 index 00000000000..3c3aec8f171 --- /dev/null +++ b/csvs/bybit-statement-account-spot.json @@ -0,0 +1,187 @@ +{ + "id": "bybit-statement-account-spot", + "service": "bybit", + "formatter": { + "Type": ["string"], + "Coin": ["string"], + "Amount": ["big-decimal"], + "Wallet Balance": ["big-decimal"], + "Time(UTC)": ["iso8601"] + }, + "parser": { + "parsers": [ + { + "description": "airdropAssetDeduction", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Type" + }, + "pattern": "airdropAssetDeduction" + } + ], + "generators": [ + { + "type": "transfer", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_spot-account_", + { "type": "cell", "column": "Time(UTC)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Time(UTC)" + }, + "comment": { + "type": "join", + "values": [ + "Type: ", + { "type": "cell", "column": "Type" }, + " / ", + { "type": "cell", "column": "Amount" }, + " ", + { "type": "cell", "column": "Coin" } + ] + }, + "transfers": [ + { + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Amount" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "cell", + "column": "Coin" + } + } + } + ] + } + ] + }, + { + "description": "airdropAssetIncrease", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Type" + }, + "pattern": "airdropAssetIncrease" + } + ], + "generators": [ + { + "type": "airdrop", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_spot-account_", + { "type": "cell", "column": "Time(UTC)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Time(UTC)" + }, + "comment": { + "type": "join", + "values": [ + "Type: ", + { "type": "cell", "column": "Type" }, + " / ", + { "type": "cell", "column": "Amount" }, + " ", + { "type": "cell", "column": "Coin" } + ] + }, + "transfers": [ + { + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Amount" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "cell", + "column": "Coin" + } + } + } + ] + } + ] + }, + { + "description": "ignore", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Type" + }, + "pattern": { + "type": "in", + "values": [ + "internalAccountTransferDeposit", + "internalAccountTransferWithdrawal", + "trade", + "tradingFee", + "userDeposit", + "userWithdrawal" + ] + } + } + ], + "generators": [ + { + "type": "ignore", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_spot-account_", + { "type": "cell", "column": "Time(UTC)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Time(UTC)" + }, + "comment": { + "type": "join", + "values": [ + "Type: ", + { "type": "cell", "column": "Type" }, + " / ", + { "type": "cell", "column": "Amount" }, + " ", + { "type": "cell", "column": "Coin" } + ] + }, + "transfers": [] + } + ] + } + ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" + } +} diff --git a/tests/csv/bybit-statement-account-spot-result.json b/tests/csv/bybit-statement-account-spot-result.json new file mode 100644 index 00000000000..13636dbbac1 --- /dev/null +++ b/tests/csv/bybit-statement-account-spot-result.json @@ -0,0 +1,109 @@ +[ + { + "source": "bybit-statement-account-spot_spot-account_1730864873000", + "order": 0, + "type": "ignore", + "timestamp": 1730864873000, + "evidence": "system-rule", + "comment": "Type: internalAccountTransferWithdrawal / \"-0.00522\" MV", + "transfers": [] + }, + { + "source": "bybit-statement-account-spot_spot-account_1724551366000", + "order": 0, + "type": "airdrop", + "timestamp": 1724551366000, + "evidence": "system-rule", + "comment": "Type: airdropAssetIncrease / \"3075\" DOGS", + "transfers": [ + { + "direction": "in", + "asset": { + "type": "CryptoCurrency", + "id": "dogs-2", + "name": "Dogs", + "symbol": "dogs", + "icon": "https://coin-images.coingecko.com/coins/images/39699/large/dogs_logo_200x200.png?1723687163", + "market": { "coingeckoId": "dogs-2", "marketCapUsd": 405514061 }, + "updatedAt": 1728782536762 + }, + "amount": "3075" + } + ] + }, + { + "source": "bybit-statement-account-spot_spot-account_1722260469000", + "order": 0, + "type": "transfer", + "timestamp": 1722260469000, + "evidence": "system-rule", + "comment": "Type: airdropAssetDeduction / \"-464.39505\" RNDR", + "transfers": [ + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "render-token", + "name": "render-token", + "symbol": "RENDER-TOKEN", + "updatedAt": 0 + }, + "amount": "464.39505" + } + ] + }, + { + "source": "bybit-statement-account-spot_spot-account_1687831026000", + "order": 0, + "type": "ignore", + "timestamp": 1687831026000, + "evidence": "system-rule", + "comment": "Type: internalAccountTransferDeposit / \"10\" USDT", + "transfers": [] + }, + { + "source": "bybit-statement-account-spot_spot-account_1687765552000", + "order": 0, + "type": "ignore", + "timestamp": 1687765552000, + "evidence": "system-rule", + "comment": "Type: tradingFee / \"-0.073269144\" USDT", + "transfers": [] + }, + { + "source": "bybit-statement-account-spot_spot-account_1687765552000", + "order": 1, + "type": "ignore", + "timestamp": 1687765552000, + "evidence": "system-rule", + "comment": "Type: trade / \"-151.32\" XRP", + "transfers": [] + }, + { + "source": "bybit-statement-account-spot_spot-account_1687765552000", + "order": 2, + "type": "ignore", + "timestamp": 1687765552000, + "evidence": "system-rule", + "comment": "Type: trade / \"73.269144\" USDT", + "transfers": [] + }, + { + "source": "bybit-statement-account-spot_spot-account_1677561700000", + "order": 0, + "type": "ignore", + "timestamp": 1677561700000, + "evidence": "system-rule", + "comment": "Type: userWithdrawal / \"-210.3\" USDT", + "transfers": [] + }, + { + "source": "bybit-statement-account-spot_spot-account_1677414837000", + "order": 0, + "type": "ignore", + "timestamp": 1677414837000, + "evidence": "system-rule", + "comment": "Type: userDeposit / \"4000\" XRP", + "transfers": [] + } +] diff --git a/tests/csv/bybit-statement-account-spot.csv b/tests/csv/bybit-statement-account-spot.csv new file mode 100644 index 00000000000..6041f9d477e --- /dev/null +++ b/tests/csv/bybit-statement-account-spot.csv @@ -0,0 +1,10 @@ +Type,Coin,Amount,Wallet Balance,Time(UTC) +internalAccountTransferWithdrawal,MV,-0.005220000000000000,0.000000000000000000,2024-11-06 03:47:53 +airdropAssetIncrease,DOGS,3075.000000000000000000,3075.000000000000000000,2024-08-25 02:02:46 +airdropAssetDeduction,RNDR,-464.395050000000000000,0.000000000000000000,2024-07-29 13:41:09 +internalAccountTransferDeposit,USDT,10.000000000000000000,3010.047681644507500000,2023-06-27 01:57:06 +tradingFee,USDT,-0.073269144000000000,6654.405553644507500000,2023-06-26 07:45:52 +trade,XRP,-151.320000000000000000,0.000000000000000000,2023-06-26 07:45:52 +trade,USDT,73.269144000000000000,6654.478822788507500000,2023-06-26 07:45:52 +userWithdrawal,USDT,-210.300000000000000000,1593.962992294947500000,2023-02-28 05:21:40 +userDeposit,XRP,4000.000000000000000000,4000.000000000000000000,2023-02-26 12:33:57 \ No newline at end of file From 3f83297cc1eaceb9de05abdc0815727c0db45aef Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 11:28:29 +0900 Subject: [PATCH 03/13] Update `bybit-statement-account-spot` csv format --- csvs/bybit-statement-account-spot.json | 3 ++- tests/csv/bybit-statement-account-spot-result.json | 9 +++++++++ tests/csv/bybit-statement-account-spot.csv | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/csvs/bybit-statement-account-spot.json b/csvs/bybit-statement-account-spot.json index 3c3aec8f171..b5117552b37 100644 --- a/csvs/bybit-statement-account-spot.json +++ b/csvs/bybit-statement-account-spot.json @@ -144,7 +144,8 @@ "trade", "tradingFee", "userDeposit", - "userWithdrawal" + "userWithdrawal", + "" ] } } diff --git a/tests/csv/bybit-statement-account-spot-result.json b/tests/csv/bybit-statement-account-spot-result.json index 13636dbbac1..8c14f6d91d0 100644 --- a/tests/csv/bybit-statement-account-spot-result.json +++ b/tests/csv/bybit-statement-account-spot-result.json @@ -52,6 +52,15 @@ } ] }, + { + "source": "bybit-statement-account-spot_spot-account_1705671434000", + "order": 0, + "type": "ignore", + "timestamp": 1705671434000, + "evidence": "system-rule", + "comment": "Type: / \"-1361.65497\" PYTH", + "transfers": [] + }, { "source": "bybit-statement-account-spot_spot-account_1687831026000", "order": 0, diff --git a/tests/csv/bybit-statement-account-spot.csv b/tests/csv/bybit-statement-account-spot.csv index 6041f9d477e..8093c56f857 100644 --- a/tests/csv/bybit-statement-account-spot.csv +++ b/tests/csv/bybit-statement-account-spot.csv @@ -2,6 +2,7 @@ Type,Coin,Amount,Wallet Balance,Time(UTC) internalAccountTransferWithdrawal,MV,-0.005220000000000000,0.000000000000000000,2024-11-06 03:47:53 airdropAssetIncrease,DOGS,3075.000000000000000000,3075.000000000000000000,2024-08-25 02:02:46 airdropAssetDeduction,RNDR,-464.395050000000000000,0.000000000000000000,2024-07-29 13:41:09 +,PYTH,-1361.654970000000000000,0.000000000000000000,2024-01-19 13:37:14 internalAccountTransferDeposit,USDT,10.000000000000000000,3010.047681644507500000,2023-06-27 01:57:06 tradingFee,USDT,-0.073269144000000000,6654.405553644507500000,2023-06-26 07:45:52 trade,XRP,-151.320000000000000000,0.000000000000000000,2023-06-26 07:45:52 From ae99813890303924190ca059e533a90618f069d2 Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 11:56:33 +0900 Subject: [PATCH 04/13] Create `bybit-statement-account-contract` csv format --- csvs/bybit-statement-account-contract.json | 135 ++++++++++++++++++ ...bit-statement-account-contract-result.json | 70 +++++++++ .../csv/bybit-statement-account-contract.csv | 7 + 3 files changed, 212 insertions(+) create mode 100644 csvs/bybit-statement-account-contract.json create mode 100644 tests/csv/bybit-statement-account-contract-result.json create mode 100644 tests/csv/bybit-statement-account-contract.csv diff --git a/csvs/bybit-statement-account-contract.json b/csvs/bybit-statement-account-contract.json new file mode 100644 index 00000000000..35e0e85eb5c --- /dev/null +++ b/csvs/bybit-statement-account-contract.json @@ -0,0 +1,135 @@ +{ + "id": "bybit-statement-account-contract", + "service": "bybit", + "formatter": { + "Time": ["iso8601"], + "Currency": ["string"], + "Contract": ["string"], + "Type": ["string"], + "Direction": ["string"], + "Quantity": ["string"], + "Position": ["string"], + "Filled Price": ["string"], + "Funding": ["string"], + "Fee Paid": ["string"], + "Cash Flow": ["big-decimal"], + "Change": ["big-decimal"], + "Wallet Balance": ["big-decimal"], + "Fee Rate": ["string"], + "Trade ID": ["string"], + "Order ID": ["string"] + }, + "parser": { + "parsers": [ + { + "description": "10074 > transfer", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Type" + }, + "pattern": "10074" + } + ], + "generators": [ + { + "type": "transfer", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_contract-account_", + { "type": "cell", "column": "Time" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Time" + }, + "comment": { + "type": "join", + "values": [ + "Type: ", + { "type": "cell", "column": "Type" }, + " / ", + { "type": "cell", "column": "Cash Flow" }, + " ", + { "type": "cell", "column": "Currency" } + ] + }, + "transfers": [ + { + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Cash Flow" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "cell", + "column": "Currency" + } + } + } + ] + } + ] + }, + { + "description": "funding / liquidation / trade / transferIn / transferOut > ignore", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Type" + }, + "pattern": { + "type": "in", + "values": [ + "funding", + "liquidation", + "trade", + "transferIn", + "transferOut" + ] + } + } + ], + "generators": [ + { + "type": "ignore", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_contract-account_", + { "type": "cell", "column": "Time" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Time" + }, + "comment": { + "type": "join", + "values": [ + "Type: ", + { "type": "cell", "column": "Type" }, + " / ", + { "type": "cell", "column": "Cash Flow" }, + " ", + { "type": "cell", "column": "Currency" } + ] + }, + "transfers": [] + } + ] + } + ] + } +} diff --git a/tests/csv/bybit-statement-account-contract-result.json b/tests/csv/bybit-statement-account-contract-result.json new file mode 100644 index 00000000000..f774ba4f941 --- /dev/null +++ b/tests/csv/bybit-statement-account-contract-result.json @@ -0,0 +1,70 @@ +[ + { + "source": "bybit-statement-account-contract_contract-account_1730864876000", + "order": 0, + "type": "transfer", + "timestamp": 1730864876000, + "evidence": "system-rule", + "comment": "Type: 10074 / \"-0.00004836\" USDT", + "transfers": [ + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "tether", + "name": "Tether", + "symbol": "usdt", + "icon": "https://coin-images.coingecko.com/coins/images/325/large/Tether.png?1696501661", + "market": { "coingeckoId": "tether", "marketCapUsd": 119675340267 }, + "updatedAt": 1728782536762 + }, + "amount": "0.00004836" + } + ] + }, + { + "source": "bybit-statement-account-contract_contract-account_1688027480000", + "order": 0, + "type": "ignore", + "timestamp": 1688027480000, + "evidence": "system-rule", + "comment": "Type: trade / \"13.4136\" USDT", + "transfers": [] + }, + { + "source": "bybit-statement-account-contract_contract-account_1687831026000", + "order": 0, + "type": "ignore", + "timestamp": 1687831026000, + "evidence": "system-rule", + "comment": "Type: transferOut / \"-10\" USDT", + "transfers": [] + }, + { + "source": "bybit-statement-account-contract_contract-account_1687564800000", + "order": 0, + "type": "ignore", + "timestamp": 1687564800000, + "evidence": "system-rule", + "comment": "Type: funding / \"0\" USDT", + "transfers": [] + }, + { + "source": "bybit-statement-account-contract_contract-account_1686376307000", + "order": 0, + "type": "ignore", + "timestamp": 1686376307000, + "evidence": "system-rule", + "comment": "Type: liquidation / \"-163.3034\" USDT", + "transfers": [] + }, + { + "source": "bybit-statement-account-contract_contract-account_1686361849000", + "order": 0, + "type": "ignore", + "timestamp": 1686361849000, + "evidence": "system-rule", + "comment": "Type: transferIn / \"265.3344\" USDT", + "transfers": [] + } +] diff --git a/tests/csv/bybit-statement-account-contract.csv b/tests/csv/bybit-statement-account-contract.csv new file mode 100644 index 00000000000..846769b7580 --- /dev/null +++ b/tests/csv/bybit-statement-account-contract.csv @@ -0,0 +1,7 @@ +Time,Currency,Contract,Type,Direction,Quantity,Position,Filled Price,Funding,Fee Paid,Cash Flow,Change,Wallet Balance,Fee Rate,Trade ID,Order ID +2024-11-06 03:47:56,USDT,,10074,,,,,0E-8,0E-8,-0.00004836,-0.00004836,0E-8,0E-8,, +2023-06-29 08:31:20,USDT,BTCUSDT,trade,Close Long,0.0540,0.0000,30434.60000000,0E-8,0.98608104,13.41360000,12.42751896,429.03294183,0.00060000,ee8c84c2-6c89-54d8-a1d9-9940c50a7256,a2507a2e-7b3e-4a20-9456-c7fcd05650c3 +2023-06-27 01:57:06,USDT,,transferOut,,,,,0E-8,0E-8,-10.00000000,-10.00000000,417.68445282,0E-8,, +2023-06-24 00:00:00,USDT,GPTUSDT,funding,Open Long,20000.0000,20000.0000,0.01291000,0.02582000,0.02582000,0E-8,-0.02582000,780.02687282,0.00010000,f8585708-502a-4582-b898-51f95c3b212d,1687564800-GPTUSDT-27831019-Buy +2023-06-10 05:51:47,USDT,XRPUSDT,liquidation,Close Long,3132.0000,0.0000,0.47020000,0E-8,0.88359984,-163.30340000,-164.18699984,885.40960146,0.00060000,303bf3ce-1734-4e65-bfc1-c205e9aa8133,303bf3ce-1734-4e65-bfc1-c205e9aa8133 +2023-06-10 01:50:49,USDT,,transferIn,,,,,0E-8,0E-8,265.33440000,265.33440000,1897.26958718,0E-8,, \ No newline at end of file From 42d842b56eb7265d80f8298ecb314e881e6801e7 Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 12:09:49 +0900 Subject: [PATCH 05/13] Create `bybit-statement-uta-spot-trade` csv format --- csvs/bybit-statement-uta-spot-trade.json | 1438 +++++++++++++++++ ...bybit-statement-uta-spot-trade-result.json | 139 ++ tests/csv/bybit-statement-uta-spot-trade.csv | 4 + 3 files changed, 1581 insertions(+) create mode 100644 csvs/bybit-statement-uta-spot-trade.json create mode 100644 tests/csv/bybit-statement-uta-spot-trade-result.json create mode 100644 tests/csv/bybit-statement-uta-spot-trade.csv diff --git a/csvs/bybit-statement-uta-spot-trade.json b/csvs/bybit-statement-uta-spot-trade.json new file mode 100644 index 00000000000..fa1c18665ac --- /dev/null +++ b/csvs/bybit-statement-uta-spot-trade.json @@ -0,0 +1,1438 @@ +{ + "id": "bybit-statement-uta-spot-trade", + "service": "bybit", + "formatter": { + "Spot Pairs": ["string"], + "Direction": ["string"], + "Filled Value": ["big-decimal"], + "Filled Quantity": ["big-decimal"], + "Fees": ["big-decimal"], + "Transaction ID": ["string"], + "Order No.": ["string"], + "Timestamp (UTC+0)": ["iso8601"] + }, + "parser": { + "parsers": [ + { + "description": "trade", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Direction" + }, + "pattern": { + "type": "in", + "values": ["BUY", "SELL"] + } + } + ], + "generators": [ + { + "type": "trade", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_spot-trade_", + { "type": "cell", "column": "Transaction ID" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Timestamp (UTC+0)" + }, + "transfers": [ + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDT", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDE", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "SOL", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "BTC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "ETH", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "DAI", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDT", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDE", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "SOL", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "BTC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "ETH", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "DAI", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDT" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDE" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "SOL" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "BTC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "ETH" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "DAI" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDT" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDE" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "SOL" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "BTC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "ETH" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "DAI" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDT", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDE", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "SOL", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "BTC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "ETH", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "BUY" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "DAI", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "USDT" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "USDE" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "SOL" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "BTC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "ETH" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": "SELL" + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "DAI" + } + } + ] + } + ] + } + ] + } +} diff --git a/tests/csv/bybit-statement-uta-spot-trade-result.json b/tests/csv/bybit-statement-uta-spot-trade-result.json new file mode 100644 index 00000000000..398d440ab6d --- /dev/null +++ b/tests/csv/bybit-statement-uta-spot-trade-result.json @@ -0,0 +1,139 @@ +[ + { + "source": "bybit-statement-uta-spot-trade_spot-trade_2210000000571911019", + "order": 0, + "type": "trade", + "timestamp": 1734486365000, + "evidence": "system-rule", + "transfers": [ + { + "direction": "in", + "asset": { + "type": "CryptoCurrency", + "id": "usd-coin", + "name": "USDC", + "symbol": "usdc", + "icon": "https://coin-images.coingecko.com/coins/images/6319/large/usdc.png?1696506694", + "market": { "coingeckoId": "usd-coin", "marketCapUsd": 35031669445 }, + "updatedAt": 1728782536762 + }, + "amount": "25" + }, + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "tether", + "name": "Tether", + "symbol": "usdt", + "icon": "https://coin-images.coingecko.com/coins/images/325/large/Tether.png?1696501661", + "market": { "coingeckoId": "tether", "marketCapUsd": 119675340267 }, + "updatedAt": 1728782536762 + }, + "amount": "24.9975" + } + ] + }, + { + "source": "bybit-statement-uta-spot-trade_spot-trade_2210000000566540132", + "order": 0, + "type": "trade", + "timestamp": 1734145513000, + "evidence": "system-rule", + "transfers": [ + { + "direction": "in", + "asset": { + "type": "CryptoCurrency", + "id": "avalanche-2", + "name": "Avalanche", + "symbol": "avax", + "icon": "https://coin-images.coingecko.com/coins/images/12559/large/Avalanche_Circle_RedWhite_Trans.png?1696512369", + "market": { + "coingeckoId": "avalanche-2", + "marketCapUsd": 11577612406 + }, + "updatedAt": 1728782536762 + }, + "amount": "0.5" + }, + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "tether", + "name": "Tether", + "symbol": "usdt", + "icon": "https://coin-images.coingecko.com/coins/images/325/large/Tether.png?1696501661", + "market": { "coingeckoId": "tether", "marketCapUsd": 119675340267 }, + "updatedAt": 1728782536762 + }, + "amount": "26.525" + }, + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "avalanche-2", + "name": "Avalanche", + "symbol": "avax", + "icon": "https://coin-images.coingecko.com/coins/images/12559/large/Avalanche_Circle_RedWhite_Trans.png?1696512369", + "market": { + "coingeckoId": "avalanche-2", + "marketCapUsd": 11577612406 + }, + "updatedAt": 1728782536762 + }, + "amount": "0.0005" + } + ] + }, + { + "source": "bybit-statement-uta-spot-trade_spot-trade_2280000000744015206", + "order": 0, + "type": "trade", + "timestamp": 1731427507000, + "evidence": "system-rule", + "transfers": [ + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "ethereum", + "name": "Ethereum", + "symbol": "eth", + "icon": "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628", + "market": { "coingeckoId": "ethereum", "marketCapUsd": 297208008363 }, + "updatedAt": 1728782536762 + }, + "amount": "0.11145" + }, + { + "direction": "in", + "asset": { + "type": "CryptoCurrency", + "id": "tether", + "name": "Tether", + "symbol": "usdt", + "icon": "https://coin-images.coingecko.com/coins/images/325/large/Tether.png?1696501661", + "market": { "coingeckoId": "tether", "marketCapUsd": 119675340267 }, + "updatedAt": 1728782536762 + }, + "amount": "363.529839" + }, + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "tether", + "name": "Tether", + "symbol": "usdt", + "icon": "https://coin-images.coingecko.com/coins/images/325/large/Tether.png?1696501661", + "market": { "coingeckoId": "tether", "marketCapUsd": 119675340267 }, + "updatedAt": 1728782536762 + }, + "amount": "0.363529839" + } + ] + } +] diff --git a/tests/csv/bybit-statement-uta-spot-trade.csv b/tests/csv/bybit-statement-uta-spot-trade.csv new file mode 100644 index 00000000000..eb46ea3bf3a --- /dev/null +++ b/tests/csv/bybit-statement-uta-spot-trade.csv @@ -0,0 +1,4 @@ +Spot Pairs,Order Type,Direction,Filled Value,Filled Price,Filled Quantity,Fees,Transaction ID,Order No.,Timestamp (UTC+0) +USDCUSDT,MARKET,BUY,24.99750000000000000000,0.99990000000000000000,25.00000000000000000000,0.00000000000000000000,2210000000571911019,1843399672224553984,2024-12-18 01:46:05 +AVAXUSDT,MARKET,BUY,26.52500000000000000000,53.05000000000000000000,0.50000000000000000000,0.00050000000000000000,2210000000566540132,1840540401078115328,2024-12-14 03:05:13 +ETHUSDT,MARKET,SELL,363.52983900000000000000,3261.82000000000000000000,0.11145000000000000000,0.36352983900000000000,2280000000744015206,1817740110402427904,2024-11-12 16:05:07 \ No newline at end of file From 1420f28ecdec78d5e2a34aca31d0b5716cacd195 Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 12:23:29 +0900 Subject: [PATCH 06/13] Update `bybit-future-pl` csv format --- csvs/bybit-future-pl.json | 142 +++++++++++++++++++++++++- tests/csv/bybit-future-pl-result.json | 46 +++++++++ tests/csv/bybit-future-pl.csv | 2 + 3 files changed, 186 insertions(+), 4 deletions(-) diff --git a/csvs/bybit-future-pl.json b/csvs/bybit-future-pl.json index 2ffc9cc9bda..01f1b835252 100644 --- a/csvs/bybit-future-pl.json +++ b/csvs/bybit-future-pl.json @@ -11,7 +11,7 @@ "parser": { "parsers": [ { - "description": "realize profit", + "description": "realize profit (USDT Perp)", "conditions": [ { "value": { @@ -78,7 +78,7 @@ ] }, { - "description": "realize loss", + "description": "realize loss (USDT Perp)", "conditions": [ { "value": { @@ -145,7 +145,7 @@ ] }, { - "description": "realize profit", + "description": "realize profit (Inverse)", "conditions": [ { "value": { @@ -220,7 +220,7 @@ ] }, { - "description": "realize loss", + "description": "realize loss (Inverse)", "conditions": [ { "value": { @@ -293,6 +293,140 @@ ] } ] + }, + { + "description": "realize profit (USDC Perp)", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Realized P&L" + }, + "pattern": { + "type": "positive" + } + }, + { + "value": { + "type": "cell", + "column": "Contracts" + }, + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+PERP$" + } + } + ], + "generators": [ + { + "type": "realize-profit", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_future-pl_", + { "type": "cell", "column": "Filled/Settlement Time(UTC+0)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Filled/Settlement Time(UTC+0)" + }, + "comment": { + "type": "join", + "values": [ + "Close ", + { "type": "cell", "column": "Qty" }, + { "type": "cell", "column": "Contracts" }, + " / Side: ", + { "type": "cell", "column": "Trade Type" } + ] + }, + "transfers": [ + { + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Realized P&L" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + } + ] + } + ] + }, + { + "description": "realize loss (USDC Perp)", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Realized P&L" + }, + "pattern": { + "type": "negative" + } + }, + { + "value": { + "type": "cell", + "column": "Contracts" + }, + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+PERP$" + } + } + ], + "generators": [ + { + "type": "realize-loss", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_future-pl_", + { "type": "cell", "column": "Filled/Settlement Time(UTC+0)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Filled/Settlement Time(UTC+0)" + }, + "comment": { + "type": "join", + "values": [ + "Close ", + { "type": "cell", "column": "Qty" }, + { "type": "cell", "column": "Contracts" }, + " / Side: ", + { "type": "cell", "column": "Trade Type" } + ] + }, + "transfers": [ + { + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Realized P&L" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + } + ] + } + ] } ] } diff --git a/tests/csv/bybit-future-pl-result.json b/tests/csv/bybit-future-pl-result.json index 14dbd3be648..580a4f223f6 100644 --- a/tests/csv/bybit-future-pl-result.json +++ b/tests/csv/bybit-future-pl-result.json @@ -22,6 +22,52 @@ } ] }, + { + "source": "bybit-future-pl_future-pl_1734582115000", + "order": 0, + "type": "realize-profit", + "timestamp": 1734582115000, + "evidence": "system-rule", + "comment": "Close \"3\"OPPERP / Side: SELL", + "transfers": [ + { + "direction": "in", + "asset": { + "type": "CryptoCurrency", + "id": "usd-coin", + "name": "USDC", + "symbol": "usdc", + "icon": "https://coin-images.coingecko.com/coins/images/6319/large/usdc.png?1696506694", + "market": { "coingeckoId": "usd-coin", "marketCapUsd": 35031669445 }, + "updatedAt": 1728782536762 + }, + "amount": "0.02704777" + } + ] + }, + { + "source": "bybit-future-pl_future-pl_1734566400000", + "order": 0, + "type": "realize-loss", + "timestamp": 1734566400000, + "evidence": "system-rule", + "comment": "Close \"3\"OPPERP / Side: BUY", + "transfers": [ + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "usd-coin", + "name": "USDC", + "symbol": "usdc", + "icon": "https://coin-images.coingecko.com/coins/images/6319/large/usdc.png?1696506694", + "market": { "coingeckoId": "usd-coin", "marketCapUsd": 35031669445 }, + "updatedAt": 1728782536762 + }, + "amount": "0.5451471" + } + ] + }, { "source": "bybit-future-pl_future-pl_1730101500000", "order": 0, diff --git a/tests/csv/bybit-future-pl.csv b/tests/csv/bybit-future-pl.csv index 7630b93864d..2579e307ba1 100644 --- a/tests/csv/bybit-future-pl.csv +++ b/tests/csv/bybit-future-pl.csv @@ -1,4 +1,6 @@ Contracts,Trade Type,Qty,Entry Price,Realized P&L,Filled Price,Exit Type,Filled/Settlement Time(UTC+0),Create Time BTCUSDH25,SELL,500.00000000000000000000,79550.06490000000000000000,0.00107018000000000000,95950.13660000000000000000,Trade,11:36 2024-12-20,11:36 2024-12-20 +OPPERP,SELL,3.00000000000000000000,2.15700000000000000000,0.02704777000000000000,2.16850000000000000000,Trade,2024-12-19 04:21:55,2024-12-19 04:21:55 +OPPERP,BUY,3.00000000000000000000,2.33850000000000000000,-0.54514710000000000000,2.15700000000000000000,SessionSettlePnL,2024-12-19 00:00:00,2024-12-19 00:00:00 MANTAUSDT,BUY,200.00000000000000000000,1.03366120000000000000,74.85797060000000000000,0.66978905000000000000,Trade,07:45 2024-10-28,07:45 2024-10-28 AXSUSDT,BUY,100.00000000000000000000,5.36269710000000000000,-110.25364161000000000000,6.43144800000000000000,Trade,00:48 2024-07-21,00:48 2024-07-21 \ No newline at end of file From a2ba67ac73f34e722e0ade96f421d327dccf1e2d Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 12:43:07 +0900 Subject: [PATCH 07/13] Update `bybit-future-pl` csv format --- csvs/bybit-future-pl.json | 134 ++++++++++++++++++++++++++ tests/csv/bybit-future-pl-result.json | 23 +++++ tests/csv/bybit-future-pl.csv | 1 + 3 files changed, 158 insertions(+) diff --git a/csvs/bybit-future-pl.json b/csvs/bybit-future-pl.json index 01f1b835252..164ae202bfa 100644 --- a/csvs/bybit-future-pl.json +++ b/csvs/bybit-future-pl.json @@ -427,6 +427,140 @@ ] } ] + }, + { + "description": "realize profit (USDC Future)", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Realized P&L" + }, + "pattern": { + "type": "positive" + } + }, + { + "value": { + "type": "cell", + "column": "Contracts" + }, + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+\\-\\d{2}[A-Z]+\\d{2}$" + } + } + ], + "generators": [ + { + "type": "realize-profit", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_future-pl_", + { "type": "cell", "column": "Filled/Settlement Time(UTC+0)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Filled/Settlement Time(UTC+0)" + }, + "comment": { + "type": "join", + "values": [ + "Close ", + { "type": "cell", "column": "Qty" }, + { "type": "cell", "column": "Contracts" }, + " / Side: ", + { "type": "cell", "column": "Trade Type" } + ] + }, + "transfers": [ + { + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Realized P&L" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + } + ] + } + ] + }, + { + "description": "realize loss (USDC Future)", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Realized P&L" + }, + "pattern": { + "type": "negative" + } + }, + { + "value": { + "type": "cell", + "column": "Contracts" + }, + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+\\-\\d{2}[A-Z]+\\d{2}$" + } + } + ], + "generators": [ + { + "type": "realize-loss", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_future-pl_", + { "type": "cell", "column": "Filled/Settlement Time(UTC+0)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Filled/Settlement Time(UTC+0)" + }, + "comment": { + "type": "join", + "values": [ + "Close ", + { "type": "cell", "column": "Qty" }, + { "type": "cell", "column": "Contracts" }, + " / Side: ", + { "type": "cell", "column": "Trade Type" } + ] + }, + "transfers": [ + { + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Realized P&L" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + } + ] + } + ] } ] } diff --git a/tests/csv/bybit-future-pl-result.json b/tests/csv/bybit-future-pl-result.json index 580a4f223f6..25f08f582d8 100644 --- a/tests/csv/bybit-future-pl-result.json +++ b/tests/csv/bybit-future-pl-result.json @@ -68,6 +68,29 @@ } ] }, + { + "source": "bybit-future-pl_future-pl_1734486706000", + "order": 0, + "type": "realize-loss", + "timestamp": 1734486706000, + "evidence": "system-rule", + "comment": "Close \"0.03\"SOL-31JAN25 / Side: SELL", + "transfers": [ + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "usd-coin", + "name": "USDC", + "symbol": "usdc", + "icon": "https://coin-images.coingecko.com/coins/images/6319/large/usdc.png?1696506694", + "market": { "coingeckoId": "usd-coin", "marketCapUsd": 35031669445 }, + "updatedAt": 1728782536762 + }, + "amount": "0.07788623" + } + ] + }, { "source": "bybit-future-pl_future-pl_1730101500000", "order": 0, diff --git a/tests/csv/bybit-future-pl.csv b/tests/csv/bybit-future-pl.csv index 2579e307ba1..22a173eb27c 100644 --- a/tests/csv/bybit-future-pl.csv +++ b/tests/csv/bybit-future-pl.csv @@ -2,5 +2,6 @@ Contracts,Trade Type,Qty,Entry Price,Realized P&L,Filled Price,Exit Type,Filled/ BTCUSDH25,SELL,500.00000000000000000000,79550.06490000000000000000,0.00107018000000000000,95950.13660000000000000000,Trade,11:36 2024-12-20,11:36 2024-12-20 OPPERP,SELL,3.00000000000000000000,2.15700000000000000000,0.02704777000000000000,2.16850000000000000000,Trade,2024-12-19 04:21:55,2024-12-19 04:21:55 OPPERP,BUY,3.00000000000000000000,2.33850000000000000000,-0.54514710000000000000,2.15700000000000000000,SessionSettlePnL,2024-12-19 00:00:00,2024-12-19 00:00:00 +SOL-31JAN25,SELL,0.03000000000000000000,225.00000000000000000000,-0.07788623000000000000,222.65000000000000000000,Trade,2024-12-18 01:51:46,2024-12-18 01:51:46 MANTAUSDT,BUY,200.00000000000000000000,1.03366120000000000000,74.85797060000000000000,0.66978905000000000000,Trade,07:45 2024-10-28,07:45 2024-10-28 AXSUSDT,BUY,100.00000000000000000000,5.36269710000000000000,-110.25364161000000000000,6.43144800000000000000,Trade,00:48 2024-07-21,00:48 2024-07-21 \ No newline at end of file From 25514e31ac081f518f7ae217da70e49a901cca51 Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 13:03:08 +0900 Subject: [PATCH 08/13] Create `bybit-option-delivary` csv format --- csvs/bybit-option-delivary.json | 192 ++++++++++++++++++++ tests/csv/bybit-option-delivary-result.json | 25 +++ tests/csv/bybit-option-delivary.csv | 2 + 3 files changed, 219 insertions(+) create mode 100644 csvs/bybit-option-delivary.json create mode 100644 tests/csv/bybit-option-delivary-result.json create mode 100644 tests/csv/bybit-option-delivary.csv diff --git a/csvs/bybit-option-delivary.json b/csvs/bybit-option-delivary.json new file mode 100644 index 00000000000..bcf83a8c7e6 --- /dev/null +++ b/csvs/bybit-option-delivary.json @@ -0,0 +1,192 @@ +{ + "id": "bybit-option-delivary", + "service": "bybit", + "formatter": { + "Contracts": ["string"], + "Direction": ["string"], + "Delivery Price": ["big-decimal"], + "Position": ["big-decimal"], + "Delivery P&L": ["big-decimal"], + "Fees": ["big-decimal"], + "CashFlow": ["big-decimal"], + "Delivery Time(UTC+0)": ["iso8601"] + }, + "parser": { + "parsers": [ + { + "description": "realize profit", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Delivery P&L" + }, + "pattern": { + "type": "positive" + } + } + ], + "generators": [ + { + "type": "realize-profit", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_delivary_", + { "type": "cell", "column": "Delivery Time(UTC+0)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Delivery Time(UTC+0)" + }, + "comment": { + "type": "join", + "values": [ + "Delivary: ", + { "type": "cell", "column": "Position" }, + " ", + { "type": "cell", "column": "Contracts" }, + " / Direction: ", + { "type": "cell", "column": "Direction" } + ] + }, + "transfers": [ + { + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Delivery P&L" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + } + ] + } + ] + }, + { + "description": "realize loss", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Delivery P&L" + }, + "pattern": { + "type": "negative" + } + } + ], + "generators": [ + { + "type": "realize-loss", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_delivary_", + { "type": "cell", "column": "Delivery Time(UTC+0)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Delivery Time(UTC+0)" + }, + "comment": { + "type": "join", + "values": [ + "Delivary: ", + { "type": "cell", "column": "Position" }, + " ", + { "type": "cell", "column": "Contracts" }, + " / Direction: ", + { "type": "cell", "column": "Direction" } + ] + }, + "transfers": [ + { + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Delivery P&L" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + } + ] + } + ] + }, + { + "description": "fee", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Fees" + }, + "pattern": { + "type": "positive" + } + } + ], + "generators": [ + { + "type": "fee", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_delivary_", + { "type": "cell", "column": "Delivery Time(UTC+0)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Delivery Time(UTC+0)" + }, + "comment": { + "type": "join", + "values": [ + "Delivary: ", + { "type": "cell", "column": "Position" }, + " ", + { "type": "cell", "column": "Contracts" }, + " / Direction: ", + { "type": "cell", "column": "Direction" } + ] + }, + "transfers": [ + { + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + } + ] + } + ] + } + ] + } +} diff --git a/tests/csv/bybit-option-delivary-result.json b/tests/csv/bybit-option-delivary-result.json new file mode 100644 index 00000000000..f8863dd564b --- /dev/null +++ b/tests/csv/bybit-option-delivary-result.json @@ -0,0 +1,25 @@ +[ + { + "source": "bybit-option-delivary_delivary_1730880001000", + "order": 0, + "type": "realize-profit", + "timestamp": 1730880001000, + "evidence": "system-rule", + "comment": "Delivary: \"0.2\" BTC-6NOV24-74000-P / Direction: SELL", + "transfers": [ + { + "direction": "in", + "asset": { + "type": "CryptoCurrency", + "id": "usd-coin", + "name": "USDC", + "symbol": "usdc", + "icon": "https://coin-images.coingecko.com/coins/images/6319/large/usdc.png?1696506694", + "market": { "coingeckoId": "usd-coin", "marketCapUsd": 35031669445 }, + "updatedAt": 1728782536762 + }, + "amount": "16.30226015" + } + ] + } +] diff --git a/tests/csv/bybit-option-delivary.csv b/tests/csv/bybit-option-delivary.csv new file mode 100644 index 00000000000..6e5531f3a55 --- /dev/null +++ b/tests/csv/bybit-option-delivary.csv @@ -0,0 +1,2 @@ +Contracts,Direction,Delivery Price,Position,Delivery P&L,Fees,CashFlow,Delivery Time(UTC+0) +BTC-6NOV24-74000-P,SELL,73778.55701135000000000000,0.20000000000000000000,16.30226015000000000000,0.00000000000000000000,44.28859773000000000000,2024-11-06 08:00:01 From 1de0b36e1d780d58a4b36cf3a61b27a496a2b427 Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 13:32:34 +0900 Subject: [PATCH 09/13] bump @0xtorch/csv dependency to version 0.0.50 --- bun.lockb | Bin 30867 -> 30867 bytes package.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bun.lockb b/bun.lockb index 8a2f0b0932589e37693a23d61d6d4aafe54aa03e..ca3281a7f8066eb591ee3a24f3cb9414b24c32e7 100755 GIT binary patch delta 142 zcmV;90CE45@d1%2vbsnJD&9UERDP4Y wA~uSqu&Pk;U@~6|zU7KdX*Lh7$AzU2vwbKQEdn(#vz1i`69P3bvz}=65C3aG)c^nh delta 142 zcmV;90CE45@d1fhR{o9RqX_@U5qLa`T@x)su}&Hc z0Wp)21t+tR46PeLupQOT&~&UGwBwFSQgtO(`q)!Q@&99$HBG|Ull`}#y!rl?g2S$j wABbm4R+T>Uq*N@yy@XoIA@ztE9~QV|vwbKQEdn$-vz1i`69P0jvz}=65Akh4RsaA1 diff --git a/package.json b/package.json index dae2ac08eed..31d8be8bf9d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "module": "index.ts", "dependencies": { "@0xtorch/core": "^0.0.57", - "@0xtorch/csv": "^0.0.49", + "@0xtorch/csv": "^0.0.50", "@0xtorch/evm": "^0.0.121", "@0xtorch/solana": "^0.0.43", "abitype": "^1.0.6", From 3ac7655a9a8150497a24495c552968257dd3557f Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 13:35:29 +0900 Subject: [PATCH 10/13] Create `bybit-spot-trade-2` csv format --- csvs/bybit-spot-trade-2.json | 1564 ++++++++++++++++++++++ tests/csv/bybit-spot-trade-2-result.json | 98 ++ tests/csv/bybit-spot-trade-2.csv | 3 + 3 files changed, 1665 insertions(+) create mode 100644 csvs/bybit-spot-trade-2.json create mode 100644 tests/csv/bybit-spot-trade-2-result.json create mode 100644 tests/csv/bybit-spot-trade-2.csv diff --git a/csvs/bybit-spot-trade-2.json b/csvs/bybit-spot-trade-2.json new file mode 100644 index 00000000000..5a5b970d8cb --- /dev/null +++ b/csvs/bybit-spot-trade-2.json @@ -0,0 +1,1564 @@ +{ + "id": "bybit-spot-trade-2", + "service": "bybit", + "formatter": { + "Spot Pairs": ["string"], + "Direction": ["string"], + "Filled Value": ["big-decimal"], + "Filled Quantity": ["big-decimal"], + "Fees": ["big-decimal"], + "Transaction ID": ["string"], + "Order No.": ["string"], + "Timestamp (UTC+0)": ["iso8601"] + }, + "parser": { + "parsers": [ + { + "description": "trade", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Direction" + }, + "pattern": { + "type": "in", + "values": ["BUY", "buy", "SELL", "sell"] + } + } + ], + "generators": [ + { + "type": "trade", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_spot-trade_", + { "type": "cell", "column": "Transaction ID" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Timestamp (UTC+0)" + }, + "transfers": [ + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDT", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDE", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "SOL", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "BTC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "ETH", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "DAI", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDT", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDE", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "SOL", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "BTC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "ETH", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Quantity" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "DAI", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDT" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDE" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "SOL" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "BTC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "ETH" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "DAI" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDT" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "USDE" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "SOL" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "BTC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "ETH" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + } + ], + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Filled Value" + } + }, + "asset": { + "type": "symbol", + "value": "DAI" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDT", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "USDE", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "SOL", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "BTC", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "ETH", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["BUY", "buy"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "split", + "value": { + "type": "cell", + "column": "Spot Pairs" + }, + "splitter": "DAI", + "index": 0 + } + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDT$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "USDT" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDC$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "USDC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+USDE$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "USDE" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+SOL$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "SOL" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+BTC$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "BTC" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+ETH$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "ETH" + } + }, + { + "target": [ + { + "column": "Direction", + "pattern": { + "type": "in", + "values": ["SELL", "sell"] + } + }, + { + "column": "Spot Pairs", + "pattern": { + "type": "reg-exp", + "pattern": "^[a-zA-Z0-9]+DAI$" + } + }, + { + "column": "Fees", + "pattern": { + "type": "positive" + } + } + ], + "direction": "out", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "Fees" + } + }, + "asset": { + "type": "symbol", + "value": "DAI" + } + } + ] + } + ] + } + ] + } +} diff --git a/tests/csv/bybit-spot-trade-2-result.json b/tests/csv/bybit-spot-trade-2-result.json new file mode 100644 index 00000000000..a5436f730da --- /dev/null +++ b/tests/csv/bybit-spot-trade-2-result.json @@ -0,0 +1,98 @@ +[ + { + "source": "bybit-spot-trade-2_spot-trade_1809861109692793344", + "order": 0, + "type": "trade", + "timestamp": 1730488257068, + "evidence": "system-rule", + "transfers": [ + { + "direction": "in", + "asset": { + "type": "CryptoCurrency", + "id": "celestia", + "name": "Celestia", + "symbol": "tia", + "icon": "https://coin-images.coingecko.com/coins/images/31967/large/tia.jpg?1696530772", + "market": { "coingeckoId": "celestia", "marketCapUsd": 1170688494 }, + "updatedAt": 1728782536762 + }, + "amount": "99.77" + }, + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "tether", + "name": "Tether", + "symbol": "usdt", + "icon": "https://coin-images.coingecko.com/coins/images/325/large/Tether.png?1696501661", + "market": { "coingeckoId": "tether", "marketCapUsd": 119675340267 }, + "updatedAt": 1728782536762 + }, + "amount": "449.9627" + }, + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "celestia", + "name": "Celestia", + "symbol": "tia", + "icon": "https://coin-images.coingecko.com/coins/images/31967/large/tia.jpg?1696530772", + "market": { "coingeckoId": "celestia", "marketCapUsd": 1170688494 }, + "updatedAt": 1728782536762 + }, + "amount": "0.09977" + } + ] + }, + { + "source": "bybit-spot-trade-2_spot-trade_1793584254622925312", + "order": 0, + "type": "trade", + "timestamp": 1728547904741, + "evidence": "system-rule", + "transfers": [ + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "carv", + "name": "CARV", + "symbol": "carv", + "icon": "missing_large.png", + "market": { "coingeckoId": "carv" }, + "updatedAt": 1720036911252 + }, + "amount": "146.18" + }, + { + "direction": "in", + "asset": { + "type": "CryptoCurrency", + "id": "tether", + "name": "Tether", + "symbol": "usdt", + "icon": "https://coin-images.coingecko.com/coins/images/325/large/Tether.png?1696501661", + "market": { "coingeckoId": "tether", "marketCapUsd": 119675340267 }, + "updatedAt": 1728782536762 + }, + "amount": "56.35239000000001" + }, + { + "direction": "out", + "asset": { + "type": "CryptoCurrency", + "id": "tether", + "name": "Tether", + "symbol": "usdt", + "icon": "https://coin-images.coingecko.com/coins/images/325/large/Tether.png?1696501661", + "market": { "coingeckoId": "tether", "marketCapUsd": 119675340267 }, + "updatedAt": 1728782536762 + }, + "amount": "0.05635239" + } + ] + } +] diff --git a/tests/csv/bybit-spot-trade-2.csv b/tests/csv/bybit-spot-trade-2.csv new file mode 100644 index 00000000000..d7e7ab455a7 --- /dev/null +++ b/tests/csv/bybit-spot-trade-2.csv @@ -0,0 +1,3 @@ +Spot Pairs,Order Type,Direction,Filled Value,Filled Price,Filled Quantity,Fees,Transaction ID,Order No.,Timestamp (UTC+0) +TIAUSDT,0,buy,449.9627,4.510000000000000000,99.770000000000000000,0.099770000000000000,1809861109692793344,1807568328609792512,2024-11-01T19:10:57.068Z +CARVUSDT,0,sell,56.35239000000001,0.385500000000000000,146.180000000000000000,0.056352390000000000,1793584254622925312,1793579196183249408,2024-10-10T08:11:44.741Z \ No newline at end of file From 340f56e135afacf2953f85ca78dfdef1520a53cd Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 13:37:48 +0900 Subject: [PATCH 11/13] Add symbolAssetMap for RNDR in multiple CSV files --- csvs/bybit-funding-account.json | 3 +++ csvs/bybit-future-pl-before-uta.json | 3 +++ csvs/bybit-future-pl.json | 3 +++ csvs/bybit-option-delivary.json | 3 +++ csvs/bybit-spot-trade-2.json | 3 +++ csvs/bybit-spot-trade-before-uta.json | 3 +++ csvs/bybit-spot-trade.json | 3 +++ csvs/bybit-statement-account-contract.json | 3 +++ csvs/bybit-statement-account-uta.json | 3 +++ csvs/bybit-statement-uta-spot-trade.json | 3 +++ 10 files changed, 30 insertions(+) diff --git a/csvs/bybit-funding-account.json b/csvs/bybit-funding-account.json index 06d26eda657..21039d2b18d 100644 --- a/csvs/bybit-funding-account.json +++ b/csvs/bybit-funding-account.json @@ -172,5 +172,8 @@ ] } ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" } } diff --git a/csvs/bybit-future-pl-before-uta.json b/csvs/bybit-future-pl-before-uta.json index f59ff26595a..66efedd55f5 100644 --- a/csvs/bybit-future-pl-before-uta.json +++ b/csvs/bybit-future-pl-before-uta.json @@ -230,5 +230,8 @@ ] } ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" } } diff --git a/csvs/bybit-future-pl.json b/csvs/bybit-future-pl.json index 164ae202bfa..13a473556b0 100644 --- a/csvs/bybit-future-pl.json +++ b/csvs/bybit-future-pl.json @@ -563,5 +563,8 @@ ] } ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" } } diff --git a/csvs/bybit-option-delivary.json b/csvs/bybit-option-delivary.json index bcf83a8c7e6..522adff229e 100644 --- a/csvs/bybit-option-delivary.json +++ b/csvs/bybit-option-delivary.json @@ -188,5 +188,8 @@ ] } ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" } } diff --git a/csvs/bybit-spot-trade-2.json b/csvs/bybit-spot-trade-2.json index 5a5b970d8cb..47f6d306517 100644 --- a/csvs/bybit-spot-trade-2.json +++ b/csvs/bybit-spot-trade-2.json @@ -1560,5 +1560,8 @@ ] } ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" } } diff --git a/csvs/bybit-spot-trade-before-uta.json b/csvs/bybit-spot-trade-before-uta.json index 01817fde49d..f01b1b4ef7d 100644 --- a/csvs/bybit-spot-trade-before-uta.json +++ b/csvs/bybit-spot-trade-before-uta.json @@ -218,5 +218,8 @@ ] } ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" } } diff --git a/csvs/bybit-spot-trade.json b/csvs/bybit-spot-trade.json index f38cf03c537..38d84682c23 100644 --- a/csvs/bybit-spot-trade.json +++ b/csvs/bybit-spot-trade.json @@ -1434,5 +1434,8 @@ ] } ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" } } diff --git a/csvs/bybit-statement-account-contract.json b/csvs/bybit-statement-account-contract.json index 35e0e85eb5c..d174c32fb7c 100644 --- a/csvs/bybit-statement-account-contract.json +++ b/csvs/bybit-statement-account-contract.json @@ -131,5 +131,8 @@ ] } ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" } } diff --git a/csvs/bybit-statement-account-uta.json b/csvs/bybit-statement-account-uta.json index b04a193047b..59f930c04f5 100644 --- a/csvs/bybit-statement-account-uta.json +++ b/csvs/bybit-statement-account-uta.json @@ -189,5 +189,8 @@ ] } ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" } } diff --git a/csvs/bybit-statement-uta-spot-trade.json b/csvs/bybit-statement-uta-spot-trade.json index fa1c18665ac..db2a9a65f21 100644 --- a/csvs/bybit-statement-uta-spot-trade.json +++ b/csvs/bybit-statement-uta-spot-trade.json @@ -1434,5 +1434,8 @@ ] } ] + }, + "symbolAssetMap": { + "RNDR": "crypto/render-token" } } From 3ec1b2b10f0b041c415e79f30efe200efb280d90 Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 13:50:34 +0900 Subject: [PATCH 12/13] Update `bybit-funding-account` csv format --- csvs/bybit-funding-account.json | 57 +++++++++++++++++++++ tests/csv/bybit-funding-account-result.json | 23 +++++++++ tests/csv/bybit-funding-account.csv | 3 +- 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/csvs/bybit-funding-account.json b/csvs/bybit-funding-account.json index 21039d2b18d..ddef4ad8735 100644 --- a/csvs/bybit-funding-account.json +++ b/csvs/bybit-funding-account.json @@ -10,6 +10,63 @@ }, "parser": { "parsers": [ + { + "description": "Airdrop > airdrop", + "conditions": [ + { + "value": { + "type": "cell", + "column": "Type" + }, + "pattern": "Airdrop" + } + ], + "generators": [ + { + "type": "airdrop", + "source": { + "type": "join", + "values": [ + { "type": "service" }, + "_funding-account_", + { "type": "cell", "column": "Date & Time(UTC)" } + ] + }, + "timestamp": { + "type": "cell", + "column": "Date & Time(UTC)" + }, + "comment": { + "type": "join", + "values": [ + "Type:", + { "type": "cell", "column": "Type" }, + " / Description: ", + { "type": "cell", "column": "Description" } + ] + }, + "transfers": [ + { + "direction": "in", + "amount": { + "type": "text", + "value": { + "type": "cell", + "column": "QTY" + } + }, + "asset": { + "type": "symbol", + "value": { + "type": "cell", + "column": "Coin" + } + } + } + ] + } + ] + }, { "description": "Earn: Flexible Savings Interest Distribution", "conditions": [ diff --git a/tests/csv/bybit-funding-account-result.json b/tests/csv/bybit-funding-account-result.json index b9793e25185..8fbc521d632 100644 --- a/tests/csv/bybit-funding-account-result.json +++ b/tests/csv/bybit-funding-account-result.json @@ -98,5 +98,28 @@ "evidence": "system-rule", "comment": "Type:Earn / Description: Flexible Savings Subscription / \"-13.20854384\"ETH", "transfers": [] + }, + { + "source": "bybit-funding-account_funding-account_1707371859000", + "order": 0, + "type": "airdrop", + "timestamp": 1707371859000, + "evidence": "system-rule", + "comment": "Type:Airdrop / Description: Airdrop Bonus", + "transfers": [ + { + "direction": "in", + "asset": { + "type": "CryptoCurrency", + "id": "tether", + "name": "Tether", + "symbol": "usdt", + "icon": "https://coin-images.coingecko.com/coins/images/325/large/Tether.png?1696501661", + "market": { "coingeckoId": "tether", "marketCapUsd": 119675340267 }, + "updatedAt": 1728782536762 + }, + "amount": "0.0194" + } + ] } ] diff --git a/tests/csv/bybit-funding-account.csv b/tests/csv/bybit-funding-account.csv index 1d338955c1f..e23c989cfdd 100644 --- a/tests/csv/bybit-funding-account.csv +++ b/tests/csv/bybit-funding-account.csv @@ -6,4 +6,5 @@ Date & Time(UTC),Coin,QTY,Type,Account Balance,Description 2024-12-14 2:34:04,USDT,-13.8614,Transfer out,0,Transfer to Unified Trading Account 2024-11-05 11:51:49,USDT,9807.548542,Deposit,9858.644242,Deposit 2024-11-01 0:29:00,ETH,0.00019189,Earn,0.00067161,Flexible Savings Interest Distribution -2024-10-28 10:21:16,ETH,-13.20854384,Earn,0,Flexible Savings Subscription \ No newline at end of file +2024-10-28 10:21:16,ETH,-13.20854384,Earn,0,Flexible Savings Subscription +2024-02-08 05:57:39,USDT,0.019400000000000000,Airdrop,0.019400000000000000,Airdrop Bonus \ No newline at end of file From 3310560fd6ba617e63a04998e115deb3087fe84d Mon Sep 17 00:00:00 2001 From: 0xnekoya Date: Wed, 15 Jan 2025 13:58:53 +0900 Subject: [PATCH 13/13] Update `bybit-funding-account` csv format --- csvs/bybit-funding-account.json | 19 ++++++++-- tests/csv/bybit-funding-account-result.json | 41 +++++++++++++++++++++ tests/csv/bybit-funding-account.csv | 5 ++- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/csvs/bybit-funding-account.json b/csvs/bybit-funding-account.json index ddef4ad8735..c8baf1a640c 100644 --- a/csvs/bybit-funding-account.json +++ b/csvs/bybit-funding-account.json @@ -68,7 +68,7 @@ ] }, { - "description": "Earn: Flexible Savings Interest Distribution", + "description": "Earn: Flexible Savings Interest Distribution / Fixed Savings Interest Distribution > interest", "conditions": [ { "value": { @@ -82,7 +82,13 @@ "type": "cell", "column": "Description" }, - "pattern": "Flexible Savings Interest Distribution" + "pattern": { + "type": "in", + "values": [ + "Flexible Savings Interest Distribution", + "Fixed Savings Interest Distribution" + ] + } } ], "generators": [ @@ -132,7 +138,7 @@ ] }, { - "description": "ignore > Earn", + "description": "Earn: / Flexible Savings Subscription / Fixed Savings Subscription / Fixed Savings Principal Redemption > ignore", "conditions": [ { "value": { @@ -148,7 +154,12 @@ }, "pattern": { "type": "in", - "values": ["", "Flexible Savings Subscription"] + "values": [ + "", + "Flexible Savings Subscription", + "Fixed Savings Subscription", + "Fixed Savings Principal Redemption" + ] } } ], diff --git a/tests/csv/bybit-funding-account-result.json b/tests/csv/bybit-funding-account-result.json index 8fbc521d632..64ebbc63564 100644 --- a/tests/csv/bybit-funding-account-result.json +++ b/tests/csv/bybit-funding-account-result.json @@ -121,5 +121,46 @@ "amount": "0.0194" } ] + }, + { + "source": "bybit-funding-account_funding-account_1683765445000", + "order": 0, + "type": "interest", + "timestamp": 1683765445000, + "evidence": "system-rule", + "comment": "Type:Earn / Description: Fixed Savings Interest Distribution", + "transfers": [ + { + "direction": "in", + "asset": { + "type": "CryptoCurrency", + "id": "sui", + "name": "Sui", + "symbol": "sui", + "icon": "https://coin-images.coingecko.com/coins/images/26375/large/sui-ocean-square.png?1727791290", + "market": { "coingeckoId": "sui", "marketCapUsd": 6222595843 }, + "updatedAt": 1728782536762 + }, + "amount": "13.492931" + } + ] + }, + { + "source": "bybit-funding-account_funding-account_1683765445000", + "order": 1, + "type": "ignore", + "timestamp": 1683765445000, + "evidence": "system-rule", + "comment": "Type:Earn / Description: Fixed Savings Principal Redemption / \"799.5\"SUI", + "transfers": [] + }, + { + "source": "bybit-funding-account_funding-account_1683133052000", + "order": 0, + "type": "ignore", + "timestamp": 1683133052000, + "evidence": "system-rule", + "comment": "Type:Earn / Description: Fixed Savings Subscription / \"-799.5\"SUI", + "transfers": [] } ] diff --git a/tests/csv/bybit-funding-account.csv b/tests/csv/bybit-funding-account.csv index e23c989cfdd..d9f571cdeda 100644 --- a/tests/csv/bybit-funding-account.csv +++ b/tests/csv/bybit-funding-account.csv @@ -7,4 +7,7 @@ Date & Time(UTC),Coin,QTY,Type,Account Balance,Description 2024-11-05 11:51:49,USDT,9807.548542,Deposit,9858.644242,Deposit 2024-11-01 0:29:00,ETH,0.00019189,Earn,0.00067161,Flexible Savings Interest Distribution 2024-10-28 10:21:16,ETH,-13.20854384,Earn,0,Flexible Savings Subscription -2024-02-08 05:57:39,USDT,0.019400000000000000,Airdrop,0.019400000000000000,Airdrop Bonus \ No newline at end of file +2024-02-08 05:57:39,USDT,0.019400000000000000,Airdrop,0.019400000000000000,Airdrop Bonus +2023-05-11 00:37:25,SUI,13.492931000000000000,Earn,812.992931000000000000,Fixed Savings Interest Distribution +2023-05-11 00:37:25,SUI,799.500000000000000000,Earn,799.500000000000000000,Fixed Savings Principal Redemption +2023-05-03 16:57:32,SUI,-799.500000000000000000,Earn,0.000000000000000000,Fixed Savings Subscription \ No newline at end of file