Keith
I modified TJ’s script to identify tickers with no quotations’
var oAB = new ActiveXObject("Broker.Application");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var Shell = new ActiveXObject("WScript.Shell");
var oStocks = oAB.Stocks;
var StockQty = oStocks.Count;
var NumNoQuote = 0;
f = fso.OpenTextFile( "C:\\Amibroker\\TickersWithNoQuotations.txt", 2, true );
for( i = 0; i < StockQty; i++ )
{
oStock = oStocks(i);
var Qty = oStock.Quotations.Count;
var StockTicker = oStock.Ticker;
if( Qty == 0 )
{
NumNoQuote++;
f.WriteLine( StockTicker );
//WScript.Echo("Stock is " + NumNoQuote + " " + StockTicker);
}
}
f.Close();
WScript.Echo("Script finished. There are " + StockQty + " Tickers in the database of which " + NumNoQuote + " tickers don't have quotation.");
From: amibroker@yahoogroups.com [mailto:amibroker@yahoogroups.com]
Sent: Monday, June 27, 2016 4:56 PM
To: amibroker@yahoogroups.com
Subject: Re: [amibroker] fputs() misses some strings
TJ --
In that case, is there any way, using AB (or something else), to produce a list of all such stocks?
I would like to do so, without manually going through my entire data bases.
I will now contact my data supplier, and try to find out why I have stocks without data, and what to do about it.
Again, thank you so much for your help.
-- Keith
On 6/27/2016 6:22 PM, Tomasz Janeczko groups@amibroker.com [amibroker] wrote:
Hello,
No, Analysis window SKIPS symbols without data.
Best regards,
Tomasz Janeczko
amibroker.comOn 2016-06-27 23:08, Keith McCombs kmccombs@engineer.com [amibroker] wrote:
TJ --
Thank you for your rapid reply.
I just now discovered that the 10 stocks that were not printed by fputs() had NO data. I wasn't expecting that, and it took hours (more like days) to find.
BTW, I would have thought that even with no data, the Name() and FullName() should have been printed.
It would be very nice if it did.
Thanks again.
-- KeithOn 6/27/2016 10:49 AM, Tomasz Janeczko groups@amibroker.com [amibroker] wrote:
Hello,
Thank you very much for your e-mail.
You are using file functions (esp. fopen) incorrectly (without "shared" flag).
Correct code is here:
http://www.amibroker.com/kb/2016/01/27/how-to-write-to-single-shared-file-in-multi-threaded-scenario/
Best regards,
Tomasz Janeczko
amibroker.comOn 2016-06-27 09:47, Keith McCombs kmccombs@engineer.com [amibroker] wrote:
Hi --
I'm trying to output a string containing Symbol, Fullname, Firstdate, Lastdate, and Numberofbars for all symbols in a watchlist to a file using fputs(). With watchlists longer than only a few symbols, one or more strings are always missing. For example for a watchlist containing 83 symbols, only 73 are output (not always the same 73 though). This happens using either Explore and Scan.
I believe the problem is related to Analysis multithreading. And tried to fix it using semaphore (identical to that of Example 2 in the AB manual). Please see code snippets below for the relevant parts:function_TryEnterCS(secname){global _cursec;_cursec="";// try obtaining semaphore for 1000 msfor(i =0; i <1000; i++){if(StaticVarCompareExchange(secname,1,0) == 0){_cursec = secname;break;}else ThreadSleep(10);//sleep one millisecond}return _cursec !="";}// call it ONLY when _TryEnterCS returned TRUE !function_LeaveCS(){global _cursec;if(_cursec !=""){StaticVarSet(_cursec,0);_cursec ="";}}if(stocknumber == 0){StaticVarRemove("*");StaticVarSet("DelistedListActive", False);fdelete(f1filename);text1 = "SYM,NAME,FIRST,LAST,BARS\n";fh1 = fopen(f1filename, "a");if(fh1){fputs(text1, fh1);fclose(fh1);StaticVarSet("DelistedListActive", True);}else _trace("Opening fh1 failed, stocknum0\n");}if(StaticVarGet("DelistedListActive") == True){datearray = DateNum();first = int(datearray[0]);last = int(datearray[BarCount - 1]);firststr = DateNumToStr(first);laststr = DateNumToStr(last);barsstr = NumToStr(BarCount, 1.0, False);for(i=10; i>0; --i){ // for large data, need to try multiple timesif(_TryEnterCS("semifh1")) break; // successful}if(i>0){ // in 10 or less triesfor(j=10; j>0; --j){ // fopen may need multiple triesfh1 = fopen(f1filename, "a");if(fh1){fputs(Name() + "," + FullName() + "," + firststr + "," + laststr + "," + barsstr + "\n", fh1);fclose(fh1);_LeaveCS();break; // out of for()}else{ // if(j<=0){_TRACE("Missed fh1 for stocknum: " + NumToStr(Status("Stocknum")) + "\n");}}if(j<=0) PopupWindow("Failed to EnterCS for " + Name(), "AB Warning", 0);}else PopupWindow("Failed to EnterCS for " + Name(), "AB Warning", 0);}
BTW, the _TRACE() AND PopupWindow() functions for trouble shooting. But, they never display.
Any and all help would be appreciated.
Thank you.
-- Keith
Posted by: "TA" <tagroups@sbcglobal.net>
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (7) |
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
EmoticonEmoticon