@pradeepjadhav/trading-reload-chart 1.0.1 → 1.0.2
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/canvas/layers/TradeLayer/TradeLayer.d.ts +4 -4
- package/dist/canvas/layers/TradeLayer/TradeLayer.helpers.d.ts +2 -2
- package/dist/canvas/layers/TradeLayer/TradeLayer.types.d.ts +3 -38
- package/dist/chart/ChartController.types.d.ts +3 -4
- package/dist/index.d.ts +2 -2
- package/dist/models/Trade.types.d.ts +2 -2
- package/dist/trading-reload-chart.js +2 -2
- package/package.json +2 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { TemporaryTradeProtectionHandleRectConfig, TradeHandleRectConfig, TradeHandleStyleConfig } from '../../../config/chartConfig.types';
|
|
2
2
|
import { Candle } from '../../../models/Candle.types';
|
|
3
3
|
import { ChartViewport } from '../../../models/ChartViewport.types';
|
|
4
|
-
import { OpenTrade } from '../../../models/Trade.types';
|
|
5
|
-
import { CreateHitBoxOptions, CreateMissingProtectionHitBoxOptions, DrawConnectorLineOptions, DrawHandleLineOptions, DrawHandleRectOptions, DrawHandleSectionsOptions, DrawTradeHandleOptions, LineBlockedRange,
|
|
4
|
+
import { ClosedTrade, OpenTrade } from '../../../models/Trade.types';
|
|
5
|
+
import { CreateHitBoxOptions, CreateMissingProtectionHitBoxOptions, DrawConnectorLineOptions, DrawHandleLineOptions, DrawHandleRectOptions, DrawHandleSectionsOptions, DrawTradeHandleOptions, LineBlockedRange, TemporaryTradeProtectionDrag, TradeHandleHitbox, TradeHandleRenderState, TradeHandleType, TradeLayerOptions, TradeProtectionHandleType } from './TradeLayer.types';
|
|
6
6
|
export declare class TradeLayer {
|
|
7
7
|
#private;
|
|
8
8
|
isDragging: boolean;
|
|
9
9
|
trades: OpenTrade[];
|
|
10
|
-
pastTrades:
|
|
10
|
+
pastTrades: ClosedTrade[];
|
|
11
11
|
candles: Candle[];
|
|
12
12
|
viewport: ChartViewport | null;
|
|
13
13
|
liveCandle: Candle | null;
|
|
@@ -15,7 +15,7 @@ export declare class TradeLayer {
|
|
|
15
15
|
temporaryProtectionDrag: TemporaryTradeProtectionDrag | null;
|
|
16
16
|
constructor(options: TradeLayerOptions);
|
|
17
17
|
setTrades(trades: OpenTrade[]): void;
|
|
18
|
-
setPastTrades(pastTrades:
|
|
18
|
+
setPastTrades(pastTrades: ClosedTrade[]): void;
|
|
19
19
|
setCandles(candles: Candle[]): void;
|
|
20
20
|
setViewport(viewport: ChartViewport): void;
|
|
21
21
|
setLiveCandle(candle: Candle): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TradeDirection } from '../../../models/Trade.types';
|
|
2
2
|
export declare const getPipSize: (symbol: string) => number;
|
|
3
|
-
export declare const calculatePotentialPnlUsd: (type:
|
|
3
|
+
export declare const calculatePotentialPnlUsd: (type: TradeDirection, entryPrice: number, targetPrice: number, volume: number, symbol: string) => number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MissingTradeProtectionHandleRectConfig, PastTradeIndicatorArrowConfig, TemporaryTradeProtectionHandleRectConfig, TradeHandleLineConfig, TradeHandleRectConfig, TradeHandleStyleConfig } from '../../../config/chartConfig.types';
|
|
2
2
|
import { ChartViewport } from '../../../models/ChartViewport.types';
|
|
3
|
-
import { OpenTrade,
|
|
3
|
+
import { ClosedTrade, OpenTrade, TradeDirection } from '../../../models/Trade.types';
|
|
4
4
|
/**
|
|
5
5
|
* Type of existing trade handle shown on open positions.
|
|
6
6
|
*
|
|
@@ -50,41 +50,6 @@ export type TemporaryTradeProtectionDrag = {
|
|
|
50
50
|
price: number;
|
|
51
51
|
viewport: ChartViewport;
|
|
52
52
|
};
|
|
53
|
-
/**
|
|
54
|
-
* Historical trade marker rendered on the chart after a position is closed.
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* const trade: PastTrade = {
|
|
59
|
-
* symbol: "EURUSD",
|
|
60
|
-
* type: "sell",
|
|
61
|
-
* startTime: 1716796800000,
|
|
62
|
-
* closeTime: 1716800400000,
|
|
63
|
-
* openPrice: 1.089,
|
|
64
|
-
* closePrice: 1.086,
|
|
65
|
-
* volume: 1,
|
|
66
|
-
* sl: 1.091,
|
|
67
|
-
* tp: 1.086,
|
|
68
|
-
* commission: 0,
|
|
69
|
-
* swap: 0,
|
|
70
|
-
* pnl: 30,
|
|
71
|
-
* };
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export type PastTrade = {
|
|
75
|
-
symbol: string;
|
|
76
|
-
type: TradeType;
|
|
77
|
-
startTime: number;
|
|
78
|
-
closeTime: number;
|
|
79
|
-
openPrice: number;
|
|
80
|
-
closePrice: number;
|
|
81
|
-
volume: number;
|
|
82
|
-
sl: number | null;
|
|
83
|
-
tp: number | null;
|
|
84
|
-
commission: number;
|
|
85
|
-
swap: number;
|
|
86
|
-
pnl: number;
|
|
87
|
-
};
|
|
88
53
|
export type TradeLayerEventsOptions = {
|
|
89
54
|
canvas: HTMLCanvasElement;
|
|
90
55
|
getHandleHitboxes: () => TradeHandleHitbox[];
|
|
@@ -168,7 +133,7 @@ export type PastTradeIndicatorPoint = {
|
|
|
168
133
|
time: number;
|
|
169
134
|
};
|
|
170
135
|
export type PastTradeIndicatorRenderState = {
|
|
171
|
-
trade:
|
|
136
|
+
trade: ClosedTrade;
|
|
172
137
|
start: PastTradeIndicatorPoint;
|
|
173
138
|
close: PastTradeIndicatorPoint;
|
|
174
139
|
arrowWidth: number;
|
|
@@ -243,7 +208,7 @@ export type DrawHandleSectionsOptions = {
|
|
|
243
208
|
export type DrawPastTradeArrowOptions = {
|
|
244
209
|
x: number;
|
|
245
210
|
y: number;
|
|
246
|
-
type:
|
|
211
|
+
type: TradeDirection;
|
|
247
212
|
width: number;
|
|
248
213
|
height: number;
|
|
249
214
|
config: PastTradeIndicatorArrowConfig;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Shape, ShapeAddedPayload, ShapeModifiedPayload, ShapeSelectedPayload, ShapeToolType } from '../canvas/layers/ShapesLayer/ShapesLayer.types';
|
|
2
|
-
import { PastTrade } from '../canvas/layers/TradeLayer/TradeLayer.types';
|
|
3
2
|
import { ChartConfig } from '../config/chartConfig.types';
|
|
4
3
|
import { Candle } from '../models/Candle.types';
|
|
5
|
-
import { OpenTrade } from '../models/Trade.types';
|
|
4
|
+
import { ClosedTrade, OpenTrade } from '../models/Trade.types';
|
|
6
5
|
import { DeepPartial } from './utils/deepPartial.types';
|
|
7
6
|
/**
|
|
8
7
|
* Payload emitted when the user commits a stop-loss or take-profit change.
|
|
@@ -117,10 +116,10 @@ export type ChartControllerProps = {
|
|
|
117
116
|
*
|
|
118
117
|
* @example
|
|
119
118
|
* ```ts
|
|
120
|
-
* pastTrades: [{ symbol: "EURUSD", type: "sell",
|
|
119
|
+
* pastTrades: [{ ticket: 101245, symbol: "EURUSD", type: "sell", openTime: 1716796800000, openPrice: 1.089, closeTime: 1716800400000, closePrice: 1.086, volume: 1, sl: 1.091, tp: 1.086, commission: 0, swap: 0, pnl: 30, status: "closed" }]
|
|
121
120
|
* ```
|
|
122
121
|
*/
|
|
123
|
-
pastTrades:
|
|
122
|
+
pastTrades: ClosedTrade[];
|
|
124
123
|
/**
|
|
125
124
|
* Parent-owned shapes rendered and edited by the chart.
|
|
126
125
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { PartialShapeConfig, Shape, ShapeAddedPayload, ShapeId, ShapeModifiedPayload, ShapeSelectedPayload, ShapeToolType, ShapeType, ShapeVertex, } from './canvas/layers/ShapesLayer/ShapesLayer.types';
|
|
2
|
-
export type {
|
|
2
|
+
export type { TradeHandleType, TradeProtectionHandleType, } from './canvas/layers/TradeLayer/TradeLayer.types';
|
|
3
3
|
export type { ChartControllerProps, PreviousDay, TradeModifyPayload, } from './chart/ChartController.types';
|
|
4
4
|
export type { DeepPartial } from './chart/utils/deepPartial.types';
|
|
5
5
|
export type { CanvasPoint } from './chart/utils/getCanvasPoint.types';
|
|
@@ -8,7 +8,7 @@ export type { ChartConfig, PreviousDayHighLowConfig } from './config/chartConfig
|
|
|
8
8
|
export type { Candle } from './models/Candle.types';
|
|
9
9
|
export type { ChartViewport } from './models/ChartViewport.types';
|
|
10
10
|
export type { Point2D } from './models/Point.types';
|
|
11
|
-
export type { BaseTrade, ClosedTrade, OpenTrade,
|
|
11
|
+
export type { BaseTrade, ClosedTrade, OpenTrade, TradeDirection } from './models/Trade.types';
|
|
12
12
|
export type { VisibleRange } from './models/VisibleRange.types';
|
|
13
13
|
export { TradingReload } from './react/TradingReload';
|
|
14
14
|
export type { TradingReloadHandle, TradingReloadProps } from './react/TradingReload.types';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @example `"buy"`
|
|
5
5
|
*/
|
|
6
|
-
export type
|
|
6
|
+
export type TradeDirection = "buy" | "sell";
|
|
7
7
|
/**
|
|
8
8
|
* Shared trade fields used by open and closed trade records.
|
|
9
9
|
*
|
|
@@ -54,7 +54,7 @@ export type BaseTrade = {
|
|
|
54
54
|
*
|
|
55
55
|
* @example `"buy"`
|
|
56
56
|
*/
|
|
57
|
-
type:
|
|
57
|
+
type: TradeDirection;
|
|
58
58
|
/** Trade open time in milliseconds UTC.
|
|
59
59
|
*
|
|
60
60
|
* @example `1716883200000`
|
|
@@ -2527,7 +2527,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2527
2527
|
}
|
|
2528
2528
|
getPastTradeIndicatorRenderState(t) {
|
|
2529
2529
|
if (!this.viewport) return null;
|
|
2530
|
-
const e = this.getTimeX(t.
|
|
2530
|
+
const e = this.getTimeX(t.openTime), i = this.getTimeX(t.closeTime);
|
|
2531
2531
|
if (e === null || i === null) return null;
|
|
2532
2532
|
const r = this.getPriceY(t.openPrice, this.viewport), s = this.getPriceY(t.closePrice, this.viewport), n = c.pastTradeIndicators.arrow, a = n.width, o = n.height;
|
|
2533
2533
|
return {
|
|
@@ -2535,7 +2535,7 @@ var U = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID(
|
|
|
2535
2535
|
start: {
|
|
2536
2536
|
x: e,
|
|
2537
2537
|
y: r,
|
|
2538
|
-
time: t.
|
|
2538
|
+
time: t.openTime,
|
|
2539
2539
|
price: t.openPrice
|
|
2540
2540
|
},
|
|
2541
2541
|
close: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pradeepjadhav/trading-reload-chart",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A React canvas-based trading chart library with candles, volume, drawing tools, and trade overlays.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"trading",
|
|
@@ -71,4 +71,4 @@
|
|
|
71
71
|
"main": "./dist/trading-reload-chart.js",
|
|
72
72
|
"module": "./dist/trading-reload-chart.js",
|
|
73
73
|
"types": "./dist/index.d.ts"
|
|
74
|
-
}
|
|
74
|
+
}
|