@t2000/cli 0.14.0 → 0.14.1
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.js
CHANGED
|
@@ -1787,7 +1787,7 @@ function registerMcp(program2) {
|
|
|
1787
1787
|
mcp.command("start", { isDefault: true }).description("Start MCP server (stdio transport)").option("--key <path>", "Key file path").action(async (opts) => {
|
|
1788
1788
|
let mod;
|
|
1789
1789
|
try {
|
|
1790
|
-
mod = await import("./dist-
|
|
1790
|
+
mod = await import("./dist-4YM7JZSI.js");
|
|
1791
1791
|
} catch {
|
|
1792
1792
|
console.error(
|
|
1793
1793
|
"MCP server not installed. Run:\n npm install -g @t2000/mcp"
|
|
@@ -1940,7 +1940,7 @@ function registerContacts(program2) {
|
|
|
1940
1940
|
|
|
1941
1941
|
// src/commands/invest.ts
|
|
1942
1942
|
import pc13 from "picocolors";
|
|
1943
|
-
import { T2000 as T200024, formatUsd as formatUsd15 } from "@t2000/sdk";
|
|
1943
|
+
import { T2000 as T200024, formatUsd as formatUsd15, formatAssetAmount } from "@t2000/sdk";
|
|
1944
1944
|
function registerInvest(program2) {
|
|
1945
1945
|
const investCmd = program2.command("invest").description("Buy or sell investment assets");
|
|
1946
1946
|
investCmd.command("buy <amount> <asset>").description("Invest USD amount in an asset").option("--key <path>", "Key file path").option("--slippage <pct>", "Max slippage percent", "3").action(async (amount, asset, opts) => {
|
|
@@ -1963,9 +1963,10 @@ function registerInvest(program2) {
|
|
|
1963
1963
|
return;
|
|
1964
1964
|
}
|
|
1965
1965
|
printBlank();
|
|
1966
|
-
|
|
1966
|
+
const sym = asset.toUpperCase();
|
|
1967
|
+
printSuccess(`Bought ${formatAssetAmount(result.amount, sym)} ${sym} at ${formatUsd15(result.price)}`);
|
|
1967
1968
|
printKeyValue("Invested", formatUsd15(result.usdValue));
|
|
1968
|
-
printKeyValue("Portfolio", `${result.position.totalAmount
|
|
1969
|
+
printKeyValue("Portfolio", `${formatAssetAmount(result.position.totalAmount, sym)} ${sym} (avg ${formatUsd15(result.position.avgPrice)})`);
|
|
1969
1970
|
printKeyValue("Tx", explorerUrl(result.tx));
|
|
1970
1971
|
printBlank();
|
|
1971
1972
|
} catch (error) {
|
|
@@ -1996,7 +1997,8 @@ function registerInvest(program2) {
|
|
|
1996
1997
|
return;
|
|
1997
1998
|
}
|
|
1998
1999
|
printBlank();
|
|
1999
|
-
|
|
2000
|
+
const sym = asset.toUpperCase();
|
|
2001
|
+
printSuccess(`Sold ${formatAssetAmount(result.amount, sym)} ${sym} at ${formatUsd15(result.price)}`);
|
|
2000
2002
|
printKeyValue("Proceeds", formatUsd15(result.usdValue));
|
|
2001
2003
|
if (result.realizedPnL !== void 0) {
|
|
2002
2004
|
const pnlColor = result.realizedPnL >= 0 ? pc13.green : pc13.red;
|
|
@@ -2004,7 +2006,7 @@ function registerInvest(program2) {
|
|
|
2004
2006
|
printKeyValue("Realized P&L", pnlColor(`${pnlSign}${formatUsd15(result.realizedPnL)}`));
|
|
2005
2007
|
}
|
|
2006
2008
|
if (result.position.totalAmount > 0) {
|
|
2007
|
-
printKeyValue("Remaining", `${result.position.totalAmount
|
|
2009
|
+
printKeyValue("Remaining", `${formatAssetAmount(result.position.totalAmount, sym)} ${sym} (avg ${formatUsd15(result.position.avgPrice)})`);
|
|
2008
2010
|
}
|
|
2009
2011
|
printKeyValue("Tx", explorerUrl(result.tx));
|
|
2010
2012
|
printBlank();
|
|
@@ -2016,7 +2018,7 @@ function registerInvest(program2) {
|
|
|
2016
2018
|
|
|
2017
2019
|
// src/commands/portfolio.ts
|
|
2018
2020
|
import pc14 from "picocolors";
|
|
2019
|
-
import { T2000 as T200025, formatUsd as formatUsd16 } from "@t2000/sdk";
|
|
2021
|
+
import { T2000 as T200025, formatUsd as formatUsd16, formatAssetAmount as formatAssetAmount2 } from "@t2000/sdk";
|
|
2020
2022
|
function registerPortfolio(program2) {
|
|
2021
2023
|
program2.command("portfolio").description("Show investment portfolio").option("--key <path>", "Key file path").action(async (opts) => {
|
|
2022
2024
|
try {
|
|
@@ -2039,14 +2041,14 @@ function registerPortfolio(program2) {
|
|
|
2039
2041
|
if (pos.currentPrice === 0 && pos.totalAmount > 0) {
|
|
2040
2042
|
printKeyValue(
|
|
2041
2043
|
pos.asset,
|
|
2042
|
-
`${pos.totalAmount.
|
|
2044
|
+
`${formatAssetAmount2(pos.totalAmount, pos.asset)} Avg: ${formatUsd16(pos.avgPrice)} Now: ${pc14.yellow("unavailable")}`
|
|
2043
2045
|
);
|
|
2044
2046
|
} else {
|
|
2045
2047
|
const pnlColor = pos.unrealizedPnL >= 0 ? pc14.green : pc14.red;
|
|
2046
2048
|
const pnlSign = pos.unrealizedPnL >= 0 ? "+" : "";
|
|
2047
2049
|
printKeyValue(
|
|
2048
2050
|
pos.asset,
|
|
2049
|
-
`${pos.totalAmount.
|
|
2051
|
+
`${formatAssetAmount2(pos.totalAmount, pos.asset)} Avg: ${formatUsd16(pos.avgPrice)} Now: ${formatUsd16(pos.currentPrice)} ${pnlColor(`${pnlSign}${formatUsd16(pos.unrealizedPnL)} (${pnlSign}${pos.unrealizedPnLPct.toFixed(1)}%)`)}`
|
|
2050
2052
|
);
|
|
2051
2053
|
}
|
|
2052
2054
|
}
|