mango-v4-ui/utils/kLineChart.ts

58 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-03-04 21:48:09 -08:00
import { SUPPORTED_RESOLUTIONS as SUPPORTED_SPOT_RESOLUTIONS } from 'apis/datafeed'
2023-01-02 11:50:03 -08:00
2022-12-05 15:54:47 -08:00
export const ONE_HOUR_MINS = 60
export const ONE_MINUTE_SECONDS = 60
export const ONE_HOUR_SECONDS = ONE_HOUR_MINS * ONE_MINUTE_SECONDS
export const ONE_DAY_SECONDS = ONE_HOUR_SECONDS * 24
export type BASE_CHART_QUERY = {
2022-12-21 03:21:04 -08:00
address: string
2023-07-22 13:44:43 -07:00
type: (typeof SUPPORTED_SPOT_RESOLUTIONS)[number]
2022-12-21 03:21:04 -08:00
time_to: number
2022-12-05 15:54:47 -08:00
}
export type CHART_QUERY = BASE_CHART_QUERY & {
2022-12-21 03:21:04 -08:00
time_from: number
2022-12-05 15:54:47 -08:00
}
2023-01-02 11:50:03 -08:00
2022-12-05 15:54:47 -08:00
//Translate values that api accepts to chart seconds
export const RES_NAME_TO_RES_VAL: {
[key: string]: {
2023-07-22 13:44:43 -07:00
val: (typeof SUPPORTED_SPOT_RESOLUTIONS)[number]
2022-12-05 15:54:47 -08:00
seconds: number
}
} = {
2023-01-02 11:50:03 -08:00
'1m': { val: '1', seconds: ONE_MINUTE_SECONDS },
'5m': { val: '5', seconds: 5 * ONE_MINUTE_SECONDS },
2022-12-05 15:54:47 -08:00
'30m': {
2023-01-02 11:50:03 -08:00
val: `30`,
2022-12-05 15:54:47 -08:00
seconds: (ONE_HOUR_MINS / 2) * ONE_MINUTE_SECONDS,
},
2023-01-02 11:50:03 -08:00
'1H': { val: `60`, seconds: ONE_HOUR_SECONDS },
'2H': { val: `120`, seconds: ONE_HOUR_SECONDS * 2 },
'4H': { val: `240`, seconds: ONE_HOUR_SECONDS * 4 },
2022-12-05 15:54:47 -08:00
'1D': { val: '1D', seconds: 24 * ONE_HOUR_SECONDS },
}
export const mainTechnicalIndicatorTypes = [
'MA',
'EMA',
'SAR',
'BOLL',
'SMA',
'BBI',
'TRIX',
]
export const subTechnicalIndicatorTypes = [
'VOL',
'MACD',
'RSI',
'KDJ',
'OBV',
'CCI',
'WR',
'DMI',
'MTM',
'EMV',
]
export const DEFAULT_SUB_INDICATOR = 'VOL'
2022-12-08 06:11:09 -08:00
export const DEFAULT_MAIN_INDICATORS = ['EMA']
2022-12-05 15:54:47 -08:00
export const MAIN_INDICATOR_CLASS = 'candle_pane'