Issue 5/2001 (No. 13)
AmiBroker Tips weekly newsletter.
Issue 5/2001. No 13.
17 February 2001.
Copyright (C)2001 Tomasz Janeczko.
All back issues available from:
http://www.amibroker.com/newsletter/
IN THIS ISSUE
1 Welcome
2 Tip of the week: How to report bugs?
3 User-to-user: How I can automate downloading quotes from a web site rather then file? - by Donald Dalley

1 Welcome

Welcome to the 5th issue of AmiBroker Tips newsletter in the 2001. Last two weeks were really busy for me and that's why I wrote only one issue of the newsletter those days. Among the things I was working on last weeks was AmiBroker 3.49 (BETA) update now available for download from http://www.amibroker.com/bin/ab349beta.zip.This week I will explain a new feature introduced with the 3.47 and 3.49 beta releases called "crash recovery system" and will tell you how to report bugs using this tool. You might think that this is more or less my internal problem but in fact YOU are the beneficiary since less bugs means smoother and leaner work with the software. And the first step to eliminate bugs is to localize them. So I give you some hints how to help me in getting rid of those little creatures :-)

This issue features also the article written by Donald Dalley in response to the question "How I can automate downloading quotes from a web site rather then file?" posted on AmiBroker mailing list. Donald uses AmiBroker for Amiga for a long time and has great experience with automating downloads using portable, multiplatform language called Rebol (also available for Windows platform). He also uses ARexx - an Amiga-based automation and inter-process communication language. With ARexx you can do similar things that JScript allows on Windows. In the article he gives some general remarks on data collection that might be useful for everyone.

By the way - a big "thank-you" goes to Donald for the contribution.

Just a reminder: if you have any comments/suggestions or article ideas, please don't hesitate to drop a line to newsletter@amibroker.com

2 Tip of the week: How to report bugs?

Since version 3.47beta AmiBroker features a new system of detecting and reporting bugs called "Crash recovery system". The name suggests that AmiBroker is now able to recover from such unexpected situations and indeed it can!.

How could this be done? Well... some tricks are needed to wrap the exception handling mechanism used by Windows :-)

Normally when Windows application performs some illegal memory access, illegal operation (for example division by zero) or illegal instruction the system pops the dead-end message box saying "This program has performed an illegal operation and will be shut down". Now you have got no choice - the application is terminated when you click on OK button.

AmiBroker's crash recovery system introduced in v3.47 beta intercepts the exception generated by Windows and instead of standard dead-end message box it displays the following dialog:

As you can see there is a window that displays important system information and there are three buttons Continue, Bug report, Exit program. Clicking on the Exit program button works exactly the same as clicking on "OK" button in the standard Windows dead-end message box. But the first two buttons give you brand new possibilities. If you click on Continue button AmiBroker will try to recover from the error and continue running. In most cases you will be able to save your work and modifications you have made so you will not lose anything. In fact you will be able to work normally. There are however some cases when recovery will not succeed and AmiBroker may be unstable, so it is advised just to save your data and exit. It may also happen that this window will pop up for a couple of times - then you should just click on Continue several times.

The recover function is quite nice but the main purpose of this system is to find and fix the problems in future version and this is why the most important function was provided - Bug report. If you the crash recovery window popped up on your screen please click on Bug report button before attempting to continue work. This will automatically launch your default mail program and prepare the new e-mail with the following information:

To: bugs@amibroker.com
Subject: Bug Report (automatically generated by AmiBroker)

Steps needed to reproduce the bug:
>>PLEASE ENTER THE DESCRIPTION HERE<<

Details:
AmiBroker version 3.49.0

Microsoft Windows Millenium version 4.90 (Build 3000)
Service Pack 0.0

Common Controls version: 5.81

Unhandled exception
Type: CSysException
Code: c0000094
Description: INT DIVIDE BY ZERO
Address: 416a33
HWnd: 0x0328
Msg: 0x0110
wParam: 0x00000388
lParam: 0x00000000

Additional information:

Number of stock loaded: 505
Currently selected stock: a
Number of quotes (current stock): 0

Command history:
2817 - Draw trendlines--Trendline
2820 - Adds a new stock to a workspace--New stock
57619 - Open this workspace

As you can see AmiBroker generates itself most important details for the bug report including even some history of menu selections (Command history) but the most essential thing at this point is to provide the description of steps needed to reproduce the bug. You should just type (in place marked by >>PLEASE ENTER THE DESCRIPTION HERE<<) what you have done before the bug occurred, what special conditions must be met to reproduce it, maybe an AFL formula that you have tried and anything that you suppose might be important. This is critical since automatically generated information is very nice but can not cover all the details. Then, when the bug report is complete just click Send in your mail program to send the report to me (note that address and subject fields are filled in for you).

