Index | Recent Threads | Who's Online | Search

Posts: 116    Pages: 12    Prev 1 2 3 4 5 6 7 8 9 10 Next
Last Post
This topic has been viewed 4835 times and has 115 replies
geov
Re: Factor and data series importing


The data series function just like custom series. Once you save a data series, you can chart it and then use the values with GetSeries. GetSeries is used in the series parameter for a number of commands, including Close, SMA, EMA, etc.

So, for example, let’s say you upload the FRED data for the US leading index. And let’s say you only want to invest when the index is 0.5% or higher. So you copy the USSLIND data from FRED, open the data series tool, upload the CSV file, give it a name (say “USSLIND”), and then in your buy rule, or a screener rule, you can specify Close(0,GetSeries(“USSLIND”)) > 0.5.

I just tested this. One has to be careful here. The BUY and SELL signals from an indicator must have a Friday date for Monday trades, other wise if the signals have a Monday date then the trades occur a week late on the following Monday.

Jan 5, 2020 2:00:46 PM       
geov
Re: Factor and data series importing

This new tool works well. Thank you P123 team.

Here is SPY-IEF timed with the growth rate of iMarketSignals Business Cycle Index, BCIg.
You can download the BCI series here to try it out.
https://imarketsignals.com/bci/

There are only 3 periods of SPY investment and 2 for IEF.
Much better than buy-and-hold SPY.

Attachment BCIg Series.png (191422 bytes) (Download count: 141)


Jan 5, 2020 4:47:25 PM       
InmanRoshi
Re: Factor and data series importing

Here is a simple example of portfolio following a 50/200 SMA trend hedge of it's own performance. This simple port is just yuval's Core Combination rank against the Prussell 3000 with a Buy/Sell rule Rank > 90 with 50 positions (the max for my membership) with variable slippage on the next open. The hedge is off a data series that took all of 2 minutes to create and significantly lowered drawn down, raised sharpe without hurting overall performance. The model simply moves to short term bonds when it is out of favor and gets back in the market when it's back in favor.

It's pretty common to use a trend timing methods against a SP500, but if your model is skewed more towards something like small cap value and is not highly correlated with the SP500, why not just use your own index that reflects your model? What do you care if the SP500 is trending down if your model is flying high?

Next step is to create several portfolios that (in theory) have lowered correlation ... likes say small cap value portfolio vs. large cap growth portfolio... and toggles in and out between them using their own trends and the Portfolio function in nested Evals.


https://www.portfolio123.com/port_summary.jsp?portid=1595820

Attachment CoreWithTrend.JPG (98837 bytes) (Download count: 120)


Attachment CoreWithoutTrend.JPG (99201 bytes) (Download count: 119)


Jan 7, 2020 8:29:25 AM       
Edit 10 times, last edit by InmanRoshi at Jan 7, 2020 9:10:03 AM
geov
Re: Factor and data series importing

InmanRoshi,
How did you determine the Series "CoreWithTrend" from the performance of the model?

Jan 7, 2020 10:23:34 AM       
InmanRoshi
Re: Factor and data series importing

Just ran a simulation of the portfolio over the maximum timeframe and exported the results into CSV keeping the Date and Total Equity column, then fed it into a new custom Data Series. If you wanted to follow the port live, you would have to refresh the series data with for every port rebalance by repeating the same process .. but it takes 2 minutes to do (max).

Attachment trend.JPG (66831 bytes) (Download count: 118)


Jan 7, 2020 10:33:23 AM       
Edit 4 times, last edit by InmanRoshi at Jan 7, 2020 10:55:22 AM
geov
Re: Factor and data series importing

Thanks, that's what I thought you did.

It would be nice to have a dynamic series which does that. Perhaps P123 can make a variation of TotMktVal which references the port ID, like TotMktVal(portID).

Jan 7, 2020 10:58:23 AM       
wwasilev
Re: Factor and data series importing

Perhaps P123 can make a variation of TotMktVal which references the port ID, like TotMktVal(portID).


You can *almost* do that now with the #Equity scope.

First in a buy rule;
isNA(SMA(50,0,#Equity)>SMA(200,0,#Equity),True) // need isNA to get the ball rolling


Next add the complementary logic as a sell rule;
!isNA(SMA(50,0,#Equity)>SMA(200,0,#Equity),True)


Now there's a problem. When this sell rule triggers, all the holding are sold. Because of that, the equity curve can't change and the previous buy rule will never go true.

One solution is to modify the buy rule to trigger on an external event;
(isNA(SMA(50,0,#Equity)>SMA(200,0,#Equity),True)) | (SMA(50,0,$SP500)>SMA(200,0,$SP500))


But that changes the intent somewhat. This part needs more work. Maybe some qualifier with CashPct.

I think the custom series method also will suffer from the flat equity curve problem when processed in real-time (but I didn't test that).

Walter

Jan 7, 2020 12:27:29 PM       
Edit 2 times, last edit by wwasilev at Jan 7, 2020 12:34:40 PM
geov
Re: Factor and data series importing

Walter, the problem with this method is that the SMA of #Equity (Portfolio/Sim total value) would then include the periods when you are not in stocks. So for the trend to be correctly identified you need 2 identical Ports, one to get the trend from and the other where the trend formula is applied to. The same applies to InmanRoshi method.

The idea is to have a self correcting strategy. As long as the strategy makes money it is used, and when the trend is against you, one would get out of stocks, or apply a hedge.

Jan 7, 2020 12:57:14 PM       
Edit 1 times, last edit by geov at Jan 7, 2020 12:58:58 PM
wwasilev
Re: Factor and data series importing

Agreed and that's why strictly self-referential solutions won't work.

Jan 7, 2020 1:01:51 PM       
Edit 1 times, last edit by wwasilev at Jan 7, 2020 1:06:38 PM
geov
Re: Factor and data series importing

There is another issue I have found with "Stock Factors" which is important.

Be aware, that one cannot overwrite Stock Factor data by simply uploading another CSV file to a $$ file.
What happens is that the old data is retained and the new data is added to it.

However it is a very neat addition to P123.
Here are market timer rules for the iM Business Cycle growth, BCIg.
When BCIg >=6 invest in stocks.
When BCIg <5.5 sell stocks and invest in bonds.

Buy: Eval(close(0,GetSeries("BCIg"))>=6,$$Stocks=1,$$Bonds=1)
Sell: Eval(close(0,GetSeries("BCIg"))<5.5,$$Stocks=1,$$Bonds=1)

$$Stocks: SPY, QQQ, VIG
$$Bonds: IEF, TIP, UST

Attachment Stocks or Bonds with BCIg.png (154778 bytes) (Download count: 86)


Jan 8, 2020 3:18:02 PM       
Edit 2 times, last edit by geov at Jan 8, 2020 3:30:32 PM
Posts: 116    Pages: 12    Prev 1 2 3 4 5 6 7 8 9 10 Next
 Last Post