hyperprop-charting-library 0.1.93 → 0.1.95

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.
@@ -2523,8 +2523,19 @@ function createChart(element, options = {}) {
2523
2523
  const riskAmount = drawing.riskMode === "amount" ? drawing.risk : drawing.accountSize * (drawing.risk / 100);
2524
2524
  const qtyRaw = riskAmount > 0 && stopDist > 0 ? riskAmount / (stopDist * effectivePointValue) : 0;
2525
2525
  const hasMoney = qtyRaw > 0 && Number.isFinite(qtyRaw);
2526
- const qtyText = hasMoney ? qtyRaw.toFixed(Math.max(0, drawing.qtyPrecision)) : "";
2527
- const formatAmount = (value) => value.toFixed(2);
2526
+ const qtyDigits = Math.min(Math.max(0, drawing.qtyPrecision), 2);
2527
+ let qtyText = "";
2528
+ if (hasMoney) {
2529
+ qtyText = qtyRaw.toFixed(qtyDigits);
2530
+ if (qtyText.includes(".")) qtyText = qtyText.replace(/\.?0+$/, "");
2531
+ }
2532
+ const formatAmount = (value) => {
2533
+ const abs = Math.abs(value);
2534
+ if (abs >= 1e9) return `${(value / 1e9).toFixed(2)}B`;
2535
+ if (abs >= 1e6) return `${(value / 1e6).toFixed(2)}M`;
2536
+ if (abs >= 1e3) return `${(value / 1e3).toFixed(2)}K`;
2537
+ return value.toFixed(2);
2538
+ };
2528
2539
  const targetAmountText = hasMoney ? `, Amount: ${formatAmount(qtyRaw * target.price * effectivePointValue)}` : "";
2529
2540
  const stopAmountText = hasMoney ? `, Amount: ${formatAmount(qtyRaw * stop.price * effectivePointValue)}` : "";
2530
2541
  const drawPositionPill = (text, leftX2, centerY, bg) => {
@@ -2497,8 +2497,19 @@ function createChart(element, options = {}) {
2497
2497
  const riskAmount = drawing.riskMode === "amount" ? drawing.risk : drawing.accountSize * (drawing.risk / 100);
2498
2498
  const qtyRaw = riskAmount > 0 && stopDist > 0 ? riskAmount / (stopDist * effectivePointValue) : 0;
2499
2499
  const hasMoney = qtyRaw > 0 && Number.isFinite(qtyRaw);
2500
- const qtyText = hasMoney ? qtyRaw.toFixed(Math.max(0, drawing.qtyPrecision)) : "";
2501
- const formatAmount = (value) => value.toFixed(2);
2500
+ const qtyDigits = Math.min(Math.max(0, drawing.qtyPrecision), 2);
2501
+ let qtyText = "";
2502
+ if (hasMoney) {
2503
+ qtyText = qtyRaw.toFixed(qtyDigits);
2504
+ if (qtyText.includes(".")) qtyText = qtyText.replace(/\.?0+$/, "");
2505
+ }
2506
+ const formatAmount = (value) => {
2507
+ const abs = Math.abs(value);
2508
+ if (abs >= 1e9) return `${(value / 1e9).toFixed(2)}B`;
2509
+ if (abs >= 1e6) return `${(value / 1e6).toFixed(2)}M`;
2510
+ if (abs >= 1e3) return `${(value / 1e3).toFixed(2)}K`;
2511
+ return value.toFixed(2);
2512
+ };
2502
2513
  const targetAmountText = hasMoney ? `, Amount: ${formatAmount(qtyRaw * target.price * effectivePointValue)}` : "";
2503
2514
  const stopAmountText = hasMoney ? `, Amount: ${formatAmount(qtyRaw * stop.price * effectivePointValue)}` : "";
2504
2515
  const drawPositionPill = (text, leftX2, centerY, bg) => {
package/dist/index.cjs CHANGED
@@ -2523,8 +2523,19 @@ function createChart(element, options = {}) {
2523
2523
  const riskAmount = drawing.riskMode === "amount" ? drawing.risk : drawing.accountSize * (drawing.risk / 100);
2524
2524
  const qtyRaw = riskAmount > 0 && stopDist > 0 ? riskAmount / (stopDist * effectivePointValue) : 0;
2525
2525
  const hasMoney = qtyRaw > 0 && Number.isFinite(qtyRaw);
2526
- const qtyText = hasMoney ? qtyRaw.toFixed(Math.max(0, drawing.qtyPrecision)) : "";
2527
- const formatAmount = (value) => value.toFixed(2);
2526
+ const qtyDigits = Math.min(Math.max(0, drawing.qtyPrecision), 2);
2527
+ let qtyText = "";
2528
+ if (hasMoney) {
2529
+ qtyText = qtyRaw.toFixed(qtyDigits);
2530
+ if (qtyText.includes(".")) qtyText = qtyText.replace(/\.?0+$/, "");
2531
+ }
2532
+ const formatAmount = (value) => {
2533
+ const abs = Math.abs(value);
2534
+ if (abs >= 1e9) return `${(value / 1e9).toFixed(2)}B`;
2535
+ if (abs >= 1e6) return `${(value / 1e6).toFixed(2)}M`;
2536
+ if (abs >= 1e3) return `${(value / 1e3).toFixed(2)}K`;
2537
+ return value.toFixed(2);
2538
+ };
2528
2539
  const targetAmountText = hasMoney ? `, Amount: ${formatAmount(qtyRaw * target.price * effectivePointValue)}` : "";
2529
2540
  const stopAmountText = hasMoney ? `, Amount: ${formatAmount(qtyRaw * stop.price * effectivePointValue)}` : "";
2530
2541
  const drawPositionPill = (text, leftX2, centerY, bg) => {
package/dist/index.js CHANGED
@@ -2497,8 +2497,19 @@ function createChart(element, options = {}) {
2497
2497
  const riskAmount = drawing.riskMode === "amount" ? drawing.risk : drawing.accountSize * (drawing.risk / 100);
2498
2498
  const qtyRaw = riskAmount > 0 && stopDist > 0 ? riskAmount / (stopDist * effectivePointValue) : 0;
2499
2499
  const hasMoney = qtyRaw > 0 && Number.isFinite(qtyRaw);
2500
- const qtyText = hasMoney ? qtyRaw.toFixed(Math.max(0, drawing.qtyPrecision)) : "";
2501
- const formatAmount = (value) => value.toFixed(2);
2500
+ const qtyDigits = Math.min(Math.max(0, drawing.qtyPrecision), 2);
2501
+ let qtyText = "";
2502
+ if (hasMoney) {
2503
+ qtyText = qtyRaw.toFixed(qtyDigits);
2504
+ if (qtyText.includes(".")) qtyText = qtyText.replace(/\.?0+$/, "");
2505
+ }
2506
+ const formatAmount = (value) => {
2507
+ const abs = Math.abs(value);
2508
+ if (abs >= 1e9) return `${(value / 1e9).toFixed(2)}B`;
2509
+ if (abs >= 1e6) return `${(value / 1e6).toFixed(2)}M`;
2510
+ if (abs >= 1e3) return `${(value / 1e3).toFixed(2)}K`;
2511
+ return value.toFixed(2);
2512
+ };
2502
2513
  const targetAmountText = hasMoney ? `, Amount: ${formatAmount(qtyRaw * target.price * effectivePointValue)}` : "";
2503
2514
  const stopAmountText = hasMoney ? `, Amount: ${formatAmount(qtyRaw * stop.price * effectivePointValue)}` : "";
2504
2515
  const drawPositionPill = (text, leftX2, centerY, bg) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.93",
3
+ "version": "0.1.95",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",