@huskly/ibkr-client 0.6.0 → 0.8.0
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/README.md +79 -55
- package/dist/ibkr/derivativeContract.d.ts +6 -0
- package/dist/ibkr/derivativeContract.d.ts.map +1 -0
- package/dist/ibkr/derivativeContract.js +69 -0
- package/dist/ibkr/derivativeContract.js.map +1 -0
- package/dist/ibkr/ibkrApiTypes.d.ts +83 -1
- package/dist/ibkr/ibkrApiTypes.d.ts.map +1 -1
- package/dist/ibkr/ibkrClient.d.ts +39 -3
- package/dist/ibkr/ibkrClient.d.ts.map +1 -1
- package/dist/ibkr/ibkrClient.js +542 -2
- package/dist/ibkr/ibkrClient.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +133 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -6
- package/dist/types.js.map +1 -1
- package/package.json +4 -10
- package/dist/cli/account.d.ts +0 -7
- package/dist/cli/account.d.ts.map +0 -1
- package/dist/cli/account.js +0 -27
- package/dist/cli/account.js.map +0 -1
- package/dist/cli/index.d.ts +0 -3
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -50
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/orders.d.ts +0 -4
- package/dist/cli/orders.d.ts.map +0 -1
- package/dist/cli/orders.js +0 -5
- package/dist/cli/orders.js.map +0 -1
- package/dist/cli/positions.d.ts +0 -12
- package/dist/cli/positions.d.ts.map +0 -1
- package/dist/cli/positions.js +0 -106
- package/dist/cli/positions.js.map +0 -1
- package/dist/cli/quote.d.ts +0 -4
- package/dist/cli/quote.d.ts.map +0 -1
- package/dist/cli/quote.js +0 -5
- package/dist/cli/quote.js.map +0 -1
- package/dist/cli/shared.d.ts +0 -12
- package/dist/cli/shared.d.ts.map +0 -1
- package/dist/cli/shared.js +0 -31
- package/dist/cli/shared.js.map +0 -1
- package/dist/format.d.ts +0 -13
- package/dist/format.d.ts.map +0 -1
- package/dist/format.js +0 -32
- package/dist/format.js.map +0 -1
package/dist/cli/orders.js
DELETED
package/dist/cli/orders.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"orders.js","sourceRoot":"","sources":["../../src/cli/orders.ts"],"names":[],"mappings":"AAEA,4DAA4D;AAC5D,MAAM,UAAU,YAAY,CAAC,OAAmB;IAC9C,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/cli/positions.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { BrokerName } from "../types.js";
|
|
2
|
-
interface PositionsOptions {
|
|
3
|
-
type?: string;
|
|
4
|
-
csv?: boolean;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Show account positions as a table (or CSV).
|
|
8
|
-
* Ports render_positions() from main.py.
|
|
9
|
-
*/
|
|
10
|
-
export declare function handlePositions(broker: BrokerName, symbol: string | undefined, options: PositionsOptions): Promise<void>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=positions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"positions.d.ts","sourceRoot":"","sources":["../../src/cli/positions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,aAAa,CAAC;AAE9D,UAAU,gBAAgB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AA6BD;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAef"}
|
package/dist/cli/positions.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { apiClient } from "./shared.js";
|
|
3
|
-
import { fmtMoney, fmtPct, pad, pnlColor } from "../format.js";
|
|
4
|
-
const HEADERS = [
|
|
5
|
-
"Symbol",
|
|
6
|
-
"Type",
|
|
7
|
-
"Long",
|
|
8
|
-
"Short",
|
|
9
|
-
"Avg Price",
|
|
10
|
-
"Cur Price",
|
|
11
|
-
"Mkt Value",
|
|
12
|
-
"Day P/L",
|
|
13
|
-
"P/L Open",
|
|
14
|
-
"P/L %",
|
|
15
|
-
];
|
|
16
|
-
/** Columns 0 (Symbol) and 1 (Type) are left-aligned; the rest right-aligned. */
|
|
17
|
-
const LEFT_ALIGNED = new Set([0, 1]);
|
|
18
|
-
/** Open P/L as a fraction of cost basis (marketValue net of open P/L). */
|
|
19
|
-
function plPercent(pos) {
|
|
20
|
-
const costBasis = pos.marketValue - pos.openProfitLoss;
|
|
21
|
-
return costBasis ? (pos.openProfitLoss / costBasis) * 100 : null;
|
|
22
|
-
}
|
|
23
|
-
/** Escape a value for CSV output. */
|
|
24
|
-
function escapeCsv(value) {
|
|
25
|
-
return /[",\n]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Show account positions as a table (or CSV).
|
|
29
|
-
* Ports render_positions() from main.py.
|
|
30
|
-
*/
|
|
31
|
-
export async function handlePositions(broker, symbol, options) {
|
|
32
|
-
const api = await apiClient(broker);
|
|
33
|
-
let positions = await api.getPositions(symbol);
|
|
34
|
-
if (options.type) {
|
|
35
|
-
const upper = options.type.toUpperCase();
|
|
36
|
-
positions = positions.filter((p) => p.assetType.toUpperCase() === upper);
|
|
37
|
-
}
|
|
38
|
-
positions = positions.sort((a, b) => a.symbol.localeCompare(b.symbol));
|
|
39
|
-
if (options.csv) {
|
|
40
|
-
renderCsv(positions);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
renderTable(symbol, options.type, positions);
|
|
44
|
-
}
|
|
45
|
-
function renderCsv(positions) {
|
|
46
|
-
if (positions.length === 0)
|
|
47
|
-
return;
|
|
48
|
-
console.log(HEADERS.join(","));
|
|
49
|
-
for (const p of positions) {
|
|
50
|
-
const pct = plPercent(p);
|
|
51
|
-
console.log([
|
|
52
|
-
escapeCsv(p.symbol),
|
|
53
|
-
escapeCsv(p.assetType),
|
|
54
|
-
p.longQuantity || "",
|
|
55
|
-
p.shortQuantity || "",
|
|
56
|
-
p.averagePrice.toFixed(2),
|
|
57
|
-
p.marketPrice.toFixed(2),
|
|
58
|
-
p.marketValue.toFixed(2),
|
|
59
|
-
p.currentDayProfitLoss.toFixed(2),
|
|
60
|
-
p.openProfitLoss.toFixed(2),
|
|
61
|
-
pct === null ? "" : pct.toFixed(2),
|
|
62
|
-
].join(","));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function renderTable(symbol, type, positions) {
|
|
66
|
-
const filters = [symbol?.toUpperCase(), type?.toUpperCase()].filter(Boolean);
|
|
67
|
-
const filterText = filters.length ? `: ${filters.join(", ")}` : "";
|
|
68
|
-
console.log(chalk.bold(`\nAccount Positions${filterText}\n`));
|
|
69
|
-
if (positions.length === 0) {
|
|
70
|
-
console.log(chalk.yellow(" (no open positions)"));
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
// Each cell is [text, colorFn]; colorize after width is measured on raw text.
|
|
74
|
-
const rows = positions.map((p) => {
|
|
75
|
-
const pct = plPercent(p);
|
|
76
|
-
return [
|
|
77
|
-
[p.symbol, chalk.cyan],
|
|
78
|
-
[p.assetType, chalk.white],
|
|
79
|
-
[p.longQuantity > 0 ? String(p.longQuantity) : "-", chalk.green],
|
|
80
|
-
[p.shortQuantity > 0 ? String(p.shortQuantity) : "-", chalk.red],
|
|
81
|
-
[fmtMoney(p.averagePrice), chalk.white],
|
|
82
|
-
[fmtMoney(p.marketPrice), chalk.white],
|
|
83
|
-
[fmtMoney(p.marketValue), pnlColor(p.marketValue)],
|
|
84
|
-
[fmtMoney(p.currentDayProfitLoss, true), pnlColor(p.currentDayProfitLoss)],
|
|
85
|
-
[fmtMoney(p.openProfitLoss, true), pnlColor(p.openProfitLoss)],
|
|
86
|
-
[fmtPct(pct), pnlColor(pct)],
|
|
87
|
-
];
|
|
88
|
-
});
|
|
89
|
-
const widths = HEADERS.map((h) => h.length);
|
|
90
|
-
for (const row of rows) {
|
|
91
|
-
row.forEach(([text], i) => {
|
|
92
|
-
widths[i] = Math.max(widths[i] ?? 0, text.length);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
const align = (i) => (LEFT_ALIGNED.has(i) ? "left" : "right");
|
|
96
|
-
const gap = " ";
|
|
97
|
-
const headerLine = HEADERS.map((h, i) => chalk.dim(pad(h, widths[i] ?? 0, align(i)))).join(gap);
|
|
98
|
-
const totalWidth = widths.reduce((sum, w) => sum + w, 0) + gap.length * (widths.length - 1);
|
|
99
|
-
console.log(headerLine);
|
|
100
|
-
console.log(chalk.dim("-".repeat(totalWidth)));
|
|
101
|
-
for (const row of rows) {
|
|
102
|
-
console.log(row.map(([text, color], i) => color(pad(text, widths[i] ?? 0, align(i)))).join(gap));
|
|
103
|
-
}
|
|
104
|
-
console.log();
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=positions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"positions.js","sourceRoot":"","sources":["../../src/cli/positions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAQ/D,MAAM,OAAO,GAAG;IACd,QAAQ;IACR,MAAM;IACN,MAAM;IACN,OAAO;IACP,WAAW;IACX,WAAW;IACX,WAAW;IACX,SAAS;IACT,UAAU;IACV,OAAO;CACC,CAAC;AAEX,gFAAgF;A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AG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE5F,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC/C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CACT,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACpF,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
|
package/dist/cli/quote.d.ts
DELETED
package/dist/cli/quote.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/cli/quote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,kEAAkE;AAClE,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAEzE"}
|
package/dist/cli/quote.js
DELETED
package/dist/cli/quote.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../../src/cli/quote.ts"],"names":[],"mappings":"AAEA,kEAAkE;AAClE,MAAM,UAAU,WAAW,CAAC,OAAmB,EAAE,QAAkB;IACjE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;AAC9D,CAAC"}
|
package/dist/cli/shared.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { BrokerClient, BrokerName } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Resolve an authenticated {@link BrokerClient} for the requested broker.
|
|
4
|
-
*
|
|
5
|
-
* Today only IBKR is implemented. The `schwab` branch is intentionally a
|
|
6
|
-
* placeholder: when this is merged into huskly-cli it will return a thin
|
|
7
|
-
* adapter over huskly's existing `SchwabClient`, satisfying the same interface.
|
|
8
|
-
*/
|
|
9
|
-
export declare function apiClient(broker?: BrokerName): Promise<BrokerClient>;
|
|
10
|
-
/** Resolve the broker from a Commander option, validating the value. */
|
|
11
|
-
export declare function resolveBroker(value: string | undefined): BrokerName;
|
|
12
|
-
//# sourceMappingURL=shared.d.ts.map
|
package/dist/cli/shared.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/cli/shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,MAAM,GAAE,UAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CAclF;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAMnE"}
|
package/dist/cli/shared.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { IbkrClient } from "../ibkr/ibkrClient.js";
|
|
2
|
-
import { buildOauthConfig } from "../ibkr/oauthConfig.js";
|
|
3
|
-
/**
|
|
4
|
-
* Resolve an authenticated {@link BrokerClient} for the requested broker.
|
|
5
|
-
*
|
|
6
|
-
* Today only IBKR is implemented. The `schwab` branch is intentionally a
|
|
7
|
-
* placeholder: when this is merged into huskly-cli it will return a thin
|
|
8
|
-
* adapter over huskly's existing `SchwabClient`, satisfying the same interface.
|
|
9
|
-
*/
|
|
10
|
-
export async function apiClient(broker = "ibkr") {
|
|
11
|
-
switch (broker) {
|
|
12
|
-
case "ibkr": {
|
|
13
|
-
const client = new IbkrClient(buildOauthConfig());
|
|
14
|
-
await client.init();
|
|
15
|
-
return client;
|
|
16
|
-
}
|
|
17
|
-
case "schwab":
|
|
18
|
-
throw new Error("Broker 'schwab' is not supported yet. It will be wired up when this CLI is merged into huskly-cli.");
|
|
19
|
-
default:
|
|
20
|
-
throw new Error(`Unknown broker: ${String(broker)}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/** Resolve the broker from a Commander option, validating the value. */
|
|
24
|
-
export function resolveBroker(value) {
|
|
25
|
-
const broker = (value ?? "ibkr").toLowerCase();
|
|
26
|
-
if (broker !== "ibkr" && broker !== "schwab") {
|
|
27
|
-
throw new Error(`Invalid --broker '${broker}'. Expected 'ibkr' or 'schwab'.`);
|
|
28
|
-
}
|
|
29
|
-
return broker;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=shared.js.map
|
package/dist/cli/shared.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/cli/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,SAAqB,MAAM;IACzD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;YAClD,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,KAAK,QAAQ;YACX,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;QACJ;YACE,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,MAAM,GAAG,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/C,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,iCAAiC,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/format.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Terminal formatting helpers, ported from main.py (fmt_money / fmt_pct /
|
|
3
|
-
* P&L coloring), using chalk instead of raw ANSI codes.
|
|
4
|
-
*/
|
|
5
|
-
/** Format a dollar amount. `signed` forces a leading +/- (for P&L). */
|
|
6
|
-
export declare function fmtMoney(value: number | null | undefined, signed?: boolean): string;
|
|
7
|
-
/** Format a percentage with an explicit +/- sign. */
|
|
8
|
-
export declare function fmtPct(value: number | null | undefined): string;
|
|
9
|
-
/** Green for non-negative P&L, red for losses. */
|
|
10
|
-
export declare function pnlColor(value: number | null | undefined): (text: string) => string;
|
|
11
|
-
/** Pad `text` into `width`, left- or right-aligned. */
|
|
12
|
-
export declare function pad(text: string, width: number, align?: "left" | "right"): string;
|
|
13
|
-
//# sourceMappingURL=format.d.ts.map
|
package/dist/format.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,UAAQ,GAAG,MAAM,CAQjF;AAED,qDAAqD;AACrD,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAI/D;AAED,kDAAkD;AAClD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAEnF;AAED,uDAAuD;AACvD,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,GAAG,OAAgB,GAAG,MAAM,CAEzF"}
|
package/dist/format.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
/**
|
|
3
|
-
* Terminal formatting helpers, ported from main.py (fmt_money / fmt_pct /
|
|
4
|
-
* P&L coloring), using chalk instead of raw ANSI codes.
|
|
5
|
-
*/
|
|
6
|
-
/** Format a dollar amount. `signed` forces a leading +/- (for P&L). */
|
|
7
|
-
export function fmtMoney(value, signed = false) {
|
|
8
|
-
if (value === null || value === undefined)
|
|
9
|
-
return "-";
|
|
10
|
-
const sign = value < 0 ? "-" : signed ? "+" : "";
|
|
11
|
-
const abs = Math.abs(value).toLocaleString("en-US", {
|
|
12
|
-
minimumFractionDigits: 2,
|
|
13
|
-
maximumFractionDigits: 2,
|
|
14
|
-
});
|
|
15
|
-
return `${sign}$${abs}`;
|
|
16
|
-
}
|
|
17
|
-
/** Format a percentage with an explicit +/- sign. */
|
|
18
|
-
export function fmtPct(value) {
|
|
19
|
-
if (value === null || value === undefined)
|
|
20
|
-
return "-";
|
|
21
|
-
const sign = value < 0 ? "-" : "+";
|
|
22
|
-
return `${sign}${Math.abs(value).toFixed(2)}%`;
|
|
23
|
-
}
|
|
24
|
-
/** Green for non-negative P&L, red for losses. */
|
|
25
|
-
export function pnlColor(value) {
|
|
26
|
-
return (value ?? 0) < 0 ? chalk.red : chalk.green;
|
|
27
|
-
}
|
|
28
|
-
/** Pad `text` into `width`, left- or right-aligned. */
|
|
29
|
-
export function pad(text, width, align = "left") {
|
|
30
|
-
return align === "right" ? text.padStart(width) : text.padEnd(width);
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=format.js.map
|
package/dist/format.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;GAGG;AAEH,uEAAuE;AACvE,MAAM,UAAU,QAAQ,CAAC,KAAgC,EAAE,MAAM,GAAG,KAAK;IACvE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IACtD,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,OAAO,EAAE;QAClD,qBAAqB,EAAE,CAAC;QACxB,qBAAqB,EAAE,CAAC;KACzB,CAAC,CAAC;IACH,OAAO,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,MAAM,CAAC,KAAgC;IACrD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IACtD,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACnC,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CA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