Uneven time series

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Uneven time series

Luis Damiano
Dear all,

I'm dealing with an uneven time series with regressors [0]. If the series
was regular, my preferred approach would be some form of space state
representation such as smoothing, time varying regression or an
autoregressive process with external regressors.

The series shows a clear trend and I believe that irregularity is an
important feature. So far, I've found two alternatives: a) continuous time
models and packages like ctsem [1] and cts [2], but they seemed limited in
their application, and b) exponential smoothing for uneven time series [3]
but they wouldn't allow for regressors.

Before I give up, I was wondering if you can suggest a better way to model
this series.

Thank you a lot!

Regards,

[0] http://puu.sh/s6O9q/ba6aa206f6.png

[1] https://cran.r-project.org/web/packages/ctsem/

[2] https://cran.r-project.org/web/packages/cts/

[3] https://oroboro.com/irregular-ema/

        [[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
|

blotter updatePortf

Michael Chen
I have found in running my own customized strategy using blotter and updatePortf that whether I call updatePortf after completely applying my strategy/transactions or call updatePortf at regular intervals like weekly or monthly after each period's transactions, the performance statistics are the same.  So, is there a reason that I should updatePortf regularly during a run or just wait till the end?  I am puzzled.  

Thanks,

Michael

_______________________________________________
[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
|

Re: blotter updatePortf

Ilya Kipnis
Michael,

Unless you want to use a new end equity over the course of your strategy
(EG I started off with 100 dollars, I made 50 more dollars, I want to go
forward with 150 now), there's no reason to do so that I can think of.

-Ilya

On Sat, Nov 5, 2016 at 11:51 AM, Michael Chen <[hidden email]> wrote:

> I have found in running my own customized strategy using blotter and
> updatePortf that whether I call updatePortf after completely applying my
> strategy/transactions or call updatePortf at regular intervals like weekly
> or monthly after each period's transactions, the performance statistics are
> the same.  So, is there a reason that I should updatePortf regularly during
> a run or just wait till the end?  I am puzzled.
>
> Thanks,
>
> Michael
>
> _______________________________________________
> [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
|

Re: blotter updatePortf

Joshua Ulrich
In reply to this post by Michael Chen
On Sat, Nov 5, 2016 at 10:51 AM, Michael Chen <[hidden email]> wrote:
> I have found in running my own customized strategy using blotter and updatePortf that whether I call updatePortf after completely applying my strategy/transactions or call updatePortf at regular intervals like weekly or monthly after each period's transactions, the performance statistics are the same.  So, is there a reason that I should updatePortf regularly during a run or just wait till the end?  I am puzzled.
>
Calling updatePortf marks your portfolio to market.  I assume (since
you didn't specify in your message) that your transaction sizing is
invariant to portfolio equity.  In that case, you should not expect
calling updatePortf to change strategy performance.

In short, if your strategy doesn't depend on your portfolio market
value, there's no need to call updatePortf until the end of the
simulation.

> Thanks,
>
> Michael
>
> _______________________________________________
> [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.



--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.com

_______________________________________________
[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
|

Re: blotter updatePortf

Cameron McLean
In reply to this post by Michael Chen
Hi Josh, Ilya

Is there example code you can share or an existing demo in quantstrat
that shows how to update the portfolio equity curve and size future
orders based on the current amount?

A simple example would be something similar to the faber demo where he
invests 20% of equity in each of the 5 asset classes (currently the
faber demo buys and sells lots of 500 shares) or a more complex
example could be using a indicator such as ATR to size trades based on
risk.

thanks
Cam

_______________________________________________
[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
|

Re: blotter updatePortf

braverock
On 11/06/2016 12:10 PM, Cameron McLean wrote:
> Is there example code you can share or an existing demo in quantstrat
> that shows how to update the portfolio equity curve and size future
> orders based on the current amount?

Look at any of the rebalancing demos.  There are rebalancing versions of
the Faber and macd demos, at least.

These rebalance (adjust max trade size) periodically based on current
portfolio equity.

> A simple example would be something similar to the faber demo where he
> invests 20% of equity in each of the 5 asset classes (currently the
> faber demo buys and sells lots of 500 shares) or a more complex
> example could be using a indicator such as ATR to size trades based on
> risk.

Sizing based on risk would be done via a custom order sizing function
that used the indicator value to adjust trade size.  I believe Ilya has
examples of this on his blog.

Regards,

Brian

--
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
|

Re: blotter updatePortf

Michael Chen
Reading these answers reminded me to inquire the same about Quantstrat.  I looked into the code for applyStrategy, I don't see any explicit calls to updatePort.  Is this because in my runs of quanstrat, I didn't use "real time" re-balancing? So, no update was necessary?  Usually, l  just run updatePortf (strategy) which updates every symbol and calculates PnL for each period prices available after I ran applyStrategy in quantstrat.   Please let me know if I am missing something.

thanks as always,



________________________________
From: R-SIG-Finance <[hidden email]> on behalf of Brian G. Peterson <[hidden email]>
Sent: Sunday, November 6, 2016 11:15 AM
To: [hidden email]
Subject: Re: [R-SIG-Finance] blotter updatePortf

On 11/06/2016 12:10 PM, Cameron McLean wrote:
> Is there example code you can share or an existing demo in quantstrat
> that shows how to update the portfolio equity curve and size future
> orders based on the current amount?

Look at any of the rebalancing demos.  There are rebalancing versions of
the Faber and macd demos, at least.

These rebalance (adjust max trade size) periodically based on current
portfolio equity.

> A simple example would be something similar to the faber demo where he
> invests 20% of equity in each of the 5 asset classes (currently the
> faber demo buys and sells lots of 500 shares) or a more complex
> example could be using a indicator such as ATR to size trades based on
> risk.

Sizing based on risk would be done via a custom order sizing function
that used the indicator value to adjust trade size.  I believe Ilya has
examples of this on his blog.

Regards,

Brian

--
Brian G. Peterson
http://braverock.com/brian/
Brian G. Peterson<http://braverock.com/brian/>
braverock.com
BRIAN G. PETERSON 773-459-4973. [hidden email]. download resume as PDF SUMMARY. Senior quantitative trader, financial analyst, technical architect, and project ...



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.

        [[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
|

Re: blotter updatePortf

braverock
On 11/09/2016 12:41 AM, Michael Chen wrote:
> Reading these answers reminded me to inquire the same about
> Quantstrat.  I looked into the code for applyStrategy, I don't see
> any explicit calls to updatePort.  Is this because in my runs of
> quanstrat, I didn't use "real time" re-balancing? So, no update was
> necessary?  Usually, l  just run updatePortf (strategy) which
> updates every symbol and calculates PnL for each period prices
> available after I ran applyStrategy in quantstrat.   Please let me
> know if I am missing something.

updatePortf will be called automatically in quantstrat for rebalancing,
for paramsets, and for walk.forward. It will only be called by the
default applyStrategy call if wrapup=TRUE and you're using the
(experimental, incomplete?) wrapup code.

Regards,

Brian

> on Sunday, November 6, 2016 11:15 AM, Brian G. Peterson wrote:
> On 11/06/2016 12:10 PM, Cameron McLean wrote:
>> Is there example code you can share or an existing demo in
>> quantstrat that shows how to update the portfolio equity curve and
>> size future orders based on the current amount?
>
> Look at any of the rebalancing demos.  There are rebalancing
> versions of the Faber and macd demos, at least.
>
> These rebalance (adjust max trade size) periodically based on current
> portfolio equity.
>
>> A simple example would be something similar to the faber demo
>> where he invests 20% of equity in each of the 5 asset classes
>> (currently the faber demo buys and sells lots of 500 shares) or a
>> more complex example could be using a indicator such as ATR to
>> size trades based on risk.
>
> Sizing based on risk would be done via a custom order sizing function
> that used the indicator value to adjust trade size.  I believe Ilya
> has examples of this on his blog.
>
> Regards,
>
> Brian

_______________________________________________
[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
|

Re: blotter updatePortf

Michael Chen

Hi,

So, in running my custom strategy using blotter, I ran into this problem.  I'll describle the problem first before I give the simplified code to save some trouble and time for all.    I  ran  updatePortf(strategy, symbols, Dates=tradeDate), updpateAcct, and updateEndEq after each weekly transactions (addTxn).    Data is also in weekly format.  I also ran my program entirely first, then ran updatePortf(Strategy) at end.     The codes is otherwise the same.  The two runs have differene Equity curves and  performance analystics results.    Since in both runs, the trades(transactions) are the same, shouldn't the equity curve and performance results the same?    Thanks for any general suggestions and advice that I can try to fix this first.   If not, I will provide data and simplified code.

thank you all again,

Michael
________________________________
From: R-SIG-Finance <[hidden email]> on behalf of Brian G. Peterson <[hidden email]>
Sent: Wednesday, November 9, 2016 3:13 AM
To: [hidden email]
Subject: Re: [R-SIG-Finance] blotter updatePortf

On 11/09/2016 12:41 AM, Michael Chen wrote:
> Reading these answers reminded me to inquire the same about
> Quantstrat.  I looked into the code for applyStrategy, I don't see
> any explicit calls to updatePort.  Is this because in my runs of
> quanstrat, I didn't use "real time" re-balancing? So, no update was
> necessary?  Usually, l  just run updatePortf (strategy) which
> updates every symbol and calculates PnL for each period prices
> available after I ran applyStrategy in quantstrat.   Please let me
> know if I am missing something.

updatePortf will be called automatically in quantstrat for rebalancing,
for paramsets, and for walk.forward. It will only be called by the
default applyStrategy call if wrapup=TRUE and you're using the
(experimental, incomplete?) wrapup code.

Regards,

Brian

> on Sunday, November 6, 2016 11:15 AM, Brian G. Peterson wrote:
> On 11/06/2016 12:10 PM, Cameron McLean wrote:
>> Is there example code you can share or an existing demo in
>> quantstrat that shows how to update the portfolio equity curve and
>> size future orders based on the current amount?
>
> Look at any of the rebalancing demos.  There are rebalancing
> versions of the Faber and macd demos, at least.
>
> These rebalance (adjust max trade size) periodically based on current
> portfolio equity.
>
>> A simple example would be something similar to the faber demo
>> where he invests 20% of equity in each of the 5 asset classes
>> (currently the faber demo buys and sells lots of 500 shares) or a
>> more complex example could be using a indicator such as ATR to
>> size trades based on risk.
>
> Sizing based on risk would be done via a custom order sizing function
> that used the indicator value to adjust trade size.  I believe Ilya
> has examples of this on his blog.
>
> Regards,
>
> Brian

_______________________________________________
[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
|

Re: blotter updatePortf

braverock
Without a minimal reproducible example, I'm just guessing.

I would hope that what you really mean is that you are using daily data,
since daily data is widely available. Even if you plan to trade only
once a week (Monday, Friday, Wednesday, whatever) I would certainly want
more data points to check risk and other metrics against. In any event,
without more information, I would assume a subsetting problem.

The first thing I would check is that in your periodic runs of
updatePortf, you should not be using a date range. Differences are most
likely due to incorrect subsetting with your 'weekly' data.  You say
below that you are calling something like:

updatePortf(strategy, symbols, Dates=tradeDate)

just call

updatePortf(strategy, symbols)

instead.

If my guess is correct, forcing the  subset is not providing the
'starting' values to calculate the difference on your 'tradeDate' period
from.

Regards,

Brian

On 11/11/2016 04:04 AM, Michael Chen wrote:

>
> Hi,
>
> So, in running my custom strategy using blotter, I ran into this
> problem.  I'll describle the problem first before I give the
> simplified code to save some trouble and time for all.    I  ran
> updatePortf(strategy, symbols, Dates=tradeDate), updpateAcct, and
> updateEndEq after each weekly transactions (addTxn).    Data is also
> in weekly format.  I also ran my program entirely first, then ran
> updatePortf(Strategy) at end.     The codes is otherwise the same.
> The two runs have differene Equity curves and  performance analystics
> results.    Since in both runs, the trades(transactions) are the
> same, shouldn't the equity curve and performance results the same?
> Thanks for any general suggestions and advice that I can try to fix
> this first.   If not, I will provide data and simplified code.
>
> thank you all again,
>
> Michael ________________________________ From: R-SIG-Finance
> <[hidden email]> on behalf of Brian G. Peterson
> <[hidden email]> Sent: Wednesday, November 9, 2016 3:13 AM To:
> [hidden email] Subject: Re: [R-SIG-Finance] blotter
> updatePortf
>
> On 11/09/2016 12:41 AM, Michael Chen wrote:
>> Reading these answers reminded me to inquire the same about
>> Quantstrat.  I looked into the code for applyStrategy, I don't see
>> any explicit calls to updatePort.  Is this because in my runs of
>> quanstrat, I didn't use "real time" re-balancing? So, no update
>> was necessary?  Usually, l  just run updatePortf (strategy) which
>> updates every symbol and calculates PnL for each period prices
>> available after I ran applyStrategy in quantstrat.   Please let me
>> know if I am missing something.
>
> updatePortf will be called automatically in quantstrat for
> rebalancing, for paramsets, and for walk.forward. It will only be
> called by the default applyStrategy call if wrapup=TRUE and you're
> using the (experimental, incomplete?) wrapup code.
>
> Regards,
>
> Brian
>
>> on Sunday, November 6, 2016 11:15 AM, Brian G. Peterson wrote: On
>> 11/06/2016 12:10 PM, Cameron McLean wrote:
>>> Is there example code you can share or an existing demo in
>>> quantstrat that shows how to update the portfolio equity curve
>>> and size future orders based on the current amount?
>>
>> Look at any of the rebalancing demos.  There are rebalancing
>> versions of the Faber and macd demos, at least.
>>
>> These rebalance (adjust max trade size) periodically based on
>> current portfolio equity.
>>
>>> A simple example would be something similar to the faber demo
>>> where he invests 20% of equity in each of the 5 asset classes
>>> (currently the faber demo buys and sells lots of 500 shares) or
>>> a more complex example could be using a indicator such as ATR to
>>> size trades based on risk.
>>
>> Sizing based on risk would be done via a custom order sizing
>> function that used the indicator value to adjust trade size.  I
>> believe Ilya has examples of this on his blog.
>>
>> Regards,
>>
>> Brian
>
> _______________________________________________
> [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.
>


--
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.