create an OHLC series from ticker data using R

前端 未结 3 1460
梦如初夏
梦如初夏 2020-12-19 08:08

This seems like it should be a common thing, but all my searching comes up with half or unfinished answers.

I have a set of data in a csv. But the data is set up so

3条回答
  •  醉酒成梦
    2020-12-19 08:41

    Azoo series can be reclassed as OHLC with class(data) <- c('zoo', 'OHLC', 'some other class').

    From ?quantmod::quantmod.OHLC:

    ‘quantmod.OHLC’ is actually just a renaming of an object of class ‘zoo’, with the convention of NAME.Open, NAME.High, ... for the column names.

    If you don't have the volume column, then there is no code you can write that will add that data. It seems like you just have a series of intraday prices. You can still class these as zoo or xts and do time series analysis. If you want to reduce the resolution of your data, you could always scan over each day and use the functions first, max, min, last to get your O, H, L, C.

提交回复
热议问题