Giter Site home page Giter Site logo

klinecharts / pro Goto Github PK

View Code? Open in Web Editor NEW
139.0 139.0 69.0 1.25 MB

Financial chart built out of the box based on KLineChart.

Home Page: https://pro.klinecharts.com/

License: Apache License 2.0

JavaScript 0.09% TypeScript 92.39% Less 7.10% CSS 0.42%

pro's People

Contributors

liihuu avatar mawsyh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pro's Issues

How to use custom indicators?

I'm using KLineChartPro for my project and would like to add custom indicators that are not included in the built-in list of available indicators. I've searched the documentation, but I couldn't find any information on how to implement and register custom indicators.

Could you please provide a guide or an example of how to create and use custom indicators with KLineChartPro?

Saving Indicators

Hello @liihuu,

I want to thank you for your excellent work on this library, which has greatly aided my chart analysis.
However, I couldn't find documentation on saving and reloading later chart indicators, such as Fibonacci retracements.

Best regards

bug

请求场景:
周期:10分钟
K线总数:240根
BUG:
当总数小于500时会疯狂调用接口,且把多次调用的数据叠加在图上

源DEMO:
ChartProComponent.tsx
const get = async () => {
const [from, to] = adjustFromTo(p, new Date().getTime(), 500)
const kLineDataList = await props.datafeed.getHistoryKLineData(s, p, from, to)
widget?.applyNewData(kLineDataList, kLineDataList.length > 0)
props.datafeed.subscribe(s, p, data => {
widget?.updateData(data)
})
loading = false
setLoadingVisible(false)
}
此处应改判断查得的数据是否大于等于500

无法运行polygon数据源示例

https://pro.klinecharts.com/getting-started.html

klinecharts-pro.umd.js:1 
        
       Uncaught TypeError: Cannot read properties of undefined (reading 'registerOverlay')
    at klinecharts-pro.umd.js:1:175612
    at Array.forEach (<anonymous>)
    at klinecharts-pro.umd.js:1:175598
    at klinecharts-pro.umd.js:1:212
    at klinecharts-pro.umd.js:1:251
(匿名) @ klinecharts-pro.umd.js:1
(匿名) @ klinecharts-pro.umd.js:1
(匿名) @ klinecharts-pro.umd.js:1
(匿名) @ klinecharts-pro.umd.js:1
pro.html:23 
        
       Uncaught TypeError: klinechartspro.DefaultDatafeed is not a constructor
    at pro.html:23:15

KLineChart-pro Error Updater

Hello
Thanks for your program

Why am I seeing this error and how should I resolve the issue?

node --version
v14.21.3

npm run build

@klinecharts/[email protected] build /home/mas/nodejs/chart/KLineChart-pro-main
npm run build-core && npm run build-dts

@klinecharts/[email protected] build-core /home/mas/nodejs/chart/KLineChart-pro-main
tsc && vite build

node_modules/klinecharts/types/index.d.ts:743:2 - error TS2416: Property 'update' in type 'Widget' is not assignable to the same property in base type 'Updater'.
Type '(level: UpdateLevel) => void' is not assignable to type '(level?: UpdateLevel | undefined) => void'.
Types of parameters 'level' and 'level' are incompatible.
Type 'UpdateLevel | undefined' is not assignable to type 'UpdateLevel'.
Type 'undefined' is not assignable to type 'UpdateLevel'.

743 update(level: UpdateLevel): void;
~~~~~~

Found 1 error in node_modules/klinecharts/types/index.d.ts:743

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @klinecharts/[email protected] build-core: tsc && vite build
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @klinecharts/[email protected] build-core script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/mas/.npm/_logs/2023-09-03T08_17_41_817Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @klinecharts/[email protected] build: npm run build-core && npm run build-dts
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @klinecharts/[email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我的图表一直是第一次获取到的数据在不断重复

import {getStockRecentKMinuteRT, getStockKRT} from '@/api/stockrt'
import {parseTime} from '@/utils/utils'

export default class CustomDatafeed {
  /**
   * 模糊搜索标的
   * 在搜索框输入的时候触发
   * 返回标的信息数组
   */
  searchSymbols(search) {
    // 根据模糊字段远程拉取标的数据
    console.log(search)
  }

  /**
   * 获取历史k线数据
   * 当标的和周期发生变化的时候触发
   *
   * 返回标的k线数据数组
   */
  getHistoryKLineData(symbol, period, from, to) {
    // 完成数据请求
    console.log(symbol, period, from, to, parseTime(from, '{y}-{m}-{d} {h}:{i}:{s}'), parseTime(to, '{y}-{m}-{d} {h}:{i}:{s}'))
    let api = getStockRecentKMinuteRT
    const params = {
      code: symbol.ticker,
      period: `${period.multiplier}`,
      start_date: parseTime(from, '{y}-{m}-{d} {h}:{i}:{s}'),
      end_date:  parseTime(to, '{y}-{m}-{d} {h}:{i}:{s}')
    }
    if (period.timespan != 'minute') {
      api = getStockKRT
      params.period = period.timespan == 'day' ? 'daily': (period.timespan == 'week' ? 'weekly': 'monthly')
      params.start_date = parseTime(from, '{y}{m}{d}')
      params.end_date = parseTime(to, '{y}{m}{d}')
    }
    return new Promise((resolve, reject) => {
        api(params).then((res) => {
            const _its = res.data.items || []
            const _items = _its.map(item => {
                return {
                    timestamp: (new Date(item.time||item.date)).getTime(),
                    open: item.open,
                    close: item.close,
                    high: item.highest,
                    low: item.lowest,
                    volume: item.volume,
                    turnover: item.turnover || 1
                }
            })
            resolve(_items)
        }).catch(() => {
            resolve([])
        })
    })
  }

  /**
   * 订阅标的在某个周期的实时数据
   * 当标的和周期发生变化的时候触发
   *
   * 通过callback告知图表接收数据
   */
  subscribe(symbol, period, callback) {
    // 完成ws订阅或者http轮询
    console.log('subscribe', symbol, period, callback)
  }

  /**
   * 取消订阅标的在某个周期的实时数据
   * 当标的和周期发生变化的时候触发
   *
   */
  unsubscribe(symbol, period) {
    // 完成ws订阅取消或者http轮询取消
    console.log('unsubscribe', symbol, period)
  }
}

当我拖动图表的时候,我能看到getHistoryKLineData被触发,然后通过新的from/to来获取到数据,我看了下接口请求的参数和返回的数据都是正常。但是图表里面显示的一直都是第一次调用getHistoryKLineData时的数据的重复显示!

使用customdata时有bug

async getHistoryKLineData(symbol, period, from, to)选择日线没有问题,切换到小时和分钟线时候的from和to 会没有值 NaN
屏幕截图 2024-03-30 154047

Main and sub indicator deletion does not work correctly

@liihuu
image

I am looking at adding and deleting indicators as in this example from Kline, but the indicators other than the indicator I want to delete are deleted. Here is my example

   this.paneId = this.kLineChart.createIndicator(this.selectedVolume);

    addIndicator(obj) {
      if(obj.type === 'main') {
        this.kLineChart.createIndicator(obj.value, true, { id: 'candle_pane' })
      } else {
        this.kLineChart.createIndicator(obj.value)
      }
    },
    removeIndicator(obj) {
      console.log('obj remove', obj)
      if(obj.type === 'main') {
        this.kLineChart.removeIndicator('candle_pane', obj.val);
      } else {
        this.kLineChart.removeIndicator(this.paneId,obj.val);
      }

When I delete the main indicator, all main indicators are deleted. In Sub indicator, indicators other than the value I first set are not deleted.

移动端支持

图表在移动端下会有一些问题

  1. 触控交互
  2. 样式(如超出屏幕、显示不全等)

有没有计划兼容一下移动端,可以阉割一些功能

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.