Click here to Login





                                                   Comp() in QS language and AMM if no Market Data

  0

0
Alexander Horn
2014-06-21 06:45:21


I have the following AMM OnEndPeriod code I want to run always EOM, even if weekend or no marketdata (different exchanges). How can I make sure the Roc and comp() functions evaluate always the last available close price, so that ranking always includes all symbols even if some have no data?

Looking for something like Roc(12,LASTDATA), guess you have a trick for this?

int LB_Solver =(int)(double)Variables.GetVariable("LB Solver period");
int LB_Mom =(int)(double)Variables.GetVariable("LB Momo period");
string systemrule = "comp(Roc("+LB_Mom+"),'rank!'); ";
MMParser parsesystemrule = Data.ParseFormula("a = " + systemrule);
rank = a[0];

Same question for QS language in formula editor. What happens with comp() if not all symbols have data on this date?



QuantShare
2014-06-21 08:31:07

  0

- What happens with comp() if not all symbols have data on this date?

It will use only symbols that have data. The other symbols are not analyzed at all since they don't have data on that date.
One quick tip: Use the screener to check and verify these kind of things. Type your formula, select your symbols, select a date then check the result.

- In order to include all symbols even if they do not have data, you can use:

getseries("Symbol Name", close)

and parse the formula using the same symbol (the one that has all the data).




Alexander Horn
2014-06-21 14:08:18

  0

Thanks! Tried different versions in below screener, but none includes symbols if they have no data on the selected date. I would like to get the last available close if current bar no data.

LB_Momo = 84;
a = comp(log(GetSeries(Name(),close,LastData)/ ref(GetSeries(Name(),close,LastData),LB_Momo )),"rank!");
b= comp(log(close/ ref(close,LB_Momo)),"rank!");
c = GetSeries(Name(),close,LastData);
addColumn("comp with GetSeries", a);
addColumn("comp without GetSeries", c[3]);
addColumn("GetSeries", c);
filter = 1;

I had some strange switches in my rotation systems, and just figured out it is because of some holidays.. Little tricky thing..



Alexander Horn
2014-06-21 14:17:47

  0

.. and one follow-up question / thought: If prices have different "time gaps" due to different holiday schedules or just missing prices, this then also affects for example correlation / covariance analysis, where "aligned" price / performance data is crucial. For this, the performance data would then need a clean-up, e.g. eliminate prices or set equal to previous if not all tickers have market data this date before calculating performance.

Have looked in the forum, but not found any topic in this line.. Maybe worth a function for more accurate analysis.



QuantShare
2014-06-21 14:20:50

  0

What you are trying to do cannot be done in the screener.
Name() will get the current analyzed symbol so "GetSeries(Name(),close)" is equivalent to "close"

In the MM Script, you can type for example:

string[] symbols = Data.GetSymbols();
foreach(string symbol in symbols)
{
MMParser parser= Data.ParseFormula("a = getseries('" + symbol + "', close);");
TimeSeries a = parser.GetTimeSeries("GOOG", "a"); // Symbol that has all the data
}





QuantShare
2014-06-21 14:22:31

  0

Best Answer
For other functions such as correlation, getseries..., the data is automatically aligned.
The "comp" function is different since it analyzes all symbols at once.



Alexander Horn
2014-06-21 19:48:14

  0

Sorry, once more. Below works, e.g. last price even if no market data. But next question is how to get this into comp() like in first post, e.g. to generate ranking by symbol. I use Top5, so checking just highest score is not an option. If you have a trick, it would be appreciated, if not I build a custom sorting function.

string[] symbols = Data.GetSymbols();
foreach(string symbol in symbols)
{
MMParser parser= Data.ParseFormula("a = getseries('" + symbol + "', close);");
TimeSeries a = parser.GetTimeSeries("GOOG", "a"); // Symbol that has all the data
}







QuantShare
2014-06-23 08:24:25

  0

Jus use the "comp" function. Example:
MMParser parser= Data.ParseFormula("a = comp(getseries('" + symbol + "', close), ' rank');");
Since calculation is based on one symbol here (GOOG), the same bars will be used for all other referenced symbols (GetSeries)



Alexander Horn
2014-06-26 22:46:15

  0

Great, this works great for ranking! Last question to this topic :-)

Now I obviously have some zero values in the return timeseries c below, a.g. at least one of symbols no close data, but set to LastDate and dates are aligned perfectly for comp(). Now, before passing returns to solver, is there any any smart way in QS language to eliminate the c return bars where at least one return is zero, but keeping dates aligned ? If not will do in c# array, but means quite some looping..

MMParser parser= Data.ParseFormula("a = getseries('" + symbolclose + "', close, LastData); b= comp(a,'rank!\); c = log(a/ref(a,1));"); // Get time series aligned to first symbol, but still contains 0 values..
TimeSeries ts = parser.GetTimeSeries(symbolclosefixed, "b"); // Symbol that has all the data



QuantShare
2014-06-28 08:31:20

  0

Usually you will get 0 when it is the first bar or there is no data for a certain security.
If you "A" has data from 2000 to 2010 and you align symbol "C" with data from 2001 to 2010, you will get 0 or Nan data for period 2000-2001 for "C".

You can eliminate first bars only using C#. Needs just two loops here. (one for the securities and one for each trading bar - TimeSeries)




No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Market cap, ROE, ROA and Forward PE for U.S. Stocks - Fundamental...
Oman stock market historical data
Historical EOD data for LSE-listed Stocks and ETFs
Market Rule based on the Crossover Between Stock Close prices and...
PEG and Price to Free Cash Flow above Market Averages

How-to Lessons
How to speed up watchlist and screener plug-ins when working with...
How to download and use U.S. stocks earnings data
How to create trading rules based on Put and Call volume data
How to quickly download the most recent EOD data for your stocks
How to download EOD quotes for active and valid stocks only

Related Forum Threads
MAJOR WORLD MARKET DATA
Historical Market Cap Data For Delisted Stocks
Create and Export each database for each market
Can I download EOD data a few hours after market closed?
Performance of parsing a QS language function in AMM

Blog Posts
6 ways to download free intraday and tick data for the U.S. stock...
3 Market Indicators based on Fundamental Data
How to create a trading system, screen and composite using earnin...
Historical Market Data
4 Market Composite Indicators Based on Industry Data









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.