@kumo-charts/core/volume-profile
API 参考由源码注释生成,只有英文。
import { … } from '@kumo-charts/core/volume-profile';
Functions
checkVolumeProfileOptionsfunction源码
function checkVolumeProfileOptions(
options: VolumeProfileOptions,
label: string
): Required<VolumeProfileOptions>
The rows and the value area of options as computeVolumeProfile takes them, checked,
with their defaults; label names the options in errors. Other fields are left to the caller,
for a profile of its own, such as one of trades.
computeVolumeProfilefunction源码
function computeVolumeProfile(
bars: BarsView | readonly BarInput[],
from: number,
to: number,
options: VolumeProfileOptions = {}
): VolumeProfileData | null
The volume profile of the bars [from, to): a chart's, such as chart.data.source, or bars
of your own, checked as chart.data.set() checks them. Each bar's volume is spread evenly over
its range from low to high, so finer bars give a sharper profile. null when the bars hold no
volume. Runs anywhere, Node included.
fixedRangeVolumeProfilefunction源码
function fixedRangeVolumeProfile(
options: FixedRangeVolumeProfileOptions = {}
): DrawingTypeDefinition<Anchors<2>>
The fixed range volume profile, fixed-range-volume-profile: the volume traded at each price
of the bars from the first anchor's through the second's, computed from the source bars that a
running replay has revealed. The anchors set the time range, the bars the price range; without
volume there, the frame spans the anchors' prices. The rows are painted under the bars, and the
style's color paints the frame. Give it to the drawings module, as
drawings([...allDrawings, fixedRangeVolumeProfile()]); the options hold for every drawing of
the type.
pointOfControlfunction源码
function pointOfControl(volumes: ArrayLike<number>): number
The point of control of the volumes of rows, from the lowest price up: the row with the most volume. Of rows with as much, the one nearest the middle, and of two as near, the upper one.
valueAreaOffunction源码
function valueAreaOf(
volumes: ArrayLike<number>,
poc: number,
share = DEFAULT_VALUE_AREA
): { low: number; high: number }
The value area of the volumes of rows, from the lowest price up, around the point of control
poc: from it, the row above or the row below the area, whichever has more volume (the nearer
one to poc on a tie, the upper one when as near), joins the area while the area stays within
share of the whole volume, and it stops at the first that would take it past. Gives the
indices of its first and last row.
volumeProfileGridfunction源码
function volumeProfileGrid(
low: number,
high: number,
rows: number
): VolumeProfileGrid | null
The rows a volume profile divides the prices from low to high into, as
computeVolumeProfile divides those of bars: rows of one height, from 1 to 1000. For a
profile of your own, such as one of trades, to match the chart's. null without a range.
volumeProfilesfunction源码
function volumeProfiles(): VolumeProfilesModule
The volume profiles module: chart.volumeProfiles, the volume traded at each price of the
bars in view or of each trading day, under the bars of the main pane. The profiles are kept in
the chart's state.
Interfaces
FixedRangeVolumeProfileOptionsinterface源码
interface FixedRangeVolumeProfileOptions extends VolumeProfileOptions
Options of fixedRangeVolumeProfile, for every drawing of the type.
width?: numberLength of the row with the most volume, as a share of the range's width. Default 0.6.
upColor?: stringVolume of the bars that closed at or above their open. Default: the theme's up.
downColor?: stringVolume of the bars that closed below their open. Default: the theme's down.
pocColor?: stringThe line of the point of control. Default: the first color of the theme's palette.
VolumeProfileinterface源码
interface VolumeProfile
A volume profile on the chart, as chart.volumeProfiles gives it.
readonly id: stringreadonly mode: VolumeProfileModereadonly rows: numberreadonly valueArea: numberreadonly width: number | nullAs given, or null for the default of the mode.
readonly placement: VolumeProfilePlacementreadonly upColor: string | nullAs given, or null for the theme's color.
readonly downColor: string | nullreadonly pocColor: string | nullreadonly visible: booleanVolumeProfileDatainterface源码
interface VolumeProfileData
The volume traded at each price of a run of bars, as computeVolumeProfile gives it.
readonly rows: readonly VolumeProfileRow[]Rows of one height, from the lowest price to the highest.
readonly total: numberThe volume of every row together.
readonly poc: numberIndex of the row with the most volume, the point of control, as pointOfControl.
readonly valueArea: { readonly low: number; readonly high: number }Indices of the first and the last row of the value area, as valueAreaOf.
VolumeProfileGridinterface源码
interface VolumeProfileGrid
The price rows of a volume profile: count rows step high, from bottom up.
readonly bottom: numberreadonly step: numberreadonly count: numberVolumeProfileInputinterface源码
interface VolumeProfileInput
id?: stringGenerated when omitted.
mode: VolumeProfileModerows?: numberNumber of price rows, from 1 to 1000. Default 24.
valueArea?: numberShare of the volume in the value area, above 0 and at most 1. Default 0.7.
width?: numberLength of the row with the most volume, above 0 and at most 1: a share of the plot's width
(visible, default 0.25) or of the trading day's (session, default 0.7).
placement?: VolumeProfilePlacementThe edge a profile of the bars in view grows from. Default right.
upColor?: stringVolume of the bars that closed at or above their open. Default: the theme's up.
downColor?: stringVolume of the bars that closed below their open. Default: the theme's down.
pocColor?: stringThe line of the point of control. Default: the first color of the theme's palette.
visible?: booleanDefault true.
VolumeProfileOptionsinterface源码
interface VolumeProfileOptions
Options of computeVolumeProfile.
rows?: numberNumber of price rows, from 1 to 1000. Default 24.
valueArea?: numberShare of the volume in the value area, above 0 and at most 1. Default 0.7.
VolumeProfileRowinterface源码
interface VolumeProfileRow
One price row of a volume profile: the volume traded between low and high.
readonly low: numberreadonly high: numberreadonly up: numberVolume of the bars that closed at or above their open.
readonly down: numberVolume of the bars that closed below their open.
VolumeProfilesApiinterface源码
interface VolumeProfilesApi
Volume profiles under the bars of the main pane: of the bars in view, or of each trading day. They are computed from the source bars, so a daily chart of 1-minute bars puts each day's volume at the prices it traded at, and only from those a running replay has revealed.
set(inputs: readonly VolumeProfileInput[]): voidReplaces every profile. An invalid input throws and changes nothing.
add(input: VolumeProfileInput): stringAdds a profile and returns its id: the one it has, or one the chart numbers for it.
update(id: string, patch: Partial<Omit<VolumeProfileInput, 'id'>>): voidChanges a profile; what the patch leaves out stays. Throws for an unknown id.
remove(id: string): voidThrows for an unknown id.
clear(): voidRemoves every profile.
get(id: string): VolumeProfile | nullThe profile of an id, or null.
list(): VolumeProfile[]Every profile, in the order they paint.
Types
VolumeProfileModetype源码
type VolumeProfileMode = 'visible' | 'session'
visible: one profile of the bars in view, along an edge of the plot.session: one profile for each trading day of the chart's calendar, from the start of the day.
VolumeProfilePlacementtype源码
type VolumeProfilePlacement = 'left' | 'right'
The edge of the plot a profile of the bars in view grows from.
VolumeProfilesModuletype源码
type VolumeProfilesModule = ChartModule<{
readonly api: { readonly volumeProfiles: VolumeProfilesApi };
readonly state: { readonly volumeProfiles: readonly VolumeProfileInput[] };
}>