Some final notes: I have put significant amount of work in making this system reliable, however you should be aware that not all exception and/or system errors could be handled by this system and it may happen that AmiBroker will not be able to recover from some fatal error. It is also possible that this system would not be able to intercept all low level exceptions. In that case just prepare the report by yourself giving me as much details as possible.

Please remember that the final goal is making AmiBroker rock-solid and bug-free. This is what I am working on constantly.

3 Mail bag: How I can automate downloading quotes from a web site rather then file? - by Donald Dalley

This is an excellent question, one which deserves some thought by those that think that they should do this. My hope is that, sometime before the end of this message, you will reconsider just how much control you should give up.

By definition, "downloading quotes" and "file", to me, are the same thing. If you meant directly importing data into AmiBroker, that is somewhat different, because there *may* be no files involved. How easily you can import data
without files will depend upon what format (HTML, ASCII, archive, etc.) your data arrives, what language or other processes you can use, and so on.

As with most of my work, I like to keep things very simple. (Please bear with me as I briefly explain some of what I do to get my data.) Using REBOL as the programming language (it is the most modern and easy-to-use web language that I am aware of today - www.rebol.com) to interface with the Internet, I use small parent programs to get different groups of data pages or files (depending upon the source and time of day) from various sources. This allows me the freedom to get only the data I want, whenever I want it, without getting more than I need. (For example, if the US has a holiday, I can request only the Canadian data that interests me; and one hands-off parent program normally collects *all* of the EOD data for me.)

So far, REBOL gets used only to acquire data and check the integrity of some of it, and ARexx is used to import data and do other things.

All data is saved as files in a few directories, since I may not necessarily want to import that data immediately, and with files, I can both postpone the process or use it immediately. This also allows me the control to not
over-write previously entered data - *this point should be extremely important to you* - and it is the main reason why I still don't directly import data. I want the freedom to make sure the data is what I want to import, *before* it
is imported!

Believe me, I found out the hard way that there is just too much that can go wrong when dealing with data on web pages and from various other free data sources. Some subscription data sites have a possibly higher degree of
reliability, but, based on comments that I have read, they have their problems, too. When dealing with data from different sources that has different tickers for only *some* stocks, you can have even more complications.

Before my ISP blocked the use of a terminal to access their portal, I used one as a medium to immediately, almost directly, import intra-day single quotes into AmiBroker. The process also used a file because it was easy to implement. In about 4 years, I was neither asked nor had the need or desire to personally import data in similar ways, using direct import methods, since I made other efficient ways to acquire and import large amounts of intra-day data, with ease and control, using files. To me, having no-one ever request this ability is both telling and reassuring. (The Amiga has ways which would allow REBOL to access the OS to do this, more so than any of the other platforms for which REBOL/Core or REBOL/View is available, but I haven't tried yet, for the same reasons.)

If more than one execution of AmiBroker is running at the same time and on the same computer, it becomes fairly complicated as to just where the data goes, too. I gave up trying to reliably determine *from an external program* which AmiBroker got the data - but having the particular AmiBroker itself determine this was easy enough. This is mentioned only to point out that added risk is involved, the more complicated things get.

The only time I feel you should even consider entering data without the ability to control the process, though, is if you are 100%, absolutely SURE the data is guaranteed perfectly clean and accurate, every day. I have never
found such a source, anywhere, so you have to determine just how much risk *you* are willing to accept, by not having the option to control how, if or when you enter your imperfect data. The only successful way I found to safely do this is by using hand-made programs with error checking and manipulation of the data, files (to quickly allow checking for the many format changes and errors that frequently crop up; and for archival purposes) and leaving control to the user as to if or when to import that data.

A few more words of caution:

If you are new to using AmiBroker or its importers, be careful as to when you do a Save operation - before or after you enter more data. Using the highest-integrity data (within reason) should be everyone's goal, to lessen any problems. Take nothing for granted. Familiarity with your data is, therefore, paramount!

I am a fond believer in the balance of as much automation as is reasonable, so don't get me wrong - that is one reason I support AmiBroker in the way I do; and I do not consider myself a control freak regarding this. It's just that my experience leads me to think that this is not the place for *total hands-off control*, and that users need to be made aware of some of the pitfalls they may come across, if they try to use it, by presenting some of the risks
involved. When dealing with sometimes large amounts of data that cannot realistically be completely checked daily for possible errors, corruption and ommissions, etc., ignorance is not bliss. This is even more true for the
temporary-data-only sources, in some countries, since there may be no easy way at all to recover from bad/corrupt data.

I think you can now tell that I have little tolerance for data risk, and why.;^)

by Donald Dalley, January 2001


AmiBroker Tips weekly newsletter. Issue 5/2001. Copyright (C)2001 Tomasz Janeczko. All back issues available from: http://www.amibroker.com/newsletter/