Quantcast

data manipulation to for quantmod function

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

data manipulation to for quantmod function

KTD Services
I need some help with data manipulation so I can use quantmod.

I have a data frame with three columns: time, price, volume.  This  
data frame is all the trades of a product for about 15 days.  What I  
want to do is modify the data so that it is in a format that quantmod  
can read.  Quantmod needs data to be in columns: Open, High, Low,  
Close, and Volume.

I wanted to see if anyone had some suggestions to easily modify the  
data into the quantmod format.

Quantmod: http://www.quantmod.com/
Data (.csv, 21.67KB) can be downloaded at http://www.mediafire.com/?fyunce685ekuyo3
        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: data manipulation to for quantmod function

julien cuisinier

Hi,


Always nice to have a name on those email.

quantmod "format" is xts format, you might try as.xts but i guess you will need to give it all the needed columns to fit the XTS object

OR use quantmod getSymbols function to download the data straight into the right format if possible


HTH,
Julien



> From: [hidden email]
> To: [hidden email]
> Date: Tue, 10 Jan 2012 22:30:33 -0600
> Subject: [R-SIG-Finance] data manipulation to for quantmod function
>
> I need some help with data manipulation so I can use quantmod.
>
> I have a data frame with three columns: time, price, volume.  This  
> data frame is all the trades of a product for about 15 days.  What I  
> want to do is modify the data so that it is in a format that quantmod  
> can read.  Quantmod needs data to be in columns: Open, High, Low,  
> Close, and Volume.
>
> I wanted to see if anyone had some suggestions to easily modify the  
> data into the quantmod format.
>
> Quantmod: http://www.quantmod.com/
> Data (.csv, 21.67KB) can be downloaded at http://www.mediafire.com/?fyunce685ekuyo3
> [[alternative HTML version deleted]]
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
     
        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: data manipulation to for quantmod function

Yuanhang Wang
Hi,

    Not sure if this is the right way to seek assistance, but I'm looking
for an implementation of getSymbols.bloomberg , could anyone direct me to
the right place?



Regards,
Yuanhang

On Wed, Jan 11, 2012 at 5:22 PM, julien cuisinier
<[hidden email]>wrote:

>
> Hi,
>
>
> Always nice to have a name on those email.
>
> quantmod "format" is xts format, you might try as.xts but i guess you will
> need to give it all the needed columns to fit the XTS object
>
> OR use quantmod getSymbols function to download the data straight into the
> right format if possible
>
>
> HTH,
> Julien
>
>
>
> > From: [hidden email]
> > To: [hidden email]
> > Date: Tue, 10 Jan 2012 22:30:33 -0600
> > Subject: [R-SIG-Finance] data manipulation to for quantmod function
> >
> > I need some help with data manipulation so I can use quantmod.
> >
> > I have a data frame with three columns: time, price, volume.  This
> > data frame is all the trades of a product for about 15 days.  What I
> > want to do is modify the data so that it is in a format that quantmod
> > can read.  Quantmod needs data to be in columns: Open, High, Low,
> > Close, and Volume.
> >
> > I wanted to see if anyone had some suggestions to easily modify the
> > data into the quantmod format.
> >
> > Quantmod: http://www.quantmod.com/
> > Data (.csv, 21.67KB) can be downloaded at
> http://www.mediafire.com/?fyunce685ekuyo3
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> should go.
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>


--
¨Æ¦b¤H¬°¡C

        [[alternative HTML version deleted]]


_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: data manipulation to for quantmod function

Michael Weylandt
In reply to this post by julien cuisinier
If you have tick/high(-ish) frequency data, you'll have to transform it to OHLC; there's no way to keep the frequency you have and to make an OHLC object out of it, since those metrics are by definition aggregates. The easiest way to do so is to read it in as an xts object then use one of the to.period() functions.

Michael

On Jan 11, 2012, at 4:22 AM, julien cuisinier <[hidden email]> wrote:

