Coder Social home page Coder Social logo

Stock charts about highcharter HOT 9 CLOSED

jbkunst avatar jbkunst commented on June 21, 2024
Stock charts

from highcharter.

Comments (9)

jbkunst avatar jbkunst commented on June 21, 2024

Yep, it's in https://github.com/jbkunst/highcharter#future-work ;)!

from highcharter.

jbkunst avatar jbkunst commented on June 21, 2024

@TonyDIRL, @ziyadsaeed

Just an update. I'm just implemented a highstock parameter to get a Highstock instead of Highcharts. Works fine but it seems to be bugged the range selector and I need to do some test with real data via quantmod package.

You can check examples here: http://jkunst.com/highcharter/#time-series-highstock

from highcharter.

TonyDIRL avatar TonyDIRL commented on June 21, 2024

Great thank you.
So I see that it can handle ts objects

z <- ts(matrix(rnorm(300), 100, 1), start = c(1961, 1), frequency = 12)
highchart(highstock = TRUE) %>%  hc_add_series_ts2(z, color = "#26838E")

How would I pass it an xts object?

ProdData <- xts(runif(100,0,1), seq(as.POSIXct("2016-01-04 08:00:00"), as.POSIXct("2016-01-04 08:01:00"), length = 100),tz="GMT")

Also, is type="candlestick" from highstock exposed?

from highcharter.

jbkunst avatar jbkunst commented on June 21, 2024

@TonyDIRL

You pass an xts objects transforming the data, same as #8 (comment).

Theres no a function (like shorcut) to chart candlesticks in a quick way yet. Anyway, as same as all charts in highcharts/highstock you can replicate and make the options needes to plot. For example, if you want to chart this example http://www.highcharts.com/stock/demo/candlestick see the View options button.

Rebember, you can do everithing right know. The actual issue is you need transform your R data in jsonlike format (timestamps , in lists) to use them in highcharter. As I said you I'm working on shortcuts to chart quickly this objects ;)!

I can't run this example 100% because I have firewall issues in my work place. But something like this can work:

require("quantmod")

getSymbols("SPY", src = "google")

time <- time(SPY) %>% 
  zoo::as.Date() %>% 
  as.POSIXct() %>% 
  as.numeric() %>% 
  { 1000 * . }

spy <- SPY[,-5] %>% 
  as.data.frame() %>% 
  {cbind(time, .)} %>% 
  list.parse2()

highchart(highstock = TRUE) %>% 
  hc_add_series(type = "candlestick",
                data = spy,
                name = "SPY",
                dataGrouping = list(
                  units = list(
                    list("week", 1),
                    list("month", c(1,2,3,4,6))
                    )
                  )
                )

from highcharter.

TonyDIRL avatar TonyDIRL commented on June 21, 2024

Awesome, I confirm it works.

To be able to combine this with the highcharts boost module would make it very useful

from highcharter.

jbkunst avatar jbkunst commented on June 21, 2024

Yep it's the idea use that module! Need time to test 😄

from highcharter.

jbkunst avatar jbkunst commented on June 21, 2024

@TonyDIRL

http://jkunst.com/highcharter/#xts-objects-and-quantmod-package

Regards,

from highcharter.

TonyDIRL avatar TonyDIRL commented on June 21, 2024

Awesome, that is really great.

from highcharter.

jbkunst avatar jbkunst commented on June 21, 2024

I dont know if the module works on highsotck candlestick series (for example) But it was added:

http://rpubs.com/jbkunst/highcharter-no-boost
http://rpubs.com/jbkunst/highcharter-boost

Code:

n <- 50000

x <- sin(4*2*pi*seq(n)/n) + rnorm(n)/10

plot(x)

highchart() %>% 
  hc_title(text = sprintf("Drawin %s points", n)) %>% 
  hc_chart(zoomType = "x") %>% 
  hc_tooltip(valueDecimals = 2) %>% 
  hc_add_series(data = x, lineWidth = 0.5)

Sadly, I cant replicate de scatter example yet. With n = 4999 works, but with n = 5000 produce

highstock.js:252 Uncaught TypeError: Cannot read property 'length' of undefined
library("MASS")

# n <- 4999
n <- 5000

sigma <- matrix(c(10,3,3,2),2,2)
sigma

mvr <- round(mvrnorm(n, rep(0, 2), sigma), 4)

ds <- list.parse2(as.data.frame(mvr))

head(ds)

highchart() %>% 
  hc_xAxis(min = min(mvr[, 1]), max = max(mvr[, 1])) %>% 
  hc_yAxis(min = min(mvr[, 2]), max = max(mvr[, 2])) %>% 
  hc_chart(zoomType = "xy") %>% 
  hc_legend(enabled = FALSE) %>% 
  hc_add_series(data = ds,
                type = "scatter",
                color = 'rgba(152,0,67,0.9)',
                marker = list(radius =  0.8),
                tooltip = list(
                  followPointer = FALSE,
                  pointFormat = '[{point.x:.1f}, {point.y:.1f}]'
                )) %>% 
  hc_plotOptions(series =
                   list(
                     turboThreshold = 5000,
                     enableMouseTracking = FALSE
                   )
  )

This is related to issue #8

from highcharter.

Related Issues (20)

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.