@0xtorch/csv 0.0.74 → 0.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/.DS_Store +0 -0
  2. package/_cjs/getCsvRowCount.js +1 -0
  3. package/_cjs/getCsvRowCount.js.map +1 -1
  4. package/_cjs/hasValidHeaderRow.js +7 -7
  5. package/_cjs/hasValidHeaderRow.js.map +1 -1
  6. package/_cjs/parseCsvFileToActions.js +2 -1
  7. package/_cjs/parseCsvFileToActions.js.map +1 -1
  8. package/_cjs/parseRowsToActions/allValue.js +9 -1
  9. package/_cjs/parseRowsToActions/allValue.js.map +1 -1
  10. package/_cjs/parseRowsToActions/asset.js +7 -4
  11. package/_cjs/parseRowsToActions/asset.js.map +1 -1
  12. package/_cjs/parseRowsToActions/index.js +4 -1
  13. package/_cjs/parseRowsToActions/index.js.map +1 -1
  14. package/_cjs/parseRowsToActions/joinValue.js +10 -3
  15. package/_cjs/parseRowsToActions/joinValue.js.map +1 -1
  16. package/_cjs/parseRowsToActions/matchValue.js +2 -2
  17. package/_cjs/parseRowsToActions/matchValue.js.map +1 -1
  18. package/_cjs/parseRowsToActions/mathValue.js +17 -6
  19. package/_cjs/parseRowsToActions/mathValue.js.map +1 -1
  20. package/_cjs/parseRowsToActions/parse.js +9 -6
  21. package/_cjs/parseRowsToActions/parse.js.map +1 -1
  22. package/_cjs/parseRowsToActions/simpleValue.js +4 -1
  23. package/_cjs/parseRowsToActions/simpleValue.js.map +1 -1
  24. package/_cjs/parseRowsToActions/sliceValue.js +7 -3
  25. package/_cjs/parseRowsToActions/sliceValue.js.map +1 -1
  26. package/_cjs/parseRowsToActions/splitValue.js +2 -2
  27. package/_cjs/parseRowsToActions/splitValue.js.map +1 -1
  28. package/_cjs/parseRowsToActions/transfer.js +12 -8
  29. package/_cjs/parseRowsToActions/transfer.js.map +1 -1
  30. package/_cjs/schemas/parser.js +5 -1
  31. package/_cjs/schemas/parser.js.map +1 -1
  32. package/_cjs/streamCsvToActions.js +5 -1
  33. package/_cjs/streamCsvToActions.js.map +1 -1
  34. package/_esm/getCsvRowCount.js +1 -0
  35. package/_esm/getCsvRowCount.js.map +1 -1
  36. package/_esm/hasValidHeaderRow.js +7 -7
  37. package/_esm/hasValidHeaderRow.js.map +1 -1
  38. package/_esm/parseCsvFileToActions.js +2 -1
  39. package/_esm/parseCsvFileToActions.js.map +1 -1
  40. package/_esm/parseRowsToActions/allValue.js +9 -1
  41. package/_esm/parseRowsToActions/allValue.js.map +1 -1
  42. package/_esm/parseRowsToActions/asset.js +7 -4
  43. package/_esm/parseRowsToActions/asset.js.map +1 -1
  44. package/_esm/parseRowsToActions/index.js +4 -1
  45. package/_esm/parseRowsToActions/index.js.map +1 -1
  46. package/_esm/parseRowsToActions/joinValue.js +10 -3
  47. package/_esm/parseRowsToActions/joinValue.js.map +1 -1
  48. package/_esm/parseRowsToActions/matchValue.js +2 -2
  49. package/_esm/parseRowsToActions/matchValue.js.map +1 -1
  50. package/_esm/parseRowsToActions/mathValue.js +17 -6
  51. package/_esm/parseRowsToActions/mathValue.js.map +1 -1
  52. package/_esm/parseRowsToActions/parse.js +9 -6
  53. package/_esm/parseRowsToActions/parse.js.map +1 -1
  54. package/_esm/parseRowsToActions/simpleValue.js +4 -1
  55. package/_esm/parseRowsToActions/simpleValue.js.map +1 -1
  56. package/_esm/parseRowsToActions/sliceValue.js +7 -3
  57. package/_esm/parseRowsToActions/sliceValue.js.map +1 -1
  58. package/_esm/parseRowsToActions/splitValue.js +2 -2
  59. package/_esm/parseRowsToActions/splitValue.js.map +1 -1
  60. package/_esm/parseRowsToActions/transfer.js +12 -8
  61. package/_esm/parseRowsToActions/transfer.js.map +1 -1
  62. package/_esm/schemas/parser.js +4 -0
  63. package/_esm/schemas/parser.js.map +1 -1
  64. package/_esm/streamCsvToActions.js +5 -1
  65. package/_esm/streamCsvToActions.js.map +1 -1
  66. package/_types/getCsvRowCount.d.ts.map +1 -1
  67. package/_types/hasValidHeaderRow.d.ts.map +1 -1
  68. package/_types/parseCsvFileToActions.d.ts +2 -1
  69. package/_types/parseCsvFileToActions.d.ts.map +1 -1
  70. package/_types/parseRowsToActions/allValue.d.ts +2 -1
  71. package/_types/parseRowsToActions/allValue.d.ts.map +1 -1
  72. package/_types/parseRowsToActions/asset.d.ts +6 -3
  73. package/_types/parseRowsToActions/asset.d.ts.map +1 -1
  74. package/_types/parseRowsToActions/index.d.ts +3 -1
  75. package/_types/parseRowsToActions/index.d.ts.map +1 -1
  76. package/_types/parseRowsToActions/joinValue.d.ts +2 -1
  77. package/_types/parseRowsToActions/joinValue.d.ts.map +1 -1
  78. package/_types/parseRowsToActions/matchValue.d.ts +2 -1
  79. package/_types/parseRowsToActions/matchValue.d.ts.map +1 -1
  80. package/_types/parseRowsToActions/mathValue.d.ts +2 -1
  81. package/_types/parseRowsToActions/mathValue.d.ts.map +1 -1
  82. package/_types/parseRowsToActions/parse.d.ts +2 -1
  83. package/_types/parseRowsToActions/parse.d.ts.map +1 -1
  84. package/_types/parseRowsToActions/simpleValue.d.ts +2 -1
  85. package/_types/parseRowsToActions/simpleValue.d.ts.map +1 -1
  86. package/_types/parseRowsToActions/sliceValue.d.ts +2 -1
  87. package/_types/parseRowsToActions/sliceValue.d.ts.map +1 -1
  88. package/_types/parseRowsToActions/splitValue.d.ts +2 -1
  89. package/_types/parseRowsToActions/splitValue.d.ts.map +1 -1
  90. package/_types/parseRowsToActions/transfer.d.ts +2 -1
  91. package/_types/parseRowsToActions/transfer.d.ts.map +1 -1
  92. package/_types/schemas/format.d.ts +9360 -0
  93. package/_types/schemas/format.d.ts.map +1 -1
  94. package/_types/schemas/parser.d.ts +21287 -0
  95. package/_types/schemas/parser.d.ts.map +1 -1
  96. package/_types/streamCsvToActions.d.ts +2 -1
  97. package/_types/streamCsvToActions.d.ts.map +1 -1
  98. package/getCsvRowCount.ts +1 -0
  99. package/hasValidHeaderRow.ts +10 -7
  100. package/package.json +1 -1
  101. package/parseCsvFileToActions.ts +3 -0
  102. package/parseRowsToActions/allValue.ts +10 -0
  103. package/parseRowsToActions/asset.ts +10 -1
  104. package/parseRowsToActions/index.ts +6 -0
  105. package/parseRowsToActions/joinValue.ts +14 -1
  106. package/parseRowsToActions/matchValue.ts +3 -1
  107. package/parseRowsToActions/mathValue.ts +20 -3
  108. package/parseRowsToActions/parse.ts +18 -5
  109. package/parseRowsToActions/simpleValue.ts +5 -0
  110. package/parseRowsToActions/sliceValue.ts +9 -1
  111. package/parseRowsToActions/splitValue.ts +3 -1
  112. package/parseRowsToActions/transfer.ts +15 -5
  113. package/schemas/parser.ts +5 -0
  114. package/streamCsvToActions.ts +6 -0
  115. package/tests/.DS_Store +0 -0
  116. package/tests/okx-trade-jst-backup.csv +0 -18
  117. package/tests/okx-trade-jst.csv +0 -3
  118. package/tests/okx.ts +0 -275
@@ -24,6 +24,7 @@ export const createTransfers = ({
24
24
  schema,
25
25
  rows,
26
26
  service,
27
+ fileId,
27
28
  symbolAssetMap,
28
29
  cryptoes,
29
30
  fiats,
@@ -31,6 +32,7 @@ export const createTransfers = ({
31
32
  schema: z.infer<typeof transferComponentSchema>
32
33
  rows: readonly FormattedRow[]
33
34
  service: string
35
+ fileId: string
34
36
  symbolAssetMap?: { readonly [symbol: string]: string }
35
37
  cryptoes: readonly CryptoCurrency[]
36
38
  fiats: readonly FiatCurrency[]
@@ -40,6 +42,7 @@ export const createTransfers = ({
40
42
  schema,
41
43
  rows,
42
44
  service,
45
+ fileId,
43
46
  symbolAssetMap,
44
47
  cryptoes,
45
48
  fiats,
@@ -59,6 +62,7 @@ export const createTransfers = ({
59
62
  schema,
60
63
  rows: [targetRow],
61
64
  service,
65
+ fileId,
62
66
  symbolAssetMap,
63
67
  cryptoes,
64
68
  fiats,
@@ -95,6 +99,7 @@ const createSingleTransfer = ({
95
99
  schema,
96
100
  rows,
97
101
  service,
102
+ fileId,
98
103
  symbolAssetMap,
99
104
  cryptoes,
100
105
  fiats,
@@ -102,6 +107,7 @@ const createSingleTransfer = ({
102
107
  schema: z.infer<typeof transferComponentSchema>
103
108
  rows: readonly FormattedRow[]
104
109
  service: string
110
+ fileId: string
105
111
  symbolAssetMap?: { readonly [symbol: string]: string }
106
112
  cryptoes: readonly CryptoCurrency[]
107
113
  fiats: readonly FiatCurrency[]
@@ -109,15 +115,15 @@ const createSingleTransfer = ({
109
115
  const from =
110
116
  schema.from === undefined
111
117
  ? undefined
112
- : stringify(getAllValue({ schema: schema.from, rows, service }))
118
+ : stringify(getAllValue({ schema: schema.from, rows, service, fileId }))
113
119
  const to =
114
120
  schema.to === undefined
115
121
  ? undefined
116
- : stringify(getAllValue({ schema: schema.to, rows, service }))
122
+ : stringify(getAllValue({ schema: schema.to, rows, service, fileId }))
117
123
  const priceValue =
118
124
  schema.price === undefined
119
125
  ? undefined
120
- : getAllValue({ schema: schema.price, rows, service })
126
+ : getAllValue({ schema: schema.price, rows, service, fileId })
121
127
  let price: BigDecimal | undefined
122
128
  if (typeof priceValue === 'string') {
123
129
  if (priceValue.length === 0) {
@@ -140,6 +146,7 @@ const createSingleTransfer = ({
140
146
  schema: schema.asset,
141
147
  rows,
142
148
  service,
149
+ fileId,
143
150
  symbolAssetMap,
144
151
  cryptoes,
145
152
  fiats,
@@ -149,6 +156,7 @@ const createSingleTransfer = ({
149
156
  schema: schema.amount,
150
157
  rows,
151
158
  service,
159
+ fileId,
152
160
  }),
153
161
  ),
154
162
  price,
@@ -159,15 +167,17 @@ const createAmount = ({
159
167
  schema,
160
168
  rows,
161
169
  service,
170
+ fileId,
162
171
  }: {
163
172
  schema: z.infer<typeof amountSchema>
164
173
  rows: readonly FormattedRow[]
165
174
  service: string
175
+ fileId: string
166
176
  }): BigDecimal => {
167
177
  switch (schema.type) {
168
178
  case 'decimal': {
169
179
  const baseValue = stringify(
170
- getAllValue({ schema: schema.value, rows, service }),
180
+ getAllValue({ schema: schema.value, rows, service, fileId }),
171
181
  )
172
182
  let value: bigint
173
183
  if (baseValue === stringify(undefined)) {
@@ -183,7 +193,7 @@ const createAmount = ({
183
193
  }
184
194
  }
185
195
  case 'text': {
186
- const value = getAllValue({ schema: schema.value, rows, service })
196
+ const value = getAllValue({ schema: schema.value, rows, service, fileId })
187
197
  if (value === undefined) {
188
198
  return createBigDecimal(0n)
189
199
  }
package/schemas/parser.ts CHANGED
@@ -13,6 +13,10 @@ export const cellValueSchema = z.object({
13
13
  row: indexSchema.optional().transform((v) => v ?? 0),
14
14
  })
15
15
 
16
+ export const fileIdValueSchema = z.object({
17
+ type: z.literal('file-id'),
18
+ })
19
+
16
20
  export const serviceValueSchema = z.object({
17
21
  type: z.literal('service'),
18
22
  })
@@ -20,6 +24,7 @@ export const serviceValueSchema = z.object({
20
24
  export const simpleValueSchema = z.union([
21
25
  z.string(),
22
26
  cellValueSchema,
27
+ fileIdValueSchema,
23
28
  serviceValueSchema,
24
29
  ])
25
30
 
@@ -6,6 +6,7 @@ import { createKeyValue } from './parseRowsToActions/key'
6
6
  import type { CsvFormat, FormattedRow } from './types'
7
7
 
8
8
  type StreamCsvToActionsParameters = {
9
+ fileId: string
9
10
  file: File | string
10
11
  encoding: string
11
12
  format: CsvFormat
@@ -25,6 +26,7 @@ type StreamCsvToActionsReturnTypes = {
25
26
  }
26
27
 
27
28
  export const streamCsvToActions = async ({
29
+ fileId,
28
30
  file,
29
31
  encoding,
30
32
  format,
@@ -55,6 +57,7 @@ export const streamCsvToActions = async ({
55
57
  parse(file, {
56
58
  header: false,
57
59
  skipEmptyLines: true,
60
+ newline: '\n',
58
61
  encoding,
59
62
  complete: () => {
60
63
  resolve()
@@ -153,6 +156,7 @@ export const streamCsvToActions = async ({
153
156
  parsers: format.parser.parsers,
154
157
  symbolAssetMap: format.symbolAssetMap,
155
158
  service: format.service,
159
+ fileId,
156
160
  cryptoes,
157
161
  fiats,
158
162
  })
@@ -176,6 +180,7 @@ export const streamCsvToActions = async ({
176
180
  parsers: format.parser.parsers,
177
181
  symbolAssetMap: format.symbolAssetMap,
178
182
  service: format.service,
183
+ fileId,
179
184
  cryptoes,
180
185
  fiats,
181
186
  })
@@ -237,6 +242,7 @@ export const streamCsvToActions = async ({
237
242
  parsers: format.parser.parsers,
238
243
  symbolAssetMap: format.symbolAssetMap,
239
244
  service: format.service,
245
+ fileId,
240
246
  cryptoes,
241
247
  fiats,
242
248
  })
Binary file
@@ -1,18 +0,0 @@
1
- UID:,Account Type:,Time Zone:UTC+9
2
- id,Order id,Time,Trade Type,Symbol,Action,Amount,Trading Unit,Filled Price,PnL,Fee,Fee Unit,Position Change,Position Balance,Balance Change,Balance,Balance Unit
3
- 667165099547201542,667165099534618642,2024-01-16 01:35:55,Spot,ETH-USDT,Buy,0.06301100,ETH,2519.40000000,0E-8,-0.00003151,ETH,0E-8,0E-8,0.06297949,8.34093237,ETH
4
- 667165099547201543,667165099534618642,2024-01-16 01:35:55,Spot,ETH-USDT,Sell,158.74991340,ETH,2519.40000000,0E-8,0E-8,USDT,0E-8,0E-8,-158.74991340,17202.73187832,USDT
5
- 667166838446919694,667166838433615872,2024-01-16 01:42:49,Transfer,,Transfer in,0,cont,0E-8,0E-8,0E-8,USDT,0E-8,0E-8,3.87864514,17206.61052346,USDT
6
- 667156126383247364,0,2024-01-16 01:00:15,Swap,ETH-USDT-SWAP,Funding fee income,10,cont,2515.07000000,0.45640796,0E-8,USDT,0E-8,0E-8,0.45640796,17156.08193268,USDT
7
- 667035278628392989,529436909564100616,2024-01-15 17:00:03,Swap,AXS-USDT-SWAP,Funding fee expense,20000,cont,7.90200000,-6.69940146,0E-8,USDT,0E-8,0E-8,-6.69940146,17012.18748172,USDT
8
- 665676914052861960,0,2024-01-11 23:02:23,Swap,AXS-USDT-SWAP,Manual margin increase,500,cont,0E-8,0E-8,0E-8,USDT,500.00000000,7831.00572500,-500.00000000,16523.01856039,USDT
9
- 663776891149000707,0,2024-01-06 17:12:23,Swap,SLP-USDT-SWAP,Manual margin decrease,2000,cont,0E-8,0E-8,0E-8,USDT,-2000.00000000,9121.74769750,2000.00000000,16300.49863796,USDT
10
- 662758029959929856,662758029951541258,2024-01-03 21:43:47,Swap,SUI-USDT-SWAP,Buy,449,cont,0.78400000,-78.60636183,-0.10560480,USDT,-276.84278373,836.69411475,198.13081711,12990.45785307,USDT
11
- 662758029959929863,662758029951541258,2024-01-03 21:43:47,Swap,SUI-USDT-SWAP,Buy,81,cont,0.78410000,-14.18875771,-0.01905363,USDT,-49.94268482,0E-8,35.73487348,13589.22490604,USDT
12
- 662758029959929859,662758029951541258,2024-01-03 21:43:47,Swap,SUI-USDT-SWAP,Buy,330,cont,0.78400000,-57.77304990,-0.07761600,USDT,-203.47019740,234.91559154,145.61953151,13421.13864928,USDT
13
- 662758029959929861,662758029951541258,2024-01-03 21:43:47,Swap,SUI-USDT-SWAP,Buy,300,cont,0.78410000,-52.55095445,-0.07056900,USDT,-184.97290672,49.94268482,132.35138328,13553.49003255,USDT
14
- 662758029959929857,662758029951541258,2024-01-03 21:43:47,Swap,SUI-USDT-SWAP,Buy,646,cont,0.78400000,-113.09512191,-0.15193920,USDT,-398.30832581,438.38578894,285.06126470,13275.51911777,USDT
15
- 662758029955735578,662758029951541258,2024-01-03 21:43:47,Swap,SUI-USDT-SWAP,Buy,257,cont,0.78400000,-44.99295098,-0.06044640,USDT,-158.46012343,1271.99702191,113.40672605,12678.92030991,USDT
16
- 662758029955735568,662758029951541258,2024-01-03 21:43:47,Swap,SUI-USDT-SWAP,Buy,300,cont,0.78390000,-52.49095445,-0.07055100,USDT,-184.97290672,1707.91650542,132.41140128,12366.94149544,USDT
17
- 662758029955735576,662758029951541258,2024-01-03 21:43:47,Swap,SUI-USDT-SWAP,Buy,450,cont,0.78400000,-78.78143168,-0.10584000,USDT,-277.45936009,1430.45714534,198.57208842,12565.51358386,USDT
18
- 662758029955735582,662758029951541258,2024-01-03 21:43:47,Swap,SUI-USDT-SWAP,Buy,257,cont,0.78400000,-44.99295098,-0.06044640,USDT,-158.46012343,1113.53689848,113.40672605,12792.32703596,USDT
@@ -1,3 +0,0 @@
1
- UID:469514189849931987,Account Type:Sub,Time Zone:UTC+9
2
- id,Order id,Time,Trade Type,Symbol,Action,Amount,Trading Unit,Filled Price,PnL,Fee,Fee Unit,Position Change,Position Balance,Balance Change,Balance,Balance Unit
3
- 684488648108486666,684488648086896640,2024-03-03 20:53:30,Transfer,,Transfer out,0,cont,0E-8,0E-8,0E-8,WLD,0E-8,0E-8,-0.00015600,0E-8,WLD
package/tests/okx.ts DELETED
@@ -1,275 +0,0 @@
1
- import type { CsvFormat } from '../types'
2
-
3
- export const okxTradeJstFormat = {
4
- id: 'okx-trade-jst',
5
- service: 'okx',
6
- headerStartColumns: ['^.*id$'],
7
- headerCheckRowSize: 4,
8
- formatter: {
9
- 'Order id': ['string'],
10
- Time: ['iso8601-jp'],
11
- 'Trade Type': ['string'],
12
- Symbol: ['string'],
13
- Action: ['string'],
14
- PnL: ['big-decimal'],
15
- Fee: ['big-decimal'],
16
- 'Fee Unit': ['string'],
17
- 'Balance Change': ['big-decimal'],
18
- 'Balance Unit': ['string'],
19
- },
20
- parser: {
21
- key: ['Order id', 'Time'],
22
- parsers: [
23
- {
24
- conditions: [
25
- {
26
- value: { type: 'cell', column: 'Trade Type', row: 0 },
27
- pattern: 'Swap',
28
- },
29
- {
30
- value: { type: 'cell', column: 'Action', row: 0 },
31
- pattern: {
32
- type: 'in',
33
- values: ['Buy', 'Sell'],
34
- },
35
- },
36
- ],
37
- generators: [
38
- {
39
- type: 'realize-profit',
40
- source: {
41
- type: 'join',
42
- values: [
43
- { type: 'service' },
44
- '_trade_',
45
- { type: 'cell', column: 'Order id', row: 0 },
46
- '_',
47
- { type: 'cell', column: 'Time', row: 0 },
48
- ],
49
- },
50
- timestamp: {
51
- type: 'cell',
52
- column: 'Time',
53
- row: 0,
54
- },
55
- comment: {
56
- type: 'join',
57
- values: [
58
- 'Trade Type: ',
59
- { type: 'cell', column: 'Trade Type', row: 0 },
60
- ' / Symbol: ',
61
- { type: 'cell', column: 'Symbol', row: 0 },
62
- ' / Action: ',
63
- { type: 'cell', column: 'Action', row: 0 },
64
- ],
65
- },
66
- transfers: [
67
- {
68
- target: [
69
- {
70
- column: 'PnL',
71
- pattern: { type: 'positive' },
72
- },
73
- ],
74
- direction: 'in',
75
- amount: {
76
- type: 'text',
77
- value: { type: 'cell', column: 'PnL', row: 0 },
78
- },
79
- asset: {
80
- type: 'symbol',
81
- value: { type: 'cell', column: 'Fee Unit', row: 0 },
82
- },
83
- },
84
- ],
85
- },
86
- {
87
- type: 'realize-loss',
88
- source: {
89
- type: 'join',
90
- values: [
91
- { type: 'service' },
92
- '_trade_',
93
- { type: 'cell', column: 'Order id', row: 0 },
94
- '_',
95
- { type: 'cell', column: 'Time', row: 0 },
96
- ],
97
- },
98
- timestamp: {
99
- type: 'cell',
100
- column: 'Time',
101
- row: 0,
102
- },
103
- comment: {
104
- type: 'join',
105
- values: [
106
- 'Trade Type: ',
107
- { type: 'cell', column: 'Trade Type', row: 0 },
108
- ' / Symbol: ',
109
- { type: 'cell', column: 'Symbol', row: 0 },
110
- ' / Action: ',
111
- { type: 'cell', column: 'Action', row: 0 },
112
- ],
113
- },
114
- transfers: [
115
- {
116
- target: [
117
- {
118
- column: 'PnL',
119
- pattern: { type: 'negative' },
120
- },
121
- ],
122
- direction: 'out',
123
- amount: {
124
- type: 'text',
125
- value: { type: 'cell', column: 'PnL', row: 0 },
126
- },
127
- asset: {
128
- type: 'symbol',
129
- value: { type: 'cell', column: 'Fee Unit', row: 0 },
130
- },
131
- },
132
- ],
133
- },
134
- {
135
- type: 'fee',
136
- source: {
137
- type: 'join',
138
- values: [
139
- { type: 'service' },
140
- '_trade_',
141
- { type: 'cell', column: 'Order id', row: 0 },
142
- '_',
143
- { type: 'cell', column: 'Time', row: 0 },
144
- ],
145
- },
146
- timestamp: {
147
- type: 'cell',
148
- column: 'Time',
149
- row: 0,
150
- },
151
- comment: {
152
- type: 'join',
153
- values: [
154
- 'Trade Type: ',
155
- { type: 'cell', column: 'Trade Type', row: 0 },
156
- ' / Symbol: ',
157
- { type: 'cell', column: 'Symbol', row: 0 },
158
- ' / Action: ',
159
- { type: 'cell', column: 'Action', row: 0 },
160
- ],
161
- },
162
- transfers: [
163
- {
164
- target: [
165
- {
166
- column: 'Fee',
167
- pattern: { type: 'negative' },
168
- },
169
- ],
170
- direction: 'out',
171
- amount: {
172
- type: 'text',
173
- value: { type: 'cell', column: 'Fee', row: 0 },
174
- },
175
- asset: {
176
- type: 'symbol',
177
- value: { type: 'cell', column: 'Fee Unit', row: 0 },
178
- },
179
- },
180
- ],
181
- },
182
- ],
183
- },
184
- {
185
- conditions: [
186
- {
187
- value: { type: 'cell', column: 'Trade Type', row: 0 },
188
- pattern: 'Swap',
189
- },
190
- {
191
- value: { type: 'cell', column: 'Action', row: 0 },
192
- pattern: {
193
- type: 'in',
194
- values: ['Manual margin increase', 'Manual margin decrease'],
195
- },
196
- },
197
- ],
198
- generators: [
199
- {
200
- type: 'ignore',
201
- source: {
202
- type: 'join',
203
- values: [
204
- { type: 'service' },
205
- '_trade_',
206
- { type: 'cell', column: 'Order id', row: 0 },
207
- '_',
208
- { type: 'cell', column: 'Time', row: 0 },
209
- ],
210
- },
211
- timestamp: {
212
- type: 'cell',
213
- column: 'Time',
214
- row: 0,
215
- },
216
- comment: {
217
- type: 'join',
218
- values: [
219
- 'Trade Type: ',
220
- { type: 'cell', column: 'Trade Type', row: 0 },
221
- ' / Action: ',
222
- { type: 'cell', column: 'Action', row: 0 },
223
- ' / Balance Change: ',
224
- { type: 'cell', column: 'Balance Change', row: 0 },
225
- { type: 'cell', column: 'Balance Unit', row: 0 },
226
- ],
227
- },
228
- transfers: [],
229
- },
230
- ],
231
- },
232
- {
233
- conditions: [
234
- {
235
- value: { type: 'cell', column: 'Trade Type', row: 0 },
236
- pattern: 'Transfer',
237
- },
238
- ],
239
- generators: [
240
- {
241
- type: 'ignore',
242
- source: {
243
- type: 'join',
244
- values: [
245
- { type: 'service' },
246
- '_trade_',
247
- { type: 'cell', column: 'Order id', row: 0 },
248
- '_',
249
- { type: 'cell', column: 'Time', row: 0 },
250
- ],
251
- },
252
- timestamp: {
253
- type: 'cell',
254
- column: 'Time',
255
- row: 0,
256
- },
257
- comment: {
258
- type: 'join',
259
- values: [
260
- 'Trade Type: ',
261
- { type: 'cell', column: 'Trade Type', row: 0 },
262
- ' / Action: ',
263
- { type: 'cell', column: 'Action', row: 0 },
264
- ' / Balance Change: ',
265
- { type: 'cell', column: 'Balance Change', row: 0 },
266
- { type: 'cell', column: 'Balance Unit', row: 0 },
267
- ],
268
- },
269
- transfers: [],
270
- },
271
- ],
272
- },
273
- ],
274
- },
275
- } satisfies CsvFormat