>
> Hi,
>
>
> Always nice to have a name on those email.
>
> quantmod "format" is xts format, you might try as.xts but i guess you will need to give it all the needed columns to fit the XTS object
>
> OR use quantmod getSymbols function to download the data straight into the right format if possible
>
>
> HTH,
> Julien
>
>
>
>> From: [hidden email]
>> To: [hidden email]
>> Date: Tue, 10 Jan 2012 22:30:33 -0600
>> Subject: [R-SIG-Finance] data manipulation to for quantmod function
>>
>> I need some help with data manipulation so I can use quantmod.
>>
>> I have a data frame with three columns: time, price, volume.  This  
>> data frame is all the trades of a product for about 15 days.  What I  
>> want to do is modify the data so that it is in a format that quantmod  
>> can read.  Quantmod needs data to be in columns: Open, High, Low,  
>> Close, and Volume.
>>
>> I wanted to see if anyone had some suggestions to easily modify the  
>> data into the quantmod format.
>>
>> Quantmod: http://www.quantmod.com/
>> Data (.csv, 21.67KB) can be downloaded at http://www.mediafire.com/?fyunce685ekuyo3
>>    [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions should go.
>                        
>    [[alternative HTML version deleted]]
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: data manipulation to for quantmod function

julien cuisinier
In reply to this post by Yuanhang Wang

Hi,


As you can see from latest quantmod package doc there is no such function, up to the developer to say if they intend to do one.

RBloomberg will be your way to access BBG data from R... Then convert the data object is uses (I am not familiar with it) into an xts object quantmod (& the subsequent tools such as quantstrat) can read / use

Thanks to update the list with your findings - especially if I am wrong


Rgds,
Julien



From: [hidden email]
Date: Wed, 11 Jan 2012 22:48:59 +0800
To: [hidden email]
Subject: Re: [R-SIG-Finance] data manipulation to for quantmod function

Hi,
 
    Not sure if this is the right way to seek assistance, but I'm looking
for an implementation of getSymbols.bloomberg , could anyone direct me to
the right place?
 
 
 
Regards,
Yuanhang
 
On Wed, Jan 11, 2012 at 5:22 PM, julien cuisinier
<[hidden email]>wrote:
 

>
> Hi,
>
>
> Always nice to have a name on those email.
>
> quantmod "format" is xts format, you might try as.xts but i guess you will
> need to give it all the needed columns to fit the XTS object
>
> OR use quantmod getSymbols function to download the data straight into the
> right format if possible
>
>
> HTH,
> Julien
>
>
>
> > From: [hidden email]
> > To: [hidden email]
> > Date: Tue, 10 Jan 2012 22:30:33 -0600
> > Subject: [R-SIG-Finance] data manipulation to for quantmod function
> >
> > I need some help with data manipulation so I can use quantmod.
> >
> > I have a data frame with three columns: time, price, volume.  This
> > data frame is all the trades of a product for about 15 days.  What I
> > want to do is modify the data so that it is in a format that quantmod
> > can read.  Quantmod needs data to be in columns: Open, High, Low,
> > Close, and Volume.
> >
> > I wanted to see if anyone had some suggestions to easily modify the
> > data into the quantmod format.
> >
> > Quantmod: http://www.quantmod.com/
> > Data (.csv, 21.67KB) can be downloaded at
> http://www.mediafire.com/?fyunce685ekuyo3
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> should go.
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>
 
 
 
--
¨Æ¦b¤H¬°¡C
 
        [[alternative HTML version deleted]]
 

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.    
        [[alternative HTML version deleted]]


_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: data manipulation to for quantmod function

braverock
In reply to this post by Michael Weylandt
On Wed, 2012-01-11 at 09:49 -0500, R. Michael Weylandt wrote:
> If you have tick/high(-ish) frequency data, you'll have to
> transform it to OHLC; there's no way to keep the frequency
> you have and to make an OHLC object out of it, since those
> metrics are by definition aggregates. The easiest way to
> do so is to read it in as an xts object then use one of the to.period() functions.


Whoa.  Not (Completely) True.

getSymbols, xts, and quantmod are perfectly comfortable with tick data
of millions and even billions of rows.

chart_Series and chartSeries have built-in charting mechanisms for OHLC
data, and you may wish to transform higher freqency data to lower
frequency OHLC before charting, but this is by no means required.

Some indicator/TA methods also require OHLC data or equivalent, but many
will work fine on univariate series or on tick.

To the original poster's question, I usually use read.table or read.csv
and then as.xts to convert to an xts object.  How to do these steps has
been covered many times on this list, so please search the archives.

With the linked csv file in the original poster's messages,
see ?strftime and the list archives for information on formatting.

Regards,

   - Brian


--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

> On Jan 11, 2012, at 4:22 AM, julien cuisinier <[hidden email]> wrote:
>
> >
> > Hi,
> >
> >
> > Always nice to have a name on those email.
> >
> > quantmod "format" is xts format, you might try as.xts but i guess you will need to give it all the needed columns to fit the XTS object
> >
> > OR use quantmod getSymbols function to download the data straight into the right format if possible
> >
> >
> > HTH,
> > Julien
> >
> >
> >
> >> From: [hidden email]
> >> To: [hidden email]
> >> Date: Tue, 10 Jan 2012 22:30:33 -0600
> >> Subject: [R-SIG-Finance] data manipulation to for quantmod function
> >>
> >> I need some help with data manipulation so I can use quantmod.
> >>
> >> I have a data frame with three columns: time, price, volume.  This  
> >> data frame is all the trades of a product for about 15 days.  What I  
> >> want to do is modify the data so that it is in a format that quantmod  
> >> can read.  Quantmod needs data to be in columns: Open, High, Low,  
> >> Close, and Volume.
> >>
> >> I wanted to see if anyone had some suggestions to easily modify the  
> >> data into the quantmod format.
> >>
> >> Quantmod: http://www.quantmod.com/
> >> Data (.csv, 21.67KB) can be downloaded at http://www.mediafire.com/?fyunce685ekuyo3
> >>    [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: data manipulation to for quantmod function

Michael Weylandt
Brian,

You are (of course) absolutely right about quantmod/quantstrat functionality - and you, Jeff, Josh, Dirk & anyone else I'm forgetting can't be thanked enough for your work. I was only directing the OP on how to get OHLC as he asked but he should be rightly informed that quantmod easily handles tick data.

Michael

On Jan 11, 2012, at 10:10 AM, "Brian G. Peterson" <[hidden email]> wrote:

> On Wed, 2012-01-11 at 09:49 -0500, R. Michael Weylandt wrote:
>> If you have tick/high(-ish) frequency data, you'll have to
>> transform it to OHLC; there's no way to keep the frequency
>> you have and to make an OHLC object out of it, since those
>> metrics are by definition aggregates. The easiest way to
>> do so is to read it in as an xts object then use one of the to.period() functions.
>
>
> Whoa.  Not (Completely) True.
>
> getSymbols, xts, and quantmod are perfectly comfortable with tick data
> of millions and even billions of rows.
>
> chart_Series and chartSeries have built-in charting mechanisms for OHLC
> data, and you may wish to transform higher freqency data to lower
> frequency OHLC before charting, but this is by no means required.
>
> Some indicator/TA methods also require OHLC data or equivalent, but many
> will work fine on univariate series or on tick.
>
> To the original poster's question, I usually use read.table or read.csv
> and then as.xts to convert to an xts object.  How to do these steps has
> been covered many times on this list, so please search the archives.
>
> With the linked csv file in the original poster's messages,
> see ?strftime and the list archives for information on formatting.
>
> Regards,
>
>   - Brian
>
>
> --
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock
>
>> On Jan 11, 2012, at 4:22 AM, julien cuisinier <[hidden email]> wrote:
>>
>>>
>>> Hi,
>>>
>>>
>>> Always nice to have a name on those email.
>>>
>>> quantmod "format" is xts format, you might try as.xts but i guess you will need to give it all the needed columns to fit the XTS object
>>>
>>> OR use quantmod getSymbols function to download the data straight into the right format if possible
>>>
>>>
>>> HTH,
>>> Julien
>>>
>>>
>>>
>>>> From: [hidden email]
>>>> To: [hidden email]
>>>> Date: Tue, 10 Jan 2012 22:30:33 -0600
>>>> Subject: [R-SIG-Finance] data manipulation to for quantmod function
>>>>
>>>> I need some help with data manipulation so I can use quantmod.
>>>>
>>>> I have a data frame with three columns: time, price, volume.  This  
>>>> data frame is all the trades of a product for about 15 days.  What I  
>>>> want to do is modify the data so that it is in a format that quantmod  
>>>> can read.  Quantmod needs data to be in columns: Open, High, Low,  
>>>> Close, and Volume.
>>>>
>>>> I wanted to see if anyone had some suggestions to easily modify the  
>>>> data into the quantmod format.
>>>>
>>>> Quantmod: http://www.quantmod.com/
>>>> Data (.csv, 21.67KB) can be downloaded at http://www.mediafire.com/?fyunce685ekuyo3
>>>>   [[alternative HTML version deleted]]
>
>

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: data manipulation to for quantmod function

gsee
In reply to this post by julien cuisinier
There is a getSymbols.Bloomberg method.  It's just commented out
because it is not platform independent.

Look here:
https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/R/getSymbols.R?revision=572&root=quantmod

-Garrett


On Wed, Jan 11, 2012 at 9:03 AM, julien cuisinier
<[hidden email]> wrote:

>
> Hi,
>
>
> As you can see from latest quantmod package doc there is no such function, up to the developer to say if they intend to do one.
>
> RBloomberg will be your way to access BBG data from R... Then convert the data object is uses (I am not familiar with it) into an xts object quantmod (& the subsequent tools such as quantstrat) can read / use
>
> Thanks to update the list with your findings - especially if I am wrong
>
>
> Rgds,
> Julien
>
>
>
> From: [hidden email]
> Date: Wed, 11 Jan 2012 22:48:59 +0800
> To: [hidden email]
> Subject: Re: [R-SIG-Finance] data manipulation to for quantmod function
>
> Hi,
>
>    Not sure if this is the right way to seek assistance, but I'm looking
> for an implementation of getSymbols.bloomberg , could anyone direct me to
> the right place?
>
>
>
> Regards,
> Yuanhang
>
> On Wed, Jan 11, 2012 at 5:22 PM, julien cuisinier
> <[hidden email]>wrote:
>
>>
>> Hi,
>>
>>
>> Always nice to have a name on those email.
>>
>> quantmod "format" is xts format, you might try as.xts but i guess you will
>> need to give it all the needed columns to fit the XTS object
>>
>> OR use quantmod getSymbols function to download the data straight into the
>> right format if possible
>>
>>
>> HTH,
>> Julien
>>
>>
>>
>> > From: [hidden email]
>> > To: [hidden email]
>> > Date: Tue, 10 Jan 2012 22:30:33 -0600
>> > Subject: [R-SIG-Finance] data manipulation to for quantmod function
>> >
>> > I need some help with data manipulation so I can use quantmod.
>> >
>> > I have a data frame with three columns: time, price, volume.  This
>> > data frame is all the trades of a product for about 15 days.  What I
>> > want to do is modify the data so that it is in a format that quantmod
>> > can read.  Quantmod needs data to be in columns: Open, High, Low,
>> > Close, and Volume.
>> >
>> > I wanted to see if anyone had some suggestions to easily modify the
>> > data into the quantmod format.
>> >
>> > Quantmod: http://www.quantmod.com/
>> > Data (.csv, 21.67KB) can be downloaded at
>> http://www.mediafire.com/?fyunce685ekuyo3
>> >       [[alternative HTML version deleted]]
>> >
>> > _______________________________________________
>> > [hidden email] mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> > -- Subscriber-posting only. If you want to post, subscribe first.
>> > -- Also note that this is not the r-help list where general R questions
>> should go.
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions
>> should go.
>>
>
>
>
> --
> 事在人為。
>
>        [[alternative HTML version deleted]]
>
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>        [[alternative HTML version deleted]]
>
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: getSymbols.Bloomberg (was Re: data manipulation to for quantmod function)

braverock
In reply to this post by julien cuisinier
Yuanhang,

Next time, please start a new thread rather than just replying to
another post.

Julien is correct that there is no exposed function for
getSymbols.Bloomberg, and that the RBloomberg package is the right place
to go to get data out of the Bloomberg terminal.

There is, however, a (start?) of a getSymbols.Bloomberg function in
quantmod, the code is commented out, and (at best) not completely
tested, as Jeff (and I right now) don't have easy access to Bloomberg
terminals.

You can find the code here:

https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/R/getSymbols.R?root=quantmod

see commented lines 93-187

We would of course welcome testing and patches from someone who has
access to both a Bloomberg terminal and RBloomberg.

Regards,

   - Brian


On Wed, 2012-01-11 at 16:03 +0100, julien cuisinier wrote:

> Hi,
>
>
> As you can see from latest quantmod package doc there is no such function, up to the developer to say if they intend to do one.
>
> RBloomberg will be your way to access BBG data from R... Then convert the data object is uses (I am not familiar with it) into an xts object quantmod (& the subsequent tools such as quantstrat) can read / use
>
> Thanks to update the list with your findings - especially if I am wrong
>
>
> Rgds,
> Julien
>
>
>
> From: [hidden email]
> Date: Wed, 11 Jan 2012 22:48:59 +0800
> To: [hidden email]
> Subject: Re: [R-SIG-Finance] data manipulation to for quantmod function
>
> Hi,
>  
>     Not sure if this is the right way to seek assistance, but I'm looking
> for an implementation of getSymbols.bloomberg , could anyone direct me to
> the right place?
>  
>
>
> Regards,
> Yuanhang
>  
> On Wed, Jan 11, 2012 at 5:22 PM, julien cuisinier
> <[hidden email]>wrote:
>  
> >
> > Hi,
> >
> >
> > Always nice to have a name on those email.
> >
> > quantmod "format" is xts format, you might try as.xts but i guess you will
> > need to give it all the needed columns to fit the XTS object
> >
> > OR use quantmod getSymbols function to download the data straight into the
> > right format if possible
> >
> >
> > HTH,
> > Julien
> >
> >
> >
> > > From: [hidden email]
> > > To: [hidden email]
> > > Date: Tue, 10 Jan 2012 22:30:33 -0600
> > > Subject: [R-SIG-Finance] data manipulation to for quantmod function
> > >
> > > I need some help with data manipulation so I can use quantmod.
> > >
> > > I have a data frame with three columns: time, price, volume.  This
> > > data frame is all the trades of a product for about 15 days.  What I
> > > want to do is modify the data so that it is in a format that quantmod
> > > can read.  Quantmod needs data to be in columns: Open, High, Low,
> > > Close, and Volume.
> > >
> > > I wanted to see if anyone had some suggestions to easily modify the
> > > data into the quantmod format.
> > >
> > > Quantmod: http://www.quantmod.com/
> > > Data (.csv, 21.67KB) can be downloaded at
> > http://www.mediafire.com/?fyunce685ekuyo3
> > >       [[alternative HTML version deleted]]
> > >
> > > _______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > > -- Subscriber-posting only. If you want to post, subscribe first.
> > > -- Also note that this is not the r-help list where general R questions
> > should go.
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> > should go.
> >
>  
>
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.

--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: getSymbols.Bloomberg (was Re: data manipulation to for quantmod function)

G.abe Lin
I have an implementation I did.  See below.  I'm not a great programmer in
practice, as my background in CS ended in grad school.  If getSymbols.BB
ended up in quantmod that would be awesome.

requires RBloomberg and FinancialInstrument (it uses the instrument's
setup...an identifier that is mapped to a BBG identifier)


getSymbols.BB <- function(Symbols, env=.GlobalEnv,from,to,...)
{
    importDefaults("getSymbols.OneTick")
    this.env <- environment()

    for (var in names(list(...))) {
        assign(var, list(...)[[var]], this.env)
    }

    if (missing(verbose))
        verbose <- FALSE
    if (missing(auto.assign))
        auto.assign <- TRUE

    if (!("package:RBloomberg" %in% search() || require("RBloomberg",
quietly = TRUE))) {
        stop(paste("package:", dQuote("RBloomberg"), "cannot be loaded"))
    }

    conn <- blpConnect()

    for (i in 1:length(Symbols)) {
        if (verbose) {
            cat(paste("Loading ", Symbols[[i]], paste(rep(".",
                10 - nchar(Symbols[[i]])), collapse = ""), sep = ""))
        }

        myInst = getInstrument(Symbols[i])

        if (missing(from))
            start_date = format(as.Date(myInst$first_traded),"%Y%m%d")
        else
            start_date = format(as.Date(from),"%Y%m%d")

        if (missing(to))
            end_date = format(as.Date(myInst$expires),"%Y%m%d")
        else
            end_date = format(as.Date(to),"%Y%m%d")

        if (as.Date(myInst$expires)>as.Date(Sys.Date()))
            end_date = format(Sys.Date(),"%Y%m%d")

        FLDS <- c("PX_OPEN","PX_HIGH","PX_LOW","PX_LAST")

        rs = bdh(conn,myInst$identifiers$BB,FLDS, start_date = start_date ,
end_date = end_date)

        if (class(rs)!="data.frame") {
            warning(paste(rs[1],rs[2]))
        } else {
            fr <- xts(rs[,-1], order.by=as.POSIXct(rs[,1]), src= "BB",
updated = Sys.time())
            # REORDER TO OHLC columns and rename

            colnames(fr) <- paste(Symbols[[i]], c("Open", "High",
                "Low", "Close"), sep = ".")

            fr = na.omit(fr)
            if (auto.assign)
                assign(Symbols[[i]], fr, env)
            if (verbose)
                cat("done\n")
        }
    }
    blpDisconnect(conn)

    if (auto.assign)
        return(Symbols)
    return(fr)
}

On Wed, Jan 11, 2012 at 10:32 AM, Brian G. Peterson <[hidden email]>wrote:

> Yuanhang,
>
> Next time, please start a new thread rather than just replying to
> another post.
>
> Julien is correct that there is no exposed function for
> getSymbols.Bloomberg, and that the RBloomberg package is the right place
> to go to get data out of the Bloomberg terminal.
>
> There is, however, a (start?) of a getSymbols.Bloomberg function in
> quantmod, the code is commented out, and (at best) not completely
> tested, as Jeff (and I right now) don't have easy access to Bloomberg
> terminals.
>
> You can find the code here:
>
>
> https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/R/getSymbols.R?root=quantmod
>
> see commented lines 93-187
>
> We would of course welcome testing and patches from someone who has
> access to both a Bloomberg terminal and RBloomberg.
>
> Regards,
>
>   - Brian
>
>
> On Wed, 2012-01-11 at 16:03 +0100, julien cuisinier wrote:
> > Hi,
> >
> >
> > As you can see from latest quantmod package doc there is no such
> function, up to the developer to say if they intend to do one.
> >
> > RBloomberg will be your way to access BBG data from R... Then convert
> the data object is uses (I am not familiar with it) into an xts object
> quantmod (& the subsequent tools such as quantstrat) can read / use
> >
> > Thanks to update the list with your findings - especially if I am wrong
> >
> >
> > Rgds,
> > Julien
> >
> >
> >
> > From: [hidden email]
> > Date: Wed, 11 Jan 2012 22:48:59 +0800
> > To: [hidden email]
> > Subject: Re: [R-SIG-Finance] data manipulation to for quantmod function
> >
> > Hi,
> >
> >     Not sure if this is the right way to seek assistance, but I'm looking
> > for an implementation of getSymbols.bloomberg , could anyone direct me to
> > the right place?
> >
> >
> >
> > Regards,
> > Yuanhang
> >
> > On Wed, Jan 11, 2012 at 5:22 PM, julien cuisinier
> > <[hidden email]>wrote:
> >
> > >
> > > Hi,
> > >
> > >
> > > Always nice to have a name on those email.
> > >
> > > quantmod "format" is xts format, you might try as.xts but i guess you
> will
> > > need to give it all the needed columns to fit the XTS object
> > >
> > > OR use quantmod getSymbols function to download the data straight into
> the
> > > right format if possible
> > >
> > >
> > > HTH,
> > > Julien
> > >
> > >
> > >
> > > > From: [hidden email]
> > > > To: [hidden email]
> > > > Date: Tue, 10 Jan 2012 22:30:33 -0600
> > > > Subject: [R-SIG-Finance] data manipulation to for quantmod function
> > > >
> > > > I need some help with data manipulation so I can use quantmod.
> > > >
> > > > I have a data frame with three columns: time, price, volume.  This
> > > > data frame is all the trades of a product for about 15 days.  What I
> > > > want to do is modify the data so that it is in a format that quantmod
> > > > can read.  Quantmod needs data to be in columns: Open, High, Low,
> > > > Close, and Volume.
> > > >
> > > > I wanted to see if anyone had some suggestions to easily modify the
> > > > data into the quantmod format.
> > > >
> > > > Quantmod: http://www.quantmod.com/
> > > > Data (.csv, 21.67KB) can be downloaded at
> > > http://www.mediafire.com/?fyunce685ekuyo3
> > > >       [[alternative HTML version deleted]]
> > > >
> > > > _______________________________________________
> > > > [hidden email] mailing list
> > > > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > > > -- Subscriber-posting only. If you want to post, subscribe first.
> > > > -- Also note that this is not the r-help list where general R
> questions
> > > should go.
> > >
> > >        [[alternative HTML version deleted]]
> > >
> > > _______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > > -- Subscriber-posting only. If you want to post, subscribe first.
> > > -- Also note that this is not the r-help list where general R questions
> > > should go.
> > >
> >
> >
> >
> > _______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> should go.
>
> --
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>



--
Gei Lin
207 East 30th St, Apt 4H
New York, NY 10016
Cell: (781) 718-8522
Office: (212) 810-8604

Don't quit. Suffer now and live the rest of your life as a champion.

                                                - Muhammad Ali

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

OHLC and volume data analysis using quantmod

financial engineer
In reply to this post by braverock


hi,

I have a time series of tick data and I am trying to get the aggregate volume for every 3-minutes for the tick data that I have converted into OHLC format (so I can use some of the nice functionalities of quantmod for my analysis).

I have written the following code, but do
 not know how to get the aggregate volume for the 3-minutes in that OHLC for some
volume analysis (so I can use aggregate(Vo(x)) etc.).

library(tseries)
library(xts)
library(quantmod)


x = read.table("tick.dat", header = FALSE, sep="\t", skip=0)
x
             V1    V2               V3    V4    V5    V6       V7 V8  V9
11107  U10 2010-07-01  1      1453 9160 TRUE  N  N   2
11108  U10 2010-07-01  1      1453 9160 TRUE  N  N   1
11109  U10 2010-07-01  1      1454 9155 TRUE  N  N   4
11110  U10 2010-07-01  1      1455 9155 TRUE  N  N   3
11111  U10 2010-07-01  1      1455 9155 TRUE  N  N   1

dt<-sprintf("%s %04d",x$V2,x$V4)
dt<-as.POSIXlt(dt,format="%Y-%m-%d %H%M")

y <- data.frame(dt,x$V5,x$V9)
colnames(y) <- c("Date","Price","Volume")
str(y)

z <- xts(y[,2], y[,1])

tickmin <- to.minutes3(z, OHLC=TRUE)

Can anyone please suggest how I get the aggregate volume by 3-minutes into my OHLC series.

     
        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: OHLC and volume data analysis using quantmod

gsee
If you apply to.minutes3 to an object that has volume, the volume will
be summed for you.

I think the following should work for you, although I didn't test your
specific example:

z <- xts(y[, 2:3], y[, 1])
to.minutes3(z, OHLC=TRUE)

HTH,
Garrett

On Mon, Jan 16, 2012 at 11:50 AM, financial engineer
<[hidden email]> wrote:

>
>
> hi,
>
> I have a time series of tick data and I am trying to get the aggregate volume for every 3-minutes for the tick data that I have converted into OHLC format (so I can use some of the nice functionalities of quantmod for my analysis).
>
> I have written the following code, but do
>  not know how to get the aggregate volume for the 3-minutes in that OHLC for some
> volume analysis (so I can use aggregate(Vo(x)) etc.).
>
> library(tseries)
> library(xts)
> library(quantmod)
>
>
> x = read.table("tick.dat", header = FALSE, sep="\t", skip=0)
> x
>             V1    V2               V3    V4    V5    V6       V7 V8  V9
> 11107  U10 2010-07-01  1      1453 9160 TRUE  N  N   2
> 11108  U10 2010-07-01  1      1453 9160 TRUE  N  N   1
> 11109  U10 2010-07-01  1      1454 9155 TRUE  N  N   4
> 11110  U10 2010-07-01  1      1455 9155 TRUE  N  N   3
> 11111  U10 2010-07-01  1      1455 9155 TRUE  N  N   1
>
> dt<-sprintf("%s %04d",x$V2,x$V4)
> dt<-as.POSIXlt(dt,format="%Y-%m-%d %H%M")
>
> y <- data.frame(dt,x$V5,x$V9)
> colnames(y) <- c("Date","Price","Volume")
> str(y)
>
> z <- xts(y[,2], y[,1])
>
> tickmin <- to.minutes3(z, OHLC=TRUE)
>
> Can anyone please suggest how I get the aggregate volume by 3-minutes into my OHLC series.
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: OHLC and volume data analysis using quantmod

financial engineer

hi Garrett,

Thanks for your response.

it did work.

Best,
Bobby

> Date: Mon, 16 Jan 2012 13:06:56 -0600
> Subject: Re: [R-SIG-Finance] OHLC and volume data analysis using quantmod
> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]
>
> If you apply to.minutes3 to an object that has volume, the volume will
> be summed for you.
>
> I think the following should work for you, although I didn't test your
> specific example:
>
> z <- xts(y[, 2:3], y[, 1])
> to.minutes3(z, OHLC=TRUE)
>
> HTH,
> Garrett
>
> On Mon, Jan 16, 2012 at 11:50 AM, financial engineer
> <[hidden email]> wrote:
> >
> >
> > hi,
> >
> > I have a time series of tick data and I am trying to get the aggregate volume for every 3-minutes for the tick data that I have converted into OHLC format (so I can use some of the nice functionalities of quantmod for my analysis).
> >
> > I have written the following code, but do
> >  not know how to get the aggregate volume for the 3-minutes in that OHLC for some
> > volume analysis (so I can use aggregate(Vo(x)) etc.).
> >
> > library(tseries)
> > library(xts)
> > library(quantmod)
> >
> >
> > x = read.table("tick.dat", header = FALSE, sep="\t", skip=0)
> > x
> >             V1    V2               V3    V4    V5    V6       V7 V8  V9
> > 11107  U10 2010-07-01  1      1453 9160 TRUE  N  N   2
> > 11108  U10 2010-07-01  1      1453 9160 TRUE  N  N   1
> > 11109  U10 2010-07-01  1      1454 9155 TRUE  N  N   4
> > 11110  U10 2010-07-01  1      1455 9155 TRUE  N  N   3
> > 11111  U10 2010-07-01  1      1455 9155 TRUE  N  N   1
> >
> > dt<-sprintf("%s %04d",x$V2,x$V4)
> > dt<-as.POSIXlt(dt,format="%Y-%m-%d %H%M")
> >
> > y <- data.frame(dt,x$V5,x$V9)
> > colnames(y) <- c("Date","Price","Volume")
> > str(y)
> >
> > z <- xts(y[,2], y[,1])
> >
> > tickmin <- to.minutes3(z, OHLC=TRUE)
> >
> > Can anyone please suggest how I get the aggregate volume by 3-minutes into my OHLC series.
> >
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions should go.
     
        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: data manipulation to for quantmod function

G.abe Lin
In reply to this post by gsee
Although it's not platform independent, would it matter if was exposed?

On Wed, Jan 11, 2012 at 10:27 AM, G See <[hidden email]> wrote:

> There is a getSymbols.Bloomberg method.  It's just commented out
> because it is not platform independent.
>
> Look here:
>
> https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/R/getSymbols.R?revision=572&root=quantmod
>
> -Garrett
>
>
> On Wed, Jan 11, 2012 at 9:03 AM, julien cuisinier
> <[hidden email]> wrote:
> >
> > Hi,
> >
> >
> > As you can see from latest quantmod package doc there is no such
> function, up to the developer to say if they intend to do one.
> >
> > RBloomberg will be your way to access BBG data from R... Then convert
> the data object is uses (I am not familiar with it) into an xts object
> quantmod (& the subsequent tools such as quantstrat) can read / use
> >
> > Thanks to update the list with your findings - especially if I am wrong
> >
> >
> > Rgds,
> > Julien
> >
> >
> >
> > From: [hidden email]
> > Date: Wed, 11 Jan 2012 22:48:59 +0800
> > To: [hidden email]
> > Subject: Re: [R-SIG-Finance] data manipulation to for quantmod function
> >
> > Hi,
> >
> >    Not sure if this is the right way to seek assistance, but I'm looking
> > for an implementation of getSymbols.bloomberg , could anyone direct me to
> > the right place?
> >
> >
> >
> > Regards,
> > Yuanhang
> >
> > On Wed, Jan 11, 2012 at 5:22 PM, julien cuisinier
> > <[hidden email]>wrote:
> >
> >>
> >> Hi,
> >>
> >>
> >> Always nice to have a name on those email.
> >>
> >> quantmod "format" is xts format, you might try as.xts but i guess you
> will
> >> need to give it all the needed columns to fit the XTS object
> >>
> >> OR use quantmod getSymbols function to download the data straight into
> the
> >> right format if possible
> >>
> >>
> >> HTH,
> >> Julien
> >>
> >>
> >>
> >> > From: [hidden email]
> >> > To: [hidden email]
> >> > Date: Tue, 10 Jan 2012 22:30:33 -0600
> >> > Subject: [R-SIG-Finance] data manipulation to for quantmod function
> >> >
> >> > I need some help with data manipulation so I can use quantmod.
> >> >
> >> > I have a data frame with three columns: time, price, volume.  This
> >> > data frame is all the trades of a product for about 15 days.  What I
> >> > want to do is modify the data so that it is in a format that quantmod
> >> > can read.  Quantmod needs data to be in columns: Open, High, Low,
> >> > Close, and Volume.
> >> >
> >> > I wanted to see if anyone had some suggestions to easily modify the
> >> > data into the quantmod format.
> >> >
> >> > Quantmod: http://www.quantmod.com/
> >> > Data (.csv, 21.67KB) can be downloaded at
> >> http://www.mediafire.com/?fyunce685ekuyo3
> >> >       [[alternative HTML version deleted]]
> >> >
> >> > _______________________________________________
> >> > [hidden email] mailing list
> >> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> >> > -- Subscriber-posting only. If you want to post, subscribe first.
> >> > -- Also note that this is not the r-help list where general R
> questions
> >> should go.
> >>
> >>        [[alternative HTML version deleted]]
> >>
> >> _______________________________________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> >> -- Subscriber-posting only. If you want to post, subscribe first.
> >> -- Also note that this is not the r-help list where general R questions
> >> should go.
> >>
> >
> >
> >
> > --
> > ¨Æ¦b¤H¬°¡C
> >
> >        [[alternative HTML version deleted]]
> >
> >
> > _______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> should go.
> >        [[alternative HTML version deleted]]
> >
> >
> > _______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> should go.
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>


--
Gei Lin
207 East 30th St, Apt 4H
New York, NY 10016
Cell: (781) 718-8522

Don't quit. Suffer now and live the rest of your life as a champion.

                                                - Muhammad Ali

        [[alternative HTML version deleted]]


_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Loading...