-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1674 from tradingview/curve-charts
Add Yield Curve and Options Chart Types, Up/Down Markers Plugin
- Loading branch information
Showing
69 changed files
with
2,536 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ | |
"output": { | ||
"sortNodes": true, | ||
"respectPreserveConstEnum": true | ||
} | ||
}, | ||
"failOnClass": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { DeepPartial } from '../helpers/strict-type-checks'; | ||
|
||
import { HorzScaleBehaviorPrice } from '../model/horz-scale-behavior-price/horz-scale-behaviour-price'; | ||
import { PriceChartOptions } from '../model/horz-scale-behavior-price/options'; | ||
|
||
import { createChartEx } from './create-chart'; | ||
import { IChartApiBase } from './ichart-api'; | ||
|
||
/** | ||
* Creates an 'options' chart with price values on the horizontal scale. | ||
* | ||
* This function is used to create a specialized chart type where the horizontal scale | ||
* represents price values instead of time. It's particularly useful for visualizing | ||
* option chains, price distributions, or any data where price is the primary x-axis metric. | ||
* | ||
* @param container - The DOM element or its id where the chart will be rendered. | ||
* @param options - Optional configuration options for the price chart. | ||
* @returns An instance of IChartApiBase configured for price-based horizontal scaling. | ||
*/ | ||
export function createOptionsChart( | ||
container: string | HTMLElement, | ||
options?: DeepPartial<PriceChartOptions> | ||
): IChartApiBase<number> { | ||
return createChartEx(container, new HorzScaleBehaviorPrice(), options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { DeepPartial } from '../helpers/strict-type-checks'; | ||
|
||
import { | ||
YieldCurveChartOptions, | ||
} from '../model/yield-curve-horz-scale-behavior/yield-curve-chart-options'; | ||
|
||
import { fetchHtmlElement } from './create-chart'; | ||
import { IYieldCurveChartApi } from './iyield-chart-api'; | ||
import { YieldChartApi } from './yield-chart-api'; | ||
|
||
/** | ||
* Creates a yield curve chart with the specified options. | ||
* | ||
* A yield curve chart differs from the default chart type | ||
* in the following ways: | ||
* - Horizontal scale is linearly spaced, and defined in monthly | ||
* time duration units | ||
* - Whitespace is ignored for the crosshair and grid lines | ||
* | ||
* @param container - ID of HTML element or element itself | ||
* @param options - The yield chart options. | ||
* @returns An interface to the created chart | ||
*/ | ||
export function createYieldCurveChart( | ||
container: string | HTMLElement, | ||
options?: DeepPartial<YieldCurveChartOptions> | ||
): IYieldCurveChartApi { | ||
const htmlElement = fetchHtmlElement(container); | ||
const chartApi = new YieldChartApi(htmlElement, options); | ||
return chartApi; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { LineData, WhitespaceData } from '../model/data-consumer'; | ||
import { SeriesPartialOptionsMap } from '../model/series-options'; | ||
import { SeriesDefinition } from '../model/series/series-def'; | ||
|
||
import { IChartApiBase } from './ichart-api'; | ||
import { ISeriesApi } from './iseries-api'; | ||
|
||
export type YieldCurveSeriesType = 'Area' | 'Line'; | ||
|
||
/** | ||
* The main interface of a single yield curve chart. | ||
*/ | ||
export interface IYieldCurveChartApi extends Omit<IChartApiBase<number>, 'addSeries'> { | ||
/** | ||
* Creates a series with specified parameters. | ||
* | ||
* Note that the Yield Curve chart only supports the Area and Line series types. | ||
* | ||
* @param definition - A series definition for either AreaSeries or LineSeries. | ||
* @param customOptions - Customization parameters of the series being created. | ||
* @param paneIndex - An index of the pane where the series should be created. | ||
* ```js | ||
* const series = chart.addSeries(LineSeries, { lineWidth: 2 }); | ||
* ``` | ||
*/ | ||
addSeries<T extends YieldCurveSeriesType>( | ||
definition: SeriesDefinition<T>, | ||
options?: SeriesPartialOptionsMap[T], | ||
paneIndex?: number | ||
): ISeriesApi<T, number, WhitespaceData<number> | LineData<number>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { YieldCurveOptions } from '../../model/yield-curve-horz-scale-behavior/yield-curve-chart-options'; | ||
|
||
export const yieldChartOptionsDefaults: YieldCurveOptions = { | ||
baseResolution: 1, | ||
minimumTimeRange: 120, | ||
startTimeRange: 0, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.