@0xtorch/csv 0.0.88 → 0.0.89
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.
- package/.DS_Store +0 -0
- package/_cjs/streamCsvToActions.js +29 -42
- package/_cjs/streamCsvToActions.js.map +1 -1
- package/_esm/streamCsvToActions.js +30 -43
- package/_esm/streamCsvToActions.js.map +1 -1
- package/_types/streamCsvToActions.d.ts.map +1 -1
- package/package.json +1 -1
- package/streamCsvToActions.ts +30 -45
- package/tests/okj-trade-202512.csv +5 -0
- package/tests/okj.ts +258 -0
package/.DS_Store
ADDED
|
Binary file
|
|
@@ -12,9 +12,8 @@ const streamCsvToActions = async ({ fileId, file, encoding, format, cryptoes, fi
|
|
|
12
12
|
let rowCount = 0;
|
|
13
13
|
let headerRow;
|
|
14
14
|
const ignoreRows = [];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let currentRawRows = [];
|
|
15
|
+
const rowsPerKey = {};
|
|
16
|
+
const rawRowsPerKey = {};
|
|
18
17
|
let actions = [];
|
|
19
18
|
const headerStartColumnRegExps = format.headerStartColumns === undefined
|
|
20
19
|
? undefined
|
|
@@ -103,8 +102,6 @@ const streamCsvToActions = async ({ fileId, file, encoding, format, cryptoes, fi
|
|
|
103
102
|
return;
|
|
104
103
|
}
|
|
105
104
|
if (format.parser.key === undefined) {
|
|
106
|
-
currentRawRows = [];
|
|
107
|
-
currentRows = [];
|
|
108
105
|
const rowActions = (0, parseRowsToActions_1.parseTargetRowsToActions)({
|
|
109
106
|
rows: [formattedRow],
|
|
110
107
|
parsers: format.parser.parsers,
|
|
@@ -128,29 +125,12 @@ const streamCsvToActions = async ({ fileId, file, encoding, format, cryptoes, fi
|
|
|
128
125
|
row: formattedRow,
|
|
129
126
|
key: format.parser.key,
|
|
130
127
|
});
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
symbolAssetMap: format.symbolAssetMap,
|
|
138
|
-
service: format.service,
|
|
139
|
-
fileId,
|
|
140
|
-
cryptoes,
|
|
141
|
-
fiats,
|
|
142
|
-
});
|
|
143
|
-
if (keyActions.length === 0) {
|
|
144
|
-
ignoreRows.push(...currentRawRows);
|
|
145
|
-
ignoreRowCount += currentRows.length;
|
|
146
|
-
}
|
|
147
|
-
actions.push(...keyActions);
|
|
148
|
-
currentRawRows = [];
|
|
149
|
-
currentRows = [];
|
|
150
|
-
}
|
|
151
|
-
currentKeyValue = keyValue;
|
|
152
|
-
currentRawRows.push(cells);
|
|
153
|
-
currentRows.push(formattedRow);
|
|
128
|
+
const rows = rowsPerKey[keyValue] ?? [];
|
|
129
|
+
rows.push(formattedRow);
|
|
130
|
+
rowsPerKey[keyValue] = rows;
|
|
131
|
+
const rawRows = rawRowsPerKey[keyValue] ?? [];
|
|
132
|
+
rawRows.push(cells);
|
|
133
|
+
rawRowsPerKey[keyValue] = rawRows;
|
|
154
134
|
}
|
|
155
135
|
if (actions.length >= chunkSize + 1) {
|
|
156
136
|
parser.pause();
|
|
@@ -189,21 +169,28 @@ const streamCsvToActions = async ({ fileId, file, encoding, format, cryptoes, fi
|
|
|
189
169
|
ignoreRows,
|
|
190
170
|
};
|
|
191
171
|
}
|
|
192
|
-
if (
|
|
193
|
-
const
|
|
194
|
-
rows
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
172
|
+
if (format.parser.key !== undefined) {
|
|
173
|
+
for (const keyValue of Object.keys(rowsPerKey)) {
|
|
174
|
+
const rows = rowsPerKey[keyValue] ?? [];
|
|
175
|
+
const rawRows = rawRowsPerKey[keyValue] ?? [];
|
|
176
|
+
if (rows.length === 0) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const keyActions = (0, parseRowsToActions_1.parseTargetRowsToActions)({
|
|
180
|
+
rows,
|
|
181
|
+
parsers: format.parser.parsers,
|
|
182
|
+
symbolAssetMap: format.symbolAssetMap,
|
|
183
|
+
service: format.service,
|
|
184
|
+
fileId,
|
|
185
|
+
cryptoes,
|
|
186
|
+
fiats,
|
|
187
|
+
});
|
|
188
|
+
if (keyActions.length === 0) {
|
|
189
|
+
ignoreRows.push(...rawRows);
|
|
190
|
+
ignoreRowCount += rows.length;
|
|
191
|
+
}
|
|
192
|
+
actions.push(...keyActions);
|
|
205
193
|
}
|
|
206
|
-
actions.push(...keyActions);
|
|
207
194
|
}
|
|
208
195
|
if (actions.length > 0) {
|
|
209
196
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamCsvToActions.js","sourceRoot":"","sources":["../streamCsvToActions.ts"],"names":[],"mappings":";;;AACA,yCAAiC;AACjC,mDAA8C;AAC9C,6DAA+D;AAC/D,kDAAyD;AAwBlD,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,SAAS,GAAG,GAAG,EACf,cAAc,GACe,EAA0C,EAAE;IAEzE,IAAI,OAAO,GAAG,IAAI,CAAA;IAClB,IAAI,KAAc,CAAA;IAClB,IAAI,cAAc,GAAG,CAAC,CAAA;IACtB,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,IAAI,SAA+B,CAAA;IACnC,MAAM,UAAU,GAAe,EAAE,CAAA;IACjC,
|
|
1
|
+
{"version":3,"file":"streamCsvToActions.js","sourceRoot":"","sources":["../streamCsvToActions.ts"],"names":[],"mappings":";;;AACA,yCAAiC;AACjC,mDAA8C;AAC9C,6DAA+D;AAC/D,kDAAyD;AAwBlD,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,SAAS,GAAG,GAAG,EACf,cAAc,GACe,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C;AACH,CAAC,CAAA"}
|
|
@@ -10,9 +10,8 @@ export const streamCsvToActions = async ({ fileId, file, encoding, format, crypt
|
|
|
10
10
|
let rowCount = 0;
|
|
11
11
|
let headerRow;
|
|
12
12
|
const ignoreRows = [];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let currentRawRows = [];
|
|
13
|
+
const rowsPerKey = {};
|
|
14
|
+
const rawRowsPerKey = {};
|
|
16
15
|
let actions = [];
|
|
17
16
|
const headerStartColumnRegExps = format.headerStartColumns === undefined
|
|
18
17
|
? undefined
|
|
@@ -105,8 +104,6 @@ export const streamCsvToActions = async ({ fileId, file, encoding, format, crypt
|
|
|
105
104
|
}
|
|
106
105
|
// parse
|
|
107
106
|
if (format.parser.key === undefined) {
|
|
108
|
-
currentRawRows = [];
|
|
109
|
-
currentRows = [];
|
|
110
107
|
const rowActions = parseTargetRowsToActions({
|
|
111
108
|
rows: [formattedRow],
|
|
112
109
|
parsers: format.parser.parsers,
|
|
@@ -130,29 +127,12 @@ export const streamCsvToActions = async ({ fileId, file, encoding, format, crypt
|
|
|
130
127
|
row: formattedRow,
|
|
131
128
|
key: format.parser.key,
|
|
132
129
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
symbolAssetMap: format.symbolAssetMap,
|
|
140
|
-
service: format.service,
|
|
141
|
-
fileId,
|
|
142
|
-
cryptoes,
|
|
143
|
-
fiats,
|
|
144
|
-
});
|
|
145
|
-
if (keyActions.length === 0) {
|
|
146
|
-
ignoreRows.push(...currentRawRows);
|
|
147
|
-
ignoreRowCount += currentRows.length;
|
|
148
|
-
}
|
|
149
|
-
actions.push(...keyActions);
|
|
150
|
-
currentRawRows = [];
|
|
151
|
-
currentRows = [];
|
|
152
|
-
}
|
|
153
|
-
currentKeyValue = keyValue;
|
|
154
|
-
currentRawRows.push(cells);
|
|
155
|
-
currentRows.push(formattedRow);
|
|
130
|
+
const rows = rowsPerKey[keyValue] ?? [];
|
|
131
|
+
rows.push(formattedRow);
|
|
132
|
+
rowsPerKey[keyValue] = rows;
|
|
133
|
+
const rawRows = rawRowsPerKey[keyValue] ?? [];
|
|
134
|
+
rawRows.push(cells);
|
|
135
|
+
rawRowsPerKey[keyValue] = rawRows;
|
|
156
136
|
}
|
|
157
137
|
// actions が chunkSize に達したら最後の action source と同一 source を除いて actions を保存
|
|
158
138
|
if (actions.length >= chunkSize + 1) {
|
|
@@ -192,22 +172,29 @@ export const streamCsvToActions = async ({ fileId, file, encoding, format, crypt
|
|
|
192
172
|
ignoreRows,
|
|
193
173
|
};
|
|
194
174
|
}
|
|
195
|
-
//
|
|
196
|
-
if (
|
|
197
|
-
const
|
|
198
|
-
rows
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
175
|
+
// format.parser.key がある場合、 key ごとに actions に変換して追加
|
|
176
|
+
if (format.parser.key !== undefined) {
|
|
177
|
+
for (const keyValue of Object.keys(rowsPerKey)) {
|
|
178
|
+
const rows = rowsPerKey[keyValue] ?? [];
|
|
179
|
+
const rawRows = rawRowsPerKey[keyValue] ?? [];
|
|
180
|
+
if (rows.length === 0) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const keyActions = parseTargetRowsToActions({
|
|
184
|
+
rows,
|
|
185
|
+
parsers: format.parser.parsers,
|
|
186
|
+
symbolAssetMap: format.symbolAssetMap,
|
|
187
|
+
service: format.service,
|
|
188
|
+
fileId,
|
|
189
|
+
cryptoes,
|
|
190
|
+
fiats,
|
|
191
|
+
});
|
|
192
|
+
if (keyActions.length === 0) {
|
|
193
|
+
ignoreRows.push(...rawRows);
|
|
194
|
+
ignoreRowCount += rows.length;
|
|
195
|
+
}
|
|
196
|
+
actions.push(...keyActions);
|
|
209
197
|
}
|
|
210
|
-
actions.push(...keyActions);
|
|
211
198
|
}
|
|
212
199
|
// actions が残っていたら actions 保存処理
|
|
213
200
|
if (actions.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamCsvToActions.js","sourceRoot":"","sources":["../streamCsvToActions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAwBzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,SAAS,GAAG,GAAG,EACf,cAAc,GACe,EAA0C,EAAE;IACzE,aAAa;IACb,IAAI,OAAO,GAAG,IAAI,CAAA;IAClB,IAAI,KAAc,CAAA;IAClB,IAAI,cAAc,GAAG,CAAC,CAAA;IACtB,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,IAAI,SAA+B,CAAA;IACnC,MAAM,UAAU,GAAe,EAAE,CAAA;IACjC,
|
|
1
|
+
{"version":3,"file":"streamCsvToActions.js","sourceRoot":"","sources":["../streamCsvToActions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAwBzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,SAAS,GAAG,GAAG,EACf,cAAc,GACe,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E,CAAC;QACf,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamCsvToActions.d.ts","sourceRoot":"","sources":["../streamCsvToActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAKzE,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAA;AAEtD,KAAK,4BAA4B,GAAG;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,IAAI,GAAG,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,SAAS,CAAA;IACjB,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAA;IACnC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAA;IAC9B,IAAI,EAAE,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACxC,CAAA;AAED,KAAK,6BAA6B,GAAG;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,UAAU,EAAE,MAAM,EAAE,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAU,uFAUtC,4BAA4B,KAAG,OAAO,CAAC,6BAA6B,
|
|
1
|
+
{"version":3,"file":"streamCsvToActions.d.ts","sourceRoot":"","sources":["../streamCsvToActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAKzE,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAA;AAEtD,KAAK,4BAA4B,GAAG;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,IAAI,GAAG,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,SAAS,CAAA;IACjB,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAA;IACnC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAA;IAC9B,IAAI,EAAE,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACxC,CAAA;AAED,KAAK,6BAA6B,GAAG;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,UAAU,EAAE,MAAM,EAAE,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAU,uFAUtC,4BAA4B,KAAG,OAAO,CAAC,6BAA6B,CAiOtE,CAAA"}
|
package/package.json
CHANGED
package/streamCsvToActions.ts
CHANGED
|
@@ -44,9 +44,8 @@ export const streamCsvToActions = async ({
|
|
|
44
44
|
let rowCount = 0
|
|
45
45
|
let headerRow: string[] | undefined
|
|
46
46
|
const ignoreRows: string[][] = []
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
let currentRawRows: string[][] = []
|
|
47
|
+
const rowsPerKey: Record<string, FormattedRow[] | undefined> = {}
|
|
48
|
+
const rawRowsPerKey: Record<string, string[][] | undefined> = {}
|
|
50
49
|
let actions: Action[] = []
|
|
51
50
|
|
|
52
51
|
const headerStartColumnRegExps =
|
|
@@ -151,8 +150,6 @@ export const streamCsvToActions = async ({
|
|
|
151
150
|
|
|
152
151
|
// parse
|
|
153
152
|
if (format.parser.key === undefined) {
|
|
154
|
-
currentRawRows = []
|
|
155
|
-
currentRows = []
|
|
156
153
|
const rowActions = parseTargetRowsToActions({
|
|
157
154
|
rows: [formattedRow],
|
|
158
155
|
parsers: format.parser.parsers,
|
|
@@ -175,31 +172,12 @@ export const streamCsvToActions = async ({
|
|
|
175
172
|
row: formattedRow,
|
|
176
173
|
key: format.parser.key,
|
|
177
174
|
})
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
rows: currentRows,
|
|
185
|
-
parsers: format.parser.parsers,
|
|
186
|
-
symbolAssetMap: format.symbolAssetMap,
|
|
187
|
-
service: format.service,
|
|
188
|
-
fileId,
|
|
189
|
-
cryptoes,
|
|
190
|
-
fiats,
|
|
191
|
-
})
|
|
192
|
-
if (keyActions.length === 0) {
|
|
193
|
-
ignoreRows.push(...currentRawRows)
|
|
194
|
-
ignoreRowCount += currentRows.length
|
|
195
|
-
}
|
|
196
|
-
actions.push(...keyActions)
|
|
197
|
-
currentRawRows = []
|
|
198
|
-
currentRows = []
|
|
199
|
-
}
|
|
200
|
-
currentKeyValue = keyValue
|
|
201
|
-
currentRawRows.push(cells)
|
|
202
|
-
currentRows.push(formattedRow)
|
|
175
|
+
const rows = rowsPerKey[keyValue] ?? []
|
|
176
|
+
rows.push(formattedRow)
|
|
177
|
+
rowsPerKey[keyValue] = rows
|
|
178
|
+
const rawRows = rawRowsPerKey[keyValue] ?? []
|
|
179
|
+
rawRows.push(cells)
|
|
180
|
+
rawRowsPerKey[keyValue] = rawRows
|
|
203
181
|
}
|
|
204
182
|
|
|
205
183
|
// actions が chunkSize に達したら最後の action source と同一 source を除いて actions を保存
|
|
@@ -240,22 +218,29 @@ export const streamCsvToActions = async ({
|
|
|
240
218
|
}
|
|
241
219
|
}
|
|
242
220
|
|
|
243
|
-
//
|
|
244
|
-
if (
|
|
245
|
-
const
|
|
246
|
-
rows
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
221
|
+
// format.parser.key がある場合、 key ごとに actions に変換して追加
|
|
222
|
+
if (format.parser.key !== undefined) {
|
|
223
|
+
for (const keyValue of Object.keys(rowsPerKey)) {
|
|
224
|
+
const rows = rowsPerKey[keyValue] ?? []
|
|
225
|
+
const rawRows = rawRowsPerKey[keyValue] ?? []
|
|
226
|
+
if (rows.length === 0) {
|
|
227
|
+
continue
|
|
228
|
+
}
|
|
229
|
+
const keyActions = parseTargetRowsToActions({
|
|
230
|
+
rows,
|
|
231
|
+
parsers: format.parser.parsers,
|
|
232
|
+
symbolAssetMap: format.symbolAssetMap,
|
|
233
|
+
service: format.service,
|
|
234
|
+
fileId,
|
|
235
|
+
cryptoes,
|
|
236
|
+
fiats,
|
|
237
|
+
})
|
|
238
|
+
if (keyActions.length === 0) {
|
|
239
|
+
ignoreRows.push(...rawRows)
|
|
240
|
+
ignoreRowCount += rows.length
|
|
241
|
+
}
|
|
242
|
+
actions.push(...keyActions)
|
|
257
243
|
}
|
|
258
|
-
actions.push(...keyActions)
|
|
259
244
|
}
|
|
260
245
|
|
|
261
246
|
// actions が残っていたら actions 保存処理
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
約定id,注文id,日時,取引銘柄,通貨,取引内容,約定数量,約定価格,残高,m/t,手数料
|
|
2
|
+
856768422926094342,15453749887177731,2025/06/22 06:31:50,BTC/JPY,BTC,購入, 0.00076302," 14,860,508.00000000", 0.00754770,taker,-0.0000010682280000
|
|
3
|
+
857232780667916289,15461005473420288,2025/06/23 13:17:02,BTC/JPY,BTC,売却, -0.00019730," 14,898,258.00000000", 0.00715242,taker,0.0000000000000000
|
|
4
|
+
856768422926094343,15453749887177731,2025/06/22 06:31:50,BTC/JPY,JPY,売却," -11,338.86481416",1.00000000," 175,258.16151939",taker,0.0000000000000000
|
|
5
|
+
857232780667916288,15461005473420288,2025/06/23 13:17:02,BTC/JPY,JPY,購入," 2,939.42630340",1.00000000," 144,026.11388321",taker,-3.5273115640800000
|
package/tests/okj.ts
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import type { CsvFormat } from '../_types'
|
|
2
|
+
|
|
3
|
+
export const okjFormat = {
|
|
4
|
+
id: 'okj-trade-202512',
|
|
5
|
+
service: 'okj',
|
|
6
|
+
formatter: {
|
|
7
|
+
注文id: ['string'],
|
|
8
|
+
日時: ['datetime-jp'],
|
|
9
|
+
通貨: ['string'],
|
|
10
|
+
取引内容: ['string'],
|
|
11
|
+
約定数量: ['big-decimal'],
|
|
12
|
+
手数料: ['big-decimal'],
|
|
13
|
+
},
|
|
14
|
+
parser: {
|
|
15
|
+
key: ['注文id'],
|
|
16
|
+
parsers: [
|
|
17
|
+
{
|
|
18
|
+
conditions: [
|
|
19
|
+
{
|
|
20
|
+
value: {
|
|
21
|
+
type: 'cell',
|
|
22
|
+
column: '取引内容',
|
|
23
|
+
row: 0,
|
|
24
|
+
},
|
|
25
|
+
pattern: {
|
|
26
|
+
type: 'in',
|
|
27
|
+
values: ['購入', '売却'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
generators: [
|
|
32
|
+
{
|
|
33
|
+
type: 'trade',
|
|
34
|
+
source: {
|
|
35
|
+
type: 'join',
|
|
36
|
+
values: [
|
|
37
|
+
{ type: 'service' },
|
|
38
|
+
'_trade_',
|
|
39
|
+
{
|
|
40
|
+
type: 'cell',
|
|
41
|
+
column: '注文id',
|
|
42
|
+
row: 0,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
timestamp: {
|
|
47
|
+
type: 'cell',
|
|
48
|
+
column: '日時',
|
|
49
|
+
row: 0,
|
|
50
|
+
},
|
|
51
|
+
transfers: [
|
|
52
|
+
{
|
|
53
|
+
target: [
|
|
54
|
+
{
|
|
55
|
+
column: '約定数量',
|
|
56
|
+
pattern: {
|
|
57
|
+
type: 'positive',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
direction: 'in',
|
|
62
|
+
amount: {
|
|
63
|
+
type: 'text',
|
|
64
|
+
value: {
|
|
65
|
+
type: 'cell',
|
|
66
|
+
column: '約定数量',
|
|
67
|
+
row: 0,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
asset: {
|
|
71
|
+
type: 'symbol',
|
|
72
|
+
value: {
|
|
73
|
+
type: 'cell',
|
|
74
|
+
column: '通貨',
|
|
75
|
+
row: 0,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
target: [
|
|
81
|
+
{
|
|
82
|
+
column: '手数料',
|
|
83
|
+
pattern: {
|
|
84
|
+
type: 'positive',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
direction: 'in',
|
|
89
|
+
amount: {
|
|
90
|
+
type: 'text',
|
|
91
|
+
value: {
|
|
92
|
+
type: 'cell',
|
|
93
|
+
column: '手数料',
|
|
94
|
+
row: 0,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
asset: {
|
|
98
|
+
type: 'symbol',
|
|
99
|
+
value: {
|
|
100
|
+
type: 'cell',
|
|
101
|
+
column: '通貨',
|
|
102
|
+
row: 0,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
target: [
|
|
108
|
+
{
|
|
109
|
+
column: '約定数量',
|
|
110
|
+
pattern: {
|
|
111
|
+
type: 'negative',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
direction: 'out',
|
|
116
|
+
amount: {
|
|
117
|
+
type: 'text',
|
|
118
|
+
value: {
|
|
119
|
+
type: 'cell',
|
|
120
|
+
column: '約定数量',
|
|
121
|
+
row: 0,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
asset: {
|
|
125
|
+
type: 'symbol',
|
|
126
|
+
value: {
|
|
127
|
+
type: 'cell',
|
|
128
|
+
column: '通貨',
|
|
129
|
+
row: 0,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
target: [
|
|
135
|
+
{
|
|
136
|
+
column: '手数料',
|
|
137
|
+
pattern: {
|
|
138
|
+
type: 'negative',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
direction: 'out',
|
|
143
|
+
amount: {
|
|
144
|
+
type: 'text',
|
|
145
|
+
value: {
|
|
146
|
+
type: 'cell',
|
|
147
|
+
column: '手数料',
|
|
148
|
+
row: 0,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
asset: {
|
|
152
|
+
type: 'symbol',
|
|
153
|
+
value: {
|
|
154
|
+
type: 'cell',
|
|
155
|
+
column: '通貨',
|
|
156
|
+
row: 0,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
conditions: [
|
|
166
|
+
{
|
|
167
|
+
value: {
|
|
168
|
+
type: 'cell',
|
|
169
|
+
column: '取引内容',
|
|
170
|
+
row: 0,
|
|
171
|
+
},
|
|
172
|
+
pattern: {
|
|
173
|
+
type: 'in',
|
|
174
|
+
values: ['入出金口座から振替', '入出金口座に振替'],
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
generators: [
|
|
179
|
+
{
|
|
180
|
+
type: 'ignore',
|
|
181
|
+
source: {
|
|
182
|
+
type: 'join',
|
|
183
|
+
values: [
|
|
184
|
+
{ type: 'service' },
|
|
185
|
+
'_trade_',
|
|
186
|
+
{
|
|
187
|
+
type: 'cell',
|
|
188
|
+
column: '注文id',
|
|
189
|
+
row: 0,
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
timestamp: {
|
|
194
|
+
type: 'cell',
|
|
195
|
+
column: '日時',
|
|
196
|
+
row: 0,
|
|
197
|
+
},
|
|
198
|
+
comment: {
|
|
199
|
+
type: 'join',
|
|
200
|
+
values: [
|
|
201
|
+
{ type: 'cell', column: '取引内容', row: 0 },
|
|
202
|
+
': ',
|
|
203
|
+
{ type: 'cell', column: '約定数量', row: 0 },
|
|
204
|
+
{ type: 'cell', column: '通貨', row: 0 },
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
transfers: [],
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
symbolAssetMap: {
|
|
214
|
+
BTC: 'crypto/bitcoin',
|
|
215
|
+
ETH: 'crypto/ethereum',
|
|
216
|
+
ADA: 'crypto/cardano',
|
|
217
|
+
APE: 'crypto/apecoin',
|
|
218
|
+
APT: 'crypto/aptos',
|
|
219
|
+
ARB: 'crypto/arbitrum',
|
|
220
|
+
ASTR: 'crypto/astar',
|
|
221
|
+
AVAX: 'crypto/avalanche-2',
|
|
222
|
+
BAT: 'crypto/basic-attention-token',
|
|
223
|
+
BCH: 'crypto/bitcoin-cash',
|
|
224
|
+
DAI: 'crypto/dai',
|
|
225
|
+
DEP: 'crypto/deapcoin',
|
|
226
|
+
DOGE: 'crypto/dogecoin',
|
|
227
|
+
DOT: 'crypto/polkadot',
|
|
228
|
+
ENJ: 'crypto/enjincoin',
|
|
229
|
+
ETC: 'crypto/ethereum-classic',
|
|
230
|
+
FIL: 'crypto/filecoin',
|
|
231
|
+
FNCT: 'crypto/financie-token',
|
|
232
|
+
IOST: 'crypto/iostoken',
|
|
233
|
+
IOTX: 'crypto/iotex',
|
|
234
|
+
KAIA: 'crypto/kaia',
|
|
235
|
+
LSK: 'crypto/lisk',
|
|
236
|
+
LTC: 'crypto/litecoin',
|
|
237
|
+
MASK: 'crypto/mask-network',
|
|
238
|
+
MKR: 'crypto/maker',
|
|
239
|
+
NEO: 'crypto/neo',
|
|
240
|
+
OAS: 'crypto/oasys',
|
|
241
|
+
OP: 'crypto/optimism',
|
|
242
|
+
OKB: 'crypto/okb',
|
|
243
|
+
PEPE: 'crypto/pepe',
|
|
244
|
+
PLT: 'crypto/palette',
|
|
245
|
+
POL: 'crypto/polygon-ecosystem-token',
|
|
246
|
+
QTUM: 'crypto/qtum',
|
|
247
|
+
SAND: 'crypto/the-sandbox',
|
|
248
|
+
SHIB: 'crypto/shiba-inu',
|
|
249
|
+
SOL: 'crypto/solana',
|
|
250
|
+
SUI: 'crypto/sui',
|
|
251
|
+
TON: 'crypto/the-open-network',
|
|
252
|
+
TRX: 'crypto/tron',
|
|
253
|
+
XLM: 'crypto/stellar',
|
|
254
|
+
XRP: 'crypto/ripple',
|
|
255
|
+
XTZ: 'crypto/tezos',
|
|
256
|
+
ZIL: 'crypto/zilliqa',
|
|
257
|
+
},
|
|
258
|
+
} satisfies CsvFormat
|