@pradeepjadhav/trading-reload-chart 1.0.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/LICENSE +87 -0
- package/README.md +256 -0
- package/dist/canvas/layers/AxisLayerX/AxisLayerX.d.ts +27 -0
- package/dist/canvas/layers/AxisLayerX/AxisLayerX.helpers.d.ts +32 -0
- package/dist/canvas/layers/AxisLayerX/AxisLayerX.types.d.ts +10 -0
- package/dist/canvas/layers/AxisLayerY/AxisLayerY.d.ts +23 -0
- package/dist/canvas/layers/AxisLayerY/AxisLayerY.helpers.d.ts +4 -0
- package/dist/canvas/layers/AxisLayerY/AxisLayerY.types.d.ts +8 -0
- package/dist/canvas/layers/CrosshairLayer.d.ts +23 -0
- package/dist/canvas/layers/CrosshairLayer.types.d.ts +10 -0
- package/dist/canvas/layers/ExistingCandlesLayer.d.ts +107 -0
- package/dist/canvas/layers/ExistingCandlesLayer.types.d.ts +56 -0
- package/dist/canvas/layers/PdhPdlLayer.d.ts +24 -0
- package/dist/canvas/layers/ShapesLayer/FibRetracementShape.d.ts +28 -0
- package/dist/canvas/layers/ShapesLayer/LineShape.d.ts +27 -0
- package/dist/canvas/layers/ShapesLayer/PathShape.d.ts +29 -0
- package/dist/canvas/layers/ShapesLayer/RectangleShape.d.ts +28 -0
- package/dist/canvas/layers/ShapesLayer/ShapesLayer.d.ts +70 -0
- package/dist/canvas/layers/ShapesLayer/ShapesLayer.helpers.d.ts +47 -0
- package/dist/canvas/layers/ShapesLayer/ShapesLayer.types.d.ts +470 -0
- package/dist/canvas/layers/ShapesLayer/ShortLongPosition.d.ts +40 -0
- package/dist/canvas/layers/ShapesLayer/ShortLongPosition.types.d.ts +11 -0
- package/dist/canvas/layers/TradeLayer/TradeLayer.d.ts +152 -0
- package/dist/canvas/layers/TradeLayer/TradeLayer.helpers.d.ts +3 -0
- package/dist/canvas/layers/TradeLayer/TradeLayer.types.d.ts +261 -0
- package/dist/canvas/layers/TradeLayer/TradeLayerEvents.d.ts +68 -0
- package/dist/canvas/layers/TradeLayer/TradeLayerEvents.types.d.ts +12 -0
- package/dist/canvas/layers/VolumeLayer/VolumeLayer.d.ts +28 -0
- package/dist/canvas/layers/VolumeLayer/VolumeLayer.types.d.ts +25 -0
- package/dist/canvas/layers/helpers/LayerHelpers.d.ts +29 -0
- package/dist/chart/ChartController.d.ts +8 -0
- package/dist/chart/ChartController.types.d.ts +224 -0
- package/dist/chart/createChartDom.d.ts +2 -0
- package/dist/chart/createChartDom.types.d.ts +13 -0
- package/dist/chart/utils/deepPartial.types.d.ts +14 -0
- package/dist/chart/utils/getCanvasPoint.d.ts +2 -0
- package/dist/chart/utils/getCanvasPoint.types.d.ts +10 -0
- package/dist/chart/utils/mergeChartConfig.d.ts +3 -0
- package/dist/chart/utils/normalizeCandleTime.d.ts +2 -0
- package/dist/chart/utils/updateTradeTPSL.d.ts +8 -0
- package/dist/config/ChartShapeConfig/chartShapeConfig.d.ts +2 -0
- package/dist/config/chartConfig.d.ts +20 -0
- package/dist/config/chartConfig.types.d.ts +642 -0
- package/dist/config/colors.d.ts +19 -0
- package/dist/config/pairs.d.ts +3 -0
- package/dist/core/CoordinateSystem.d.ts +10 -0
- package/dist/favicon.svg +1 -0
- package/dist/helpers/math.d.ts +1 -0
- package/dist/icons.svg +24 -0
- package/dist/index.d.ts +14 -0
- package/dist/models/Candle.types.d.ts +67 -0
- package/dist/models/ChartViewport.types.d.ts +30 -0
- package/dist/models/Point.types.d.ts +12 -0
- package/dist/models/Trade.types.d.ts +151 -0
- package/dist/models/VisibleRange.types.d.ts +15 -0
- package/dist/react/TradingReload.d.ts +28 -0
- package/dist/react/TradingReload.types.d.ts +74 -0
- package/dist/trading-reload-chart.css +2 -0
- package/dist/trading-reload-chart.js +3503 -0
- package/package.json +74 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FibRetracementConfig, FibRetracementShapeData, ShapeCoordinateConverter, ShapeHandleHitbox, ShapePoint, ShapeVertex } from './ShapesLayer.types';
|
|
2
|
+
export declare class FibRetracementShape {
|
|
3
|
+
static defaultConfig: FibRetracementConfig;
|
|
4
|
+
static draw({ ctx, shape, converter, config, selected, hovered, }: {
|
|
5
|
+
ctx: CanvasRenderingContext2D;
|
|
6
|
+
shape: FibRetracementShapeData;
|
|
7
|
+
converter: ShapeCoordinateConverter;
|
|
8
|
+
config?: FibRetracementConfig;
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
hovered?: boolean;
|
|
11
|
+
}): void;
|
|
12
|
+
static drawDraft({ ctx, vertices, converter, config, }: {
|
|
13
|
+
ctx: CanvasRenderingContext2D;
|
|
14
|
+
vertices: [ShapeVertex, ShapeVertex];
|
|
15
|
+
converter: ShapeCoordinateConverter;
|
|
16
|
+
config?: FibRetracementConfig;
|
|
17
|
+
}): void;
|
|
18
|
+
static getHandles(shape: FibRetracementShapeData, converter: ShapeCoordinateConverter, config?: FibRetracementConfig): ShapeHandleHitbox[];
|
|
19
|
+
static hitTest({ point, shape, converter, tolerance, config, }: {
|
|
20
|
+
point: ShapePoint;
|
|
21
|
+
shape: FibRetracementShapeData;
|
|
22
|
+
converter: ShapeCoordinateConverter;
|
|
23
|
+
tolerance?: number;
|
|
24
|
+
config?: FibRetracementConfig;
|
|
25
|
+
}): boolean;
|
|
26
|
+
static move(shape: FibRetracementShapeData, delta: ShapeVertex): FibRetracementShapeData;
|
|
27
|
+
static resize(shape: FibRetracementShapeData, handleType: ShapeHandleHitbox["type"], vertex: ShapeVertex): FibRetracementShapeData;
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ShapeCoordinateConverter, CommonShapeConfig, ShapeHandleHitbox, ShapePoint, ShapeVertex, TrendlineShape } from './ShapesLayer.types';
|
|
2
|
+
export declare class LineShape {
|
|
3
|
+
static defaultConfig: CommonShapeConfig;
|
|
4
|
+
static draw({ ctx, shape, converter, config, selected, hovered, }: {
|
|
5
|
+
ctx: CanvasRenderingContext2D;
|
|
6
|
+
shape: TrendlineShape;
|
|
7
|
+
converter: ShapeCoordinateConverter;
|
|
8
|
+
config?: CommonShapeConfig;
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
hovered?: boolean;
|
|
11
|
+
}): void;
|
|
12
|
+
static drawDraft({ ctx, vertices, converter, config, }: {
|
|
13
|
+
ctx: CanvasRenderingContext2D;
|
|
14
|
+
vertices: [ShapeVertex, ShapeVertex];
|
|
15
|
+
converter: ShapeCoordinateConverter;
|
|
16
|
+
config?: CommonShapeConfig;
|
|
17
|
+
}): void;
|
|
18
|
+
static getHandles(shape: TrendlineShape, converter: ShapeCoordinateConverter, config?: CommonShapeConfig): ShapeHandleHitbox[];
|
|
19
|
+
static hitTest({ point, shape, converter, tolerance, }: {
|
|
20
|
+
point: ShapePoint;
|
|
21
|
+
shape: TrendlineShape;
|
|
22
|
+
converter: ShapeCoordinateConverter;
|
|
23
|
+
tolerance?: number;
|
|
24
|
+
}): boolean;
|
|
25
|
+
static move(shape: TrendlineShape, delta: ShapeVertex): TrendlineShape;
|
|
26
|
+
static resize(shape: TrendlineShape, handleType: ShapeHandleHitbox["type"], vertex: ShapeVertex): TrendlineShape;
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PathShapeData, ShapeCoordinateConverter, CommonShapeConfig, ShapeHandleHitbox, ShapePoint, ShapeVertex } from './ShapesLayer.types';
|
|
2
|
+
export declare class PathShape {
|
|
3
|
+
static defaultConfig: CommonShapeConfig;
|
|
4
|
+
static draw({ ctx, shape, converter, config, selected, hovered, }: {
|
|
5
|
+
ctx: CanvasRenderingContext2D;
|
|
6
|
+
shape: PathShapeData;
|
|
7
|
+
converter: ShapeCoordinateConverter;
|
|
8
|
+
config?: CommonShapeConfig;
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
hovered?: boolean;
|
|
11
|
+
}): void;
|
|
12
|
+
static drawDraft({ ctx, vertices, previewVertex, converter, config, }: {
|
|
13
|
+
ctx: CanvasRenderingContext2D;
|
|
14
|
+
vertices: ShapeVertex[];
|
|
15
|
+
previewVertex: ShapeVertex | null;
|
|
16
|
+
converter: ShapeCoordinateConverter;
|
|
17
|
+
config?: CommonShapeConfig;
|
|
18
|
+
}): void;
|
|
19
|
+
static getHandles(shape: PathShapeData, converter: ShapeCoordinateConverter, config?: CommonShapeConfig): ShapeHandleHitbox[];
|
|
20
|
+
static hitTest({ point, shape, converter, tolerance, }: {
|
|
21
|
+
point: ShapePoint;
|
|
22
|
+
shape: PathShapeData;
|
|
23
|
+
converter: ShapeCoordinateConverter;
|
|
24
|
+
tolerance?: number;
|
|
25
|
+
}): boolean;
|
|
26
|
+
static move(shape: PathShapeData, delta: ShapeVertex): PathShapeData;
|
|
27
|
+
static resize(shape: PathShapeData, handleIndex: number, vertex: ShapeVertex): PathShapeData;
|
|
28
|
+
private static drawEndArrow;
|
|
29
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RectangleShapeData, ShapeCoordinateConverter, ShapeHandleHitbox, ShapePoint, ShapeVertex, RectangleShapeConfig } from './ShapesLayer.types';
|
|
2
|
+
export declare class RectangleShape {
|
|
3
|
+
static defaultConfig: RectangleShapeConfig;
|
|
4
|
+
static draw({ ctx, shape, converter, config, selected, hovered, }: {
|
|
5
|
+
ctx: CanvasRenderingContext2D;
|
|
6
|
+
shape: RectangleShapeData;
|
|
7
|
+
converter: ShapeCoordinateConverter;
|
|
8
|
+
config?: RectangleShapeConfig;
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
hovered?: boolean;
|
|
11
|
+
}): void;
|
|
12
|
+
static drawDraft({ ctx, vertices, converter, config, }: {
|
|
13
|
+
ctx: CanvasRenderingContext2D;
|
|
14
|
+
vertices: [ShapeVertex, ShapeVertex];
|
|
15
|
+
converter: ShapeCoordinateConverter;
|
|
16
|
+
config?: RectangleShapeConfig;
|
|
17
|
+
}): void;
|
|
18
|
+
static getHandles(shape: RectangleShapeData, converter: ShapeCoordinateConverter, config?: RectangleShapeConfig): ShapeHandleHitbox[];
|
|
19
|
+
static hitTest({ point, shape, converter, tolerance, }: {
|
|
20
|
+
point: ShapePoint;
|
|
21
|
+
shape: RectangleShapeData;
|
|
22
|
+
converter: ShapeCoordinateConverter;
|
|
23
|
+
tolerance?: number;
|
|
24
|
+
}): boolean;
|
|
25
|
+
static move(shape: RectangleShapeData, delta: ShapeVertex): RectangleShapeData;
|
|
26
|
+
static resize(shape: RectangleShapeData, handleType: ShapeHandleHitbox["type"], vertex: ShapeVertex): RectangleShapeData;
|
|
27
|
+
private static drawText;
|
|
28
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Candle } from '../../../models/Candle.types';
|
|
2
|
+
import { ChartViewport } from '../../../models/ChartViewport.types';
|
|
3
|
+
import { PartialShapeConfig, Shape, ShapeConfig, ShapeHandleHitbox, ShapesLayerOptions, ShapeToolType } from './ShapesLayer.types';
|
|
4
|
+
export declare class ShapesLayer {
|
|
5
|
+
canvas: HTMLCanvasElement;
|
|
6
|
+
ctx: CanvasRenderingContext2D;
|
|
7
|
+
activeSymbol: string;
|
|
8
|
+
candles: Candle[];
|
|
9
|
+
viewport: ChartViewport | null;
|
|
10
|
+
shapes: Shape[];
|
|
11
|
+
activeTool: ShapeToolType | null;
|
|
12
|
+
config: ShapeConfig;
|
|
13
|
+
selectedShapeId: string | null;
|
|
14
|
+
hoveredShapeId: string | null;
|
|
15
|
+
handleHitboxes: ShapeHandleHitbox[];
|
|
16
|
+
private draft;
|
|
17
|
+
private dragState;
|
|
18
|
+
private onShapeAdded?;
|
|
19
|
+
private onShapeModified?;
|
|
20
|
+
private onShapeSelected?;
|
|
21
|
+
private onToolChange?;
|
|
22
|
+
constructor(options: ShapesLayerOptions);
|
|
23
|
+
setCandles(candles: Candle[]): void;
|
|
24
|
+
setViewport(viewport: ChartViewport): void;
|
|
25
|
+
setShapes(shapes: Shape[]): void;
|
|
26
|
+
setConfig(config?: PartialShapeConfig): void;
|
|
27
|
+
setActiveTool(tool: ShapeToolType | null): void;
|
|
28
|
+
clearHoverState(): void;
|
|
29
|
+
render(): void;
|
|
30
|
+
handlePointerEvent(event: PointerEvent | MouseEvent): boolean;
|
|
31
|
+
handleKeyboardEvent(event: KeyboardEvent): boolean;
|
|
32
|
+
private handlePointerDown;
|
|
33
|
+
private handlePointerMove;
|
|
34
|
+
private handlePointerUp;
|
|
35
|
+
private handleContextMenu;
|
|
36
|
+
private handleToolPointerDown;
|
|
37
|
+
private handleTwoPointDraft;
|
|
38
|
+
private handlePathDraft;
|
|
39
|
+
private completePathDraft;
|
|
40
|
+
private addPositionShape;
|
|
41
|
+
private updateDraftPreview;
|
|
42
|
+
private addShape;
|
|
43
|
+
private emitShapeModified;
|
|
44
|
+
private applyDrag;
|
|
45
|
+
private moveShape;
|
|
46
|
+
private resizeShape;
|
|
47
|
+
private drawShape;
|
|
48
|
+
private drawDraft;
|
|
49
|
+
private rebuildHandleHitboxes;
|
|
50
|
+
private getShapeHandles;
|
|
51
|
+
private findHandleAtPoint;
|
|
52
|
+
private findHandleAtPointForShape;
|
|
53
|
+
private findShapeAtPoint;
|
|
54
|
+
private isShapeHit;
|
|
55
|
+
private setSelectedShapeId;
|
|
56
|
+
private createShapeSelectedPayload;
|
|
57
|
+
private getTrendlineConfig;
|
|
58
|
+
private getRectangleConfig;
|
|
59
|
+
private getPathConfig;
|
|
60
|
+
private getFibRetracementConfig;
|
|
61
|
+
private getPositionConfig;
|
|
62
|
+
private setActiveToolAndEmit;
|
|
63
|
+
private getConverter;
|
|
64
|
+
private getXForTime;
|
|
65
|
+
private getTimeForX;
|
|
66
|
+
private getYForPrice;
|
|
67
|
+
private getPriceForY;
|
|
68
|
+
private getCandleStepWidth;
|
|
69
|
+
private mergeConfig;
|
|
70
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Candle } from '../../../models/Candle.types';
|
|
2
|
+
import { FibLevelValue, Shape, ShapeBoundingBox, ShapeCoordinateConverter, CommonShapeConfig, ShapeHandleHitbox, ShapeLineStyle, ShapePoint, ShapeVertex } from './ShapesLayer.types';
|
|
3
|
+
export declare const SHAPE_HIT_TOLERANCE = 8;
|
|
4
|
+
export declare const SHAPE_HANDLE_RADIUS = 5;
|
|
5
|
+
export declare const generateShapeId: () => string;
|
|
6
|
+
export declare const getCanvasPoint: (canvas: HTMLCanvasElement, event: PointerEvent | MouseEvent) => ShapePoint;
|
|
7
|
+
export declare const createVertexFromPoint: (point: ShapePoint, converter: ShapeCoordinateConverter) => ShapeVertex;
|
|
8
|
+
export declare const vertexToPoint: (vertex: ShapeVertex, converter: ShapeCoordinateConverter) => ShapePoint;
|
|
9
|
+
export declare const getBoundingBoxFromPoints: (pointA: ShapePoint, pointB: ShapePoint) => ShapeBoundingBox;
|
|
10
|
+
export declare const getBoundingBoxFromVertices: (vertexA: ShapeVertex, vertexB: ShapeVertex, converter: ShapeCoordinateConverter) => ShapeBoundingBox;
|
|
11
|
+
export declare const getBoundingBoxFromShape: (shape: Shape, converter: ShapeCoordinateConverter) => ShapeBoundingBox;
|
|
12
|
+
export declare const getDistance: (pointA: ShapePoint, pointB: ShapePoint) => number;
|
|
13
|
+
export declare const getDistanceToLineSegment: (point: ShapePoint, lineStart: ShapePoint, lineEnd: ShapePoint) => number;
|
|
14
|
+
export declare const isPointInsideBoundingBox: (point: ShapePoint, box: ShapeBoundingBox, padding?: number) => boolean;
|
|
15
|
+
export declare const isPointNearBoundingBoxBorder: (point: ShapePoint, box: ShapeBoundingBox, tolerance?: number) => boolean;
|
|
16
|
+
export declare const createHandleHitbox: ({ shapeId, type, point, radius, cursor, index, }: {
|
|
17
|
+
shapeId: string;
|
|
18
|
+
type: ShapeHandleHitbox["type"];
|
|
19
|
+
point: ShapePoint;
|
|
20
|
+
radius?: number;
|
|
21
|
+
cursor?: string;
|
|
22
|
+
index?: number;
|
|
23
|
+
}) => ShapeHandleHitbox;
|
|
24
|
+
export declare const isPointInsideHandle: (point: ShapePoint, handle: ShapeHandleHitbox) => boolean;
|
|
25
|
+
export declare const getLineDash: (lineStyle: ShapeLineStyle, lineWidth?: number) => number[];
|
|
26
|
+
export declare const applyStrokeStyle: (ctx: CanvasRenderingContext2D, style: Pick<CommonShapeConfig, "lineColor" | "lineOpacity" | "lineWidth" | "lineStyle">, lineWidthOverride?: number) => void;
|
|
27
|
+
export declare const applyFillStyle: (ctx: CanvasRenderingContext2D, fillColor: string | undefined, fillOpacity: number | undefined) => boolean;
|
|
28
|
+
export declare const resetCanvasLineDash: (ctx: CanvasRenderingContext2D) => void;
|
|
29
|
+
export declare const drawHandle: (ctx: CanvasRenderingContext2D, handle: ShapeHandleHitbox, options?: {
|
|
30
|
+
fillColor: string;
|
|
31
|
+
borderColor: string;
|
|
32
|
+
borderThickness: number;
|
|
33
|
+
}) => void;
|
|
34
|
+
export declare const drawHandles: (ctx: CanvasRenderingContext2D, handles: ShapeHandleHitbox[], options?: {
|
|
35
|
+
fillColor: string;
|
|
36
|
+
borderColor: string;
|
|
37
|
+
borderThickness: number;
|
|
38
|
+
}) => void;
|
|
39
|
+
export declare const withOpacity: (color: string, opacity: number) => string;
|
|
40
|
+
export declare const hexToRgba: (hex: string, opacity: number) => string;
|
|
41
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
42
|
+
export declare const getFibLevelPrice: (startPrice: number, endPrice: number, level: FibLevelValue) => number;
|
|
43
|
+
export declare const getNearestCandleIndexByTime: (candles: Candle[], time: number) => number;
|
|
44
|
+
export declare const getAverageCandleTimeStep: (candles: Candle[]) => number;
|
|
45
|
+
export declare const getFutureCandleTime: (candles: Candle[], startTime: number, candleCount: number) => number;
|
|
46
|
+
export declare const getCursorForHandle: (handleType: ShapeHandleHitbox["type"]) => string;
|
|
47
|
+
export declare const hasPrimaryButton: (event: PointerEvent | MouseEvent) => boolean;
|