@kodiak-finance/orderly-utils 2.8.30-alpha.0 → 2.8.30
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/dist/index.d.mts +42 -1
- package/dist/index.d.ts +42 -1
- package/dist/index.js +491 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +478 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -149,4 +149,45 @@ type FormatNumWithNamespace = typeof formatNum & {
|
|
|
149
149
|
};
|
|
150
150
|
declare const formatNumWithNamespace: FormatNumWithNamespace;
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
/**
|
|
153
|
+
* CSV Export Service
|
|
154
|
+
* Handles CSV generation for positions, position history, and liquidations with proper formatting and column mapping.
|
|
155
|
+
* Shared by trading and portfolio packages.
|
|
156
|
+
*/
|
|
157
|
+
interface CSVColumnConfig {
|
|
158
|
+
key: string;
|
|
159
|
+
title: string;
|
|
160
|
+
formatter?: (value: any) => string | number;
|
|
161
|
+
}
|
|
162
|
+
interface ExportOptions {
|
|
163
|
+
filename: string;
|
|
164
|
+
columns: CSVColumnConfig[];
|
|
165
|
+
data: any[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Convert data to CSV format
|
|
169
|
+
*/
|
|
170
|
+
declare const generateCSV: (options: ExportOptions) => string;
|
|
171
|
+
/**
|
|
172
|
+
* Trigger browser download
|
|
173
|
+
*/
|
|
174
|
+
declare const downloadCSV: (csv: string, filename: string) => void;
|
|
175
|
+
/**
|
|
176
|
+
* Format timestamp to readable date
|
|
177
|
+
*/
|
|
178
|
+
declare const formatTimestamp: (timestamp: number | string) => string;
|
|
179
|
+
/**
|
|
180
|
+
* Format number with decimal precision
|
|
181
|
+
*/
|
|
182
|
+
declare const formatNumber: (value: any, decimals?: number) => string;
|
|
183
|
+
/**
|
|
184
|
+
* Format percentage
|
|
185
|
+
*/
|
|
186
|
+
declare const formatPercent: (value: any, decimals?: number) => string;
|
|
187
|
+
declare const getPositionExportColumns: () => CSVColumnConfig[];
|
|
188
|
+
declare const getOrderExportColumns: (tabType: string) => CSVColumnConfig[];
|
|
189
|
+
declare const getPositionHistoryExportColumns: () => CSVColumnConfig[];
|
|
190
|
+
declare const getLiquidationExportColumns: () => CSVColumnConfig[];
|
|
191
|
+
declare const exportToCSVFile: (options: ExportOptions) => void;
|
|
192
|
+
|
|
193
|
+
export { type ExportOptions, camelCaseToUnderscoreCase, capitalizeString, checkIsNaN, commify, commifyOptional, cutNumber, downloadCSV, exportToCSVFile, findLongestCommonSubString, formatNumWithNamespace as formatNum, formatNumber, formatPercent, formatSymbol, formatTimestamp, generateCSV, getBBOType, getGlobalObject, getLiquidationExportColumns, getOrderExportColumns, getPositionExportColumns, getPositionHistoryExportColumns, getPrecisionByNumber, getTPSLDirection, getTimestamp, getTrailingStopPrice, hex2int, int2hex, isSolana, isTestnet, numberToHumanStyle, optimizeSymbolDisplay, parseChainIdToNumber, parseNumStr, praseChainId, praseChainIdToNumber, removeTrailingZeros, subtractDaysFromCurrentDate, timeConvertString, timestampToString, toNonExponential, todpIfNeed, transSymbolformString, windowGuard, zero };
|
package/dist/index.d.ts
CHANGED
|
@@ -149,4 +149,45 @@ type FormatNumWithNamespace = typeof formatNum & {
|
|
|
149
149
|
};
|
|
150
150
|
declare const formatNumWithNamespace: FormatNumWithNamespace;
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
/**
|
|
153
|
+
* CSV Export Service
|
|
154
|
+
* Handles CSV generation for positions, position history, and liquidations with proper formatting and column mapping.
|
|
155
|
+
* Shared by trading and portfolio packages.
|
|
156
|
+
*/
|
|
157
|
+
interface CSVColumnConfig {
|
|
158
|
+
key: string;
|
|
159
|
+
title: string;
|
|
160
|
+
formatter?: (value: any) => string | number;
|
|
161
|
+
}
|
|
162
|
+
interface ExportOptions {
|
|
163
|
+
filename: string;
|
|
164
|
+
columns: CSVColumnConfig[];
|
|
165
|
+
data: any[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Convert data to CSV format
|
|
169
|
+
*/
|
|
170
|
+
declare const generateCSV: (options: ExportOptions) => string;
|
|
171
|
+
/**
|
|
172
|
+
* Trigger browser download
|
|
173
|
+
*/
|
|
174
|
+
declare const downloadCSV: (csv: string, filename: string) => void;
|
|
175
|
+
/**
|
|
176
|
+
* Format timestamp to readable date
|
|
177
|
+
*/
|
|
178
|
+
declare const formatTimestamp: (timestamp: number | string) => string;
|
|
179
|
+
/**
|
|
180
|
+
* Format number with decimal precision
|
|
181
|
+
*/
|
|
182
|
+
declare const formatNumber: (value: any, decimals?: number) => string;
|
|
183
|
+
/**
|
|
184
|
+
* Format percentage
|
|
185
|
+
*/
|
|
186
|
+
declare const formatPercent: (value: any, decimals?: number) => string;
|
|
187
|
+
declare const getPositionExportColumns: () => CSVColumnConfig[];
|
|
188
|
+
declare const getOrderExportColumns: (tabType: string) => CSVColumnConfig[];
|
|
189
|
+
declare const getPositionHistoryExportColumns: () => CSVColumnConfig[];
|
|
190
|
+
declare const getLiquidationExportColumns: () => CSVColumnConfig[];
|
|
191
|
+
declare const exportToCSVFile: (options: ExportOptions) => void;
|
|
192
|
+
|
|
193
|
+
export { type ExportOptions, camelCaseToUnderscoreCase, capitalizeString, checkIsNaN, commify, commifyOptional, cutNumber, downloadCSV, exportToCSVFile, findLongestCommonSubString, formatNumWithNamespace as formatNum, formatNumber, formatPercent, formatSymbol, formatTimestamp, generateCSV, getBBOType, getGlobalObject, getLiquidationExportColumns, getOrderExportColumns, getPositionExportColumns, getPositionHistoryExportColumns, getPrecisionByNumber, getTPSLDirection, getTimestamp, getTrailingStopPrice, hex2int, int2hex, isSolana, isTestnet, numberToHumanStyle, optimizeSymbolDisplay, parseChainIdToNumber, parseNumStr, praseChainId, praseChainIdToNumber, removeTrailingZeros, subtractDaysFromCurrentDate, timeConvertString, timestampToString, toNonExponential, todpIfNeed, transSymbolformString, windowGuard, zero };
|
package/dist/index.js
CHANGED
|
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
33
|
Decimal: () => decimal_default,
|
|
34
34
|
camelCaseToUnderscoreCase: () => camelCaseToUnderscoreCase,
|
|
35
35
|
capitalizeString: () => capitalizeString,
|
|
@@ -38,11 +38,21 @@ __export(src_exports, {
|
|
|
38
38
|
commifyOptional: () => commifyOptional,
|
|
39
39
|
cutNumber: () => cutNumber,
|
|
40
40
|
dayjs: () => import_dayjs.default,
|
|
41
|
+
downloadCSV: () => downloadCSV,
|
|
42
|
+
exportToCSVFile: () => exportToCSVFile,
|
|
41
43
|
findLongestCommonSubString: () => findLongestCommonSubString,
|
|
42
44
|
formatNum: () => formatNumWithNamespace,
|
|
45
|
+
formatNumber: () => formatNumber,
|
|
46
|
+
formatPercent: () => formatPercent,
|
|
43
47
|
formatSymbol: () => formatSymbol,
|
|
48
|
+
formatTimestamp: () => formatTimestamp,
|
|
49
|
+
generateCSV: () => generateCSV,
|
|
44
50
|
getBBOType: () => getBBOType,
|
|
45
51
|
getGlobalObject: () => getGlobalObject,
|
|
52
|
+
getLiquidationExportColumns: () => getLiquidationExportColumns,
|
|
53
|
+
getOrderExportColumns: () => getOrderExportColumns,
|
|
54
|
+
getPositionExportColumns: () => getPositionExportColumns,
|
|
55
|
+
getPositionHistoryExportColumns: () => getPositionHistoryExportColumns,
|
|
46
56
|
getPrecisionByNumber: () => getPrecisionByNumber,
|
|
47
57
|
getTPSLDirection: () => getTPSLDirection,
|
|
48
58
|
getTimestamp: () => getTimestamp,
|
|
@@ -67,7 +77,7 @@ __export(src_exports, {
|
|
|
67
77
|
windowGuard: () => windowGuard,
|
|
68
78
|
zero: () => zero
|
|
69
79
|
});
|
|
70
|
-
module.exports = __toCommonJS(
|
|
80
|
+
module.exports = __toCommonJS(index_exports);
|
|
71
81
|
|
|
72
82
|
// src/decimal.ts
|
|
73
83
|
var import_decimal = __toESM(require("decimal.js-light"));
|
|
@@ -233,8 +243,7 @@ var import_orderly_types = require("@kodiak-finance/orderly-types");
|
|
|
233
243
|
var hex2int = (chainId) => parseInt(chainId);
|
|
234
244
|
var int2hex = (chainId) => `0x${chainId.toString(16)}`;
|
|
235
245
|
var praseChainId = (chainId) => {
|
|
236
|
-
if (typeof chainId === "string")
|
|
237
|
-
return hex2int(chainId);
|
|
246
|
+
if (typeof chainId === "string") return hex2int(chainId);
|
|
238
247
|
return chainId;
|
|
239
248
|
};
|
|
240
249
|
var praseChainIdToNumber = (chainId) => {
|
|
@@ -472,6 +481,473 @@ formatNumWithNamespace.assetValue = (num) => {
|
|
|
472
481
|
formatNumWithNamespace.collateral = (num) => {
|
|
473
482
|
return formatNum(4 /* collateral */, 2, num);
|
|
474
483
|
};
|
|
484
|
+
|
|
485
|
+
// src/csvExport.ts
|
|
486
|
+
var generateCSV = (options) => {
|
|
487
|
+
const { columns, data } = options;
|
|
488
|
+
const headers = columns.map((col) => `"${col.title}"`).join(",");
|
|
489
|
+
const rows = data.map((row) => {
|
|
490
|
+
return columns.map((col) => {
|
|
491
|
+
let value = row[col.key];
|
|
492
|
+
if (col.formatter) {
|
|
493
|
+
value = col.formatter(value);
|
|
494
|
+
}
|
|
495
|
+
const stringValue = String(value != null ? value : "");
|
|
496
|
+
const escapedValue = stringValue.replace(/"/g, '""');
|
|
497
|
+
return `"${escapedValue}"`;
|
|
498
|
+
}).join(",");
|
|
499
|
+
});
|
|
500
|
+
return [headers, ...rows].join("\n");
|
|
501
|
+
};
|
|
502
|
+
var downloadCSV = (csv, filename) => {
|
|
503
|
+
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
|
504
|
+
const link = document.createElement("a");
|
|
505
|
+
const url = URL.createObjectURL(blob);
|
|
506
|
+
link.setAttribute("href", url);
|
|
507
|
+
link.setAttribute("download", `${filename}.csv`);
|
|
508
|
+
link.style.visibility = "hidden";
|
|
509
|
+
document.body.appendChild(link);
|
|
510
|
+
link.click();
|
|
511
|
+
document.body.removeChild(link);
|
|
512
|
+
};
|
|
513
|
+
var formatTimestamp = (timestamp) => {
|
|
514
|
+
if (!timestamp) return "--";
|
|
515
|
+
const numTimestamp = Number(timestamp);
|
|
516
|
+
const date = new Date(
|
|
517
|
+
numTimestamp > 1e10 ? numTimestamp : numTimestamp * 1e3
|
|
518
|
+
);
|
|
519
|
+
return date.toISOString().split("T")[0] + " " + date.toTimeString().slice(0, 8);
|
|
520
|
+
};
|
|
521
|
+
var formatNumber = (value, decimals = 2) => {
|
|
522
|
+
if (value === null || value === void 0) return "--";
|
|
523
|
+
const num = Number(value);
|
|
524
|
+
if (isNaN(num)) return "--";
|
|
525
|
+
return num.toFixed(decimals);
|
|
526
|
+
};
|
|
527
|
+
var formatPercent = (value, decimals = 2) => {
|
|
528
|
+
if (value === null || value === void 0) return "--";
|
|
529
|
+
const num = Number(value);
|
|
530
|
+
if (isNaN(num)) return "--";
|
|
531
|
+
return (num * 100).toFixed(decimals) + "%";
|
|
532
|
+
};
|
|
533
|
+
var getPositionExportColumns = () => [
|
|
534
|
+
{ key: "symbol", title: "Symbol" },
|
|
535
|
+
{
|
|
536
|
+
key: "position_qty",
|
|
537
|
+
title: "Position Qty",
|
|
538
|
+
formatter: (v) => formatNumber(v, 4)
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
key: "average_open_price",
|
|
542
|
+
title: "Avg Open Price",
|
|
543
|
+
formatter: (v) => formatNumber(v, 4)
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
key: "mark_price",
|
|
547
|
+
title: "Mark Price",
|
|
548
|
+
formatter: (v) => formatNumber(v, 4)
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
key: "settle_price",
|
|
552
|
+
title: "Settle Price",
|
|
553
|
+
formatter: (v) => formatNumber(v, 4)
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
key: "est_liq_price",
|
|
557
|
+
title: "Est. Liquidation Price",
|
|
558
|
+
formatter: (v) => v === null ? "--" : formatNumber(v, 4)
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
key: "cost_position",
|
|
562
|
+
title: "Cost Position",
|
|
563
|
+
formatter: (v) => formatNumber(v, 2)
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
key: "unsettled_pnl",
|
|
567
|
+
title: "Unsettled PnL",
|
|
568
|
+
formatter: (v) => formatNumber(v, 2)
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
key: "pnl_24_h",
|
|
572
|
+
title: "PnL 24h",
|
|
573
|
+
formatter: (v) => formatNumber(v, 2)
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
key: "leverage",
|
|
577
|
+
title: "Leverage",
|
|
578
|
+
formatter: (v) => formatNumber(v, 2)
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
key: "imr",
|
|
582
|
+
title: "Initial Margin Ratio",
|
|
583
|
+
formatter: (v) => formatPercent(v, 4)
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
key: "mmr",
|
|
587
|
+
title: "Maintenance Margin Ratio",
|
|
588
|
+
formatter: (v) => formatPercent(v, 4)
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
key: "IMR_withdraw_orders",
|
|
592
|
+
title: "IMR with Withdraw Orders",
|
|
593
|
+
formatter: (v) => formatPercent(v, 4)
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
key: "MMR_with_orders",
|
|
597
|
+
title: "MMR with Orders",
|
|
598
|
+
formatter: (v) => formatPercent(v, 4)
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
key: "pending_long_qty",
|
|
602
|
+
title: "Pending Long Qty",
|
|
603
|
+
formatter: (v) => formatNumber(v, 4)
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
key: "pending_short_qty",
|
|
607
|
+
title: "Pending Short Qty",
|
|
608
|
+
formatter: (v) => formatNumber(v, 4)
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
key: "last_sum_unitary_funding",
|
|
612
|
+
title: "Last Sum Unitary Funding",
|
|
613
|
+
formatter: (v) => formatNumber(v, 4)
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
key: "fee_24_h",
|
|
617
|
+
title: "Fee 24h",
|
|
618
|
+
formatter: (v) => formatNumber(v, 8)
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
key: "seq",
|
|
622
|
+
title: "Sequence"
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
key: "timestamp",
|
|
626
|
+
title: "Timestamp",
|
|
627
|
+
formatter: formatTimestamp
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
key: "updated_time",
|
|
631
|
+
title: "Updated Time",
|
|
632
|
+
formatter: formatTimestamp
|
|
633
|
+
}
|
|
634
|
+
];
|
|
635
|
+
var getOrderExportColumns = (tabType) => {
|
|
636
|
+
if (tabType === "orderHistory") {
|
|
637
|
+
return [
|
|
638
|
+
{
|
|
639
|
+
key: "order_id",
|
|
640
|
+
title: "Order ID"
|
|
641
|
+
},
|
|
642
|
+
{ key: "symbol", title: "Symbol" },
|
|
643
|
+
{ key: "side", title: "Side" },
|
|
644
|
+
{ key: "type", title: "Order Type" },
|
|
645
|
+
{ key: "status", title: "Status" },
|
|
646
|
+
{
|
|
647
|
+
key: "quantity",
|
|
648
|
+
title: "Quantity",
|
|
649
|
+
formatter: (v) => formatNumber(v, 4)
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
key: "visible_quantity",
|
|
653
|
+
title: "Visible Quantity",
|
|
654
|
+
formatter: (v) => formatNumber(v, 4)
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
key: "total_executed_quantity",
|
|
658
|
+
title: "Total Executed Qty",
|
|
659
|
+
formatter: (v) => formatNumber(v, 4)
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
key: "average_executed_price",
|
|
663
|
+
title: "Avg Executed Price",
|
|
664
|
+
formatter: (v) => v === null ? "--" : formatNumber(v, 4)
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
key: "total_fee",
|
|
668
|
+
title: "Fee",
|
|
669
|
+
formatter: (v) => formatNumber(v, 8)
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
key: "fee_asset",
|
|
673
|
+
title: "Fee Asset"
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
key: "realized_pnl",
|
|
677
|
+
title: "Realized PnL",
|
|
678
|
+
formatter: (v) => formatNumber(v, 2)
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
key: "created_time",
|
|
682
|
+
title: "Created Time",
|
|
683
|
+
formatter: formatTimestamp
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
key: "updated_time",
|
|
687
|
+
title: "Updated Time",
|
|
688
|
+
formatter: formatTimestamp
|
|
689
|
+
}
|
|
690
|
+
];
|
|
691
|
+
}
|
|
692
|
+
const baseColumns = [
|
|
693
|
+
{ key: "symbol", title: "Symbol" },
|
|
694
|
+
{
|
|
695
|
+
key: "order_id",
|
|
696
|
+
title: "Order ID"
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
key: "user_id",
|
|
700
|
+
title: "User ID"
|
|
701
|
+
},
|
|
702
|
+
{ key: "side", title: "Side" },
|
|
703
|
+
{ key: "type", title: "Order Type" },
|
|
704
|
+
{ key: "status", title: "Status" },
|
|
705
|
+
{
|
|
706
|
+
key: "price",
|
|
707
|
+
title: "Price",
|
|
708
|
+
formatter: (v) => v === null ? "--" : formatNumber(v, 4)
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
key: "quantity",
|
|
712
|
+
title: "Quantity",
|
|
713
|
+
formatter: (v) => formatNumber(v, 4)
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
key: "visible",
|
|
717
|
+
title: "Visible",
|
|
718
|
+
formatter: (v) => formatNumber(v, 4)
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
key: "visible_quantity",
|
|
722
|
+
title: "Visible Quantity",
|
|
723
|
+
formatter: (v) => formatNumber(v, 4)
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
key: "executed",
|
|
727
|
+
title: "Executed",
|
|
728
|
+
formatter: (v) => formatNumber(v, 4)
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
key: "total_executed_quantity",
|
|
732
|
+
title: "Total Executed Qty",
|
|
733
|
+
formatter: (v) => formatNumber(v, 4)
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
key: "average_executed_price",
|
|
737
|
+
title: "Avg Executed Price",
|
|
738
|
+
formatter: (v) => v === null ? "--" : formatNumber(v, 4)
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
key: "amount",
|
|
742
|
+
title: "Amount",
|
|
743
|
+
formatter: (v) => v === null ? "--" : formatNumber(v, 2)
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
key: "total_fee",
|
|
747
|
+
title: "Fee",
|
|
748
|
+
formatter: (v) => formatNumber(v, 8)
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
key: "fee_asset",
|
|
752
|
+
title: "Fee Asset"
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
key: "realized_pnl",
|
|
756
|
+
title: "Realized PnL",
|
|
757
|
+
formatter: (v) => formatNumber(v, 2)
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
key: "created_time",
|
|
761
|
+
title: "Created Time",
|
|
762
|
+
formatter: formatTimestamp
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
key: "updated_time",
|
|
766
|
+
title: "Updated Time",
|
|
767
|
+
formatter: formatTimestamp
|
|
768
|
+
}
|
|
769
|
+
];
|
|
770
|
+
if (tabType === "tp_sl") {
|
|
771
|
+
baseColumns.splice(6, 0, {
|
|
772
|
+
key: "trigger_price",
|
|
773
|
+
title: "Trigger Price",
|
|
774
|
+
formatter: (v) => formatNumber(v, 4)
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
return baseColumns;
|
|
778
|
+
};
|
|
779
|
+
var getPositionHistoryExportColumns = () => [
|
|
780
|
+
{
|
|
781
|
+
key: "position_id",
|
|
782
|
+
title: "Position ID"
|
|
783
|
+
},
|
|
784
|
+
{ key: "symbol", title: "Symbol" },
|
|
785
|
+
{
|
|
786
|
+
key: "position_status",
|
|
787
|
+
title: "Status"
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
key: "type",
|
|
791
|
+
title: "Type"
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
key: "side",
|
|
795
|
+
title: "Side"
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
key: "closed_position_qty",
|
|
799
|
+
title: "Closed Position Qty",
|
|
800
|
+
formatter: (v) => formatNumber(v, 4)
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
key: "max_position_qty",
|
|
804
|
+
title: "Max Position Qty",
|
|
805
|
+
formatter: (v) => formatNumber(v, 4)
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
key: "avg_open_price",
|
|
809
|
+
title: "Avg Open Price",
|
|
810
|
+
formatter: (v) => v === null ? "--" : formatNumber(v, 4)
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
key: "avg_close_price",
|
|
814
|
+
title: "Avg Close Price",
|
|
815
|
+
formatter: (v) => v === null ? "--" : formatNumber(v, 4)
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
key: "realized_pnl",
|
|
819
|
+
title: "Realized PnL",
|
|
820
|
+
formatter: (v) => formatNumber(v, 2)
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
key: "accumulated_funding_fee",
|
|
824
|
+
title: "Accumulated Funding Fee",
|
|
825
|
+
formatter: (v) => formatNumber(v, 2)
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
key: "trading_fee",
|
|
829
|
+
title: "Trading Fee",
|
|
830
|
+
formatter: (v) => formatNumber(v, 2)
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
key: "insurance_fund_fee",
|
|
834
|
+
title: "Insurance Fund Fee",
|
|
835
|
+
formatter: (v) => formatNumber(v, 2)
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
key: "liquidator_fee",
|
|
839
|
+
title: "Liquidator Fee",
|
|
840
|
+
formatter: (v) => formatNumber(v, 2)
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
key: "leverage",
|
|
844
|
+
title: "Leverage",
|
|
845
|
+
formatter: (v) => formatNumber(v, 2)
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
key: "open_timestamp",
|
|
849
|
+
title: "Time Opened",
|
|
850
|
+
formatter: formatTimestamp
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
key: "close_timestamp",
|
|
854
|
+
title: "Time Closed",
|
|
855
|
+
formatter: (v) => v ? formatTimestamp(v) : "--"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
key: "last_update_time",
|
|
859
|
+
title: "Updated Time",
|
|
860
|
+
formatter: formatTimestamp
|
|
861
|
+
}
|
|
862
|
+
];
|
|
863
|
+
var getLiquidationExportColumns = () => [
|
|
864
|
+
{
|
|
865
|
+
key: "timestamp",
|
|
866
|
+
title: "Time",
|
|
867
|
+
formatter: formatTimestamp
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
key: "type",
|
|
871
|
+
title: "Type"
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
key: "liquidation_id",
|
|
875
|
+
title: "Liquidation ID"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
key: "symbol",
|
|
879
|
+
title: "Symbol"
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
key: "position_qty",
|
|
883
|
+
title: "Position Qty",
|
|
884
|
+
formatter: (v) => formatNumber(v, 4)
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
key: "mark_price",
|
|
888
|
+
title: "Mark Price",
|
|
889
|
+
formatter: (v) => formatNumber(v, 4)
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
key: "transfer_price",
|
|
893
|
+
title: "Transfer Price",
|
|
894
|
+
formatter: (v) => formatNumber(v, 4)
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
key: "liquidator_fee",
|
|
898
|
+
title: "Liquidator Fee",
|
|
899
|
+
formatter: (v) => formatNumber(v, 8)
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
key: "abs_liquidation_fee",
|
|
903
|
+
title: "Abs Liquidation Fee",
|
|
904
|
+
formatter: (v) => formatNumber(v, 2)
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
key: "insurance_fund_fee",
|
|
908
|
+
title: "Insurance Fund Fee",
|
|
909
|
+
formatter: (v) => formatNumber(v, 8)
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
key: "abs_insurance_fund_fee",
|
|
913
|
+
title: "Abs Insurance Fund Fee",
|
|
914
|
+
formatter: (v) => formatNumber(v, 2)
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
key: "cost_position_transfer",
|
|
918
|
+
title: "Cost Position Transfer",
|
|
919
|
+
formatter: (v) => formatNumber(v, 2)
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
key: "margin_ratio",
|
|
923
|
+
title: "Margin Ratio",
|
|
924
|
+
formatter: (v) => formatPercent(v, 4)
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
key: "account_mmr",
|
|
928
|
+
title: "Account MMR",
|
|
929
|
+
formatter: (v) => formatPercent(v, 4)
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
key: "position_notional",
|
|
933
|
+
title: "Position Notional",
|
|
934
|
+
formatter: (v) => formatNumber(v, 2)
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
key: "collateral_value",
|
|
938
|
+
title: "Collateral Value",
|
|
939
|
+
formatter: (v) => formatNumber(v, 2)
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
key: "transfer_amount_to_insurance_fund",
|
|
943
|
+
title: "Transfer Amount to Insurance Fund",
|
|
944
|
+
formatter: (v) => formatNumber(v, 2)
|
|
945
|
+
}
|
|
946
|
+
];
|
|
947
|
+
var exportToCSVFile = (options) => {
|
|
948
|
+
const csv = generateCSV(options);
|
|
949
|
+
downloadCSV(csv, options.filename);
|
|
950
|
+
};
|
|
475
951
|
// Annotate the CommonJS export names for ESM import in node:
|
|
476
952
|
0 && (module.exports = {
|
|
477
953
|
Decimal,
|
|
@@ -482,11 +958,21 @@ formatNumWithNamespace.collateral = (num) => {
|
|
|
482
958
|
commifyOptional,
|
|
483
959
|
cutNumber,
|
|
484
960
|
dayjs,
|
|
961
|
+
downloadCSV,
|
|
962
|
+
exportToCSVFile,
|
|
485
963
|
findLongestCommonSubString,
|
|
486
964
|
formatNum,
|
|
965
|
+
formatNumber,
|
|
966
|
+
formatPercent,
|
|
487
967
|
formatSymbol,
|
|
968
|
+
formatTimestamp,
|
|
969
|
+
generateCSV,
|
|
488
970
|
getBBOType,
|
|
489
971
|
getGlobalObject,
|
|
972
|
+
getLiquidationExportColumns,
|
|
973
|
+
getOrderExportColumns,
|
|
974
|
+
getPositionExportColumns,
|
|
975
|
+
getPositionHistoryExportColumns,
|
|
490
976
|
getPrecisionByNumber,
|
|
491
977
|
getTPSLDirection,
|
|
492
978
|
getTimestamp,
|