Investment Studio > Views > Downloads > Downloader > Single item editor

The single item editor can be used to inspect and modify all of a download item's properties. To open it, select one item in the Downloads view, then use the pop-up menu in the item box (click Properties) or click in the toolbar (if the downloader is not already running, it will be launched first).

Item properties with underlined names are mandatory. The OK (save and close) button at the bottom of the single item editor is enabled only when all such properties are set to reasonable-looking values.

Click in the dialog's upper right corner to close the dialog and discard any changes; click OK to commit to the new settings.

The editor's controls are organized in five groups. From top to bottom, they are used to set up:

Basic Item properties
Script Arguments
Source data URL
Authentication
Active parsing

Basic Item properties

Use these controls to set the basic item properties displayed in the Downloads view (name, symbol and currency) and the path to the target file where the extracted data is stored:

Name and data path are mandatory. To enter the name, either type it into the name box or click the spin button in the box to choose from a list of recent names. To enter the data path, either type it into the data path box or click to select the data file using a standard Save File dialog.

Note the use of the symbolic directory name "<QUOTES>" in the picture. You don't need to enter such symbolic names manually; the editor will automatically substitute them for actual directory paths wherever possible.

All generic (non-forex) quotes should be stored under <QUOTES>, preferably structured in subdirectories (like "INDEX SHARES" in the picture). Currency conversion tables must be kept in the <FOREX> directory. Other data, e.g. images downloaded from the web, should be stored in their own subdirectories under <DATA>.

When the path to an existing file is entered, the editor will try to read its contents and display them as plain text in the beveled box at the bottom of the control group. Use the buttons to the right to scroll through the file:

 

To first row.

Scroll up one row.
 

To last row.

Scroll down one row.

If active parsing is used, the top row (highlighted in blue) can be used to test the Target format setting (see active parsing below).

Though informative, the symbol and currency properties are not essential and may be left blank; they are displayed in the Downloads view, but the downloader doesn't need them. Their primary role is to provide default settings for assets added to the Assets view.

Symbols are free format, but you should try to keep them no longer than five characters, preferably capital letters only. Click the spin button in the symbol box for a list of recent symbols.

Currency codes should be consistent with the filenames in the <FOREX> directory, which are based on ISO codes (two-letter country code + one-letter currency code). All currency codes are therefore truncated to three characters. Type them directly into the currency box or click to open a currency selection dialog.

Script Arguments

If you use scripts for URL generation and/or data parsing, you can specify up to four arguments which will be passed to the script(s) through the downloader's ActiveX interface:

All arguments are passed as strings. Depending on the context, type conversion (typically to numbers) may be performed automatically by the scripting language as the need arises or it may have to be performed explicitly.

If you need more than four arguments, chances are that you are trying to do too much with a single script method. Consider providing multiple entry points into your script, each implying some argument values, or using a lookup table which can be indexed into with a single argument. Another possibility is to pass multiple values as a single argument using a comma-separated list, and then split the list in the script.

Source data URL

The URL (Uniform Resource Locator) specifies the location of the data to be retrieved by the downloader. A URL can be static (specified as a simple string once and for all) or it can be dynamically generated by a script every time it's needed (e.g. if it contains date-dependent information).

To use a static URL

  1. Select the Static radio button;
  2. choose protocol ("file:///" for a local file, "http://" for data fetched from a web server, "ftp://" for data fetched from an FTP server) in the combo box next to the radio button; and
  3. type the rest of the URL into the long combo box, or click the spin button in the box to choose from a list of recent URLs.

  If the "file:///" protocol is selected, you can also click next to the URL box to select an existing source file using a standard Open File dialog, instead of typing the file's path manually. Either way, if the specified file exists, the editor will try to read its contents and display them as plain text in the beveled box below the URL. Use the buttons to the right to scroll through the file:
 
 

To first row.

Scroll up one row.
 

To last row.

Scroll down one row.
  If active parsing is used, the top row (highlighted in blue) can be used to test source data parsing (see active parsing below).

In the screenshot above, the local file "<TEMP>1.TMP" is a statically specified data source. The file exists, so its contents are being displayed. "<TEMP>" is a symbolic directory name. You don't need to enter such symbolic names manually; the editor will automatically substitute them for actual directory paths wherever possible.

To use a dynamically generated URL

  1. Select the Script radio button;
  2. type the path to the script file in the edit box next to the Script radio button, or click next to the edit box to choose the script file using a standard Open File dialog;
  3. type the name of the URL method into the Method box, or click the spin button in the box to choose from a list of recent URL methods;
  4. select the appropriate ActiveX Scripting engine for the script in the Engine combo box.

  If the URL method requires one or more arguments, you also need to enter those under Arguments.

Note the use of the symbolic directory name "<SCRIPTS>" in the picture. You don't need to enter such symbolic names manually; the editor will automatically substitute them for actual directory paths wherever possible.

It's recommended that all downloader scripts be stored under <SCRIPTS>.

To view (and edit) the script code, click . This opens the downloader's script editor with the script file loaded.

Downloader script methods can return one or more URLs using the downloader's ActiveX interface. To test the specified URL method, click .

The last URL returned by the test run will be reported in the static URL fields at the top of the control group.

HTTP and FTP URLs can identify a server using its name or its IP number. The server identifier can also be followed by a port number (separated by a colon, ":") to force connection through a non-standard server port. For instance, the HTTP URL "www.a-server.net:8080/a-directory/a-file.htm" means "connect to the server called 'www.a-server.net' using server port 8080 instead of the standard HTTP server port and grab the file 'a-file.htm' in the directory '/a-directory/'".

Authentication

HTTP and FTP servers can require clients to provide authentication (valid user ID and password pairs) in order to process service requests. The downloader supports standard authentication schemes (Basic Authentication with HTTP, session login with FTP). To retrieve data from a server relying on such a scheme, enter your user ID and password in the Authentication fields:

Leaving both fields blank causes the downloader to answer login requests with "anonymous" for the user ID and with your e-mail address (as specified in Internet Explorer) for the password. To make it use a blank password, specify a non-blank user ID (e.g. "anonymous") but leave the password blank.

Some servers (especially on the web) use non-standard login schemes which require special solutions, like a login sequence implemented at the script level. Some do their best to prevent automated logins. If everything else fails, download the data to a local file using your ordinary web browser, then let the downloader import it from the file.

Warning: While the password is hidden in the user interface, it can be read from your hard drive (along with the user ID) by anyone who has access to your files. You can prevent unauthorized access by encrypting your <DLISTS> directory. Under Windows 2000 and XP Professional, you can encrypt and password-protect directories using the EFS (Encrypting File System) features built into Windows. Under all Windows versions from 95 and up, you can also use third party disk encryption tools like PGPdisk (http://www.pgpi.org) or DriveCrypt (http://www.drivecrypt.com).

Active parsing

The data retrieved by the downloader can either be ready for use "as is" (e.g. images or PDF documents) or require further processing before it can be incorporated into Investment Studio's database.

If the data is ready for use as is, simply make sure that the check box in the upper left corner of the Active parsing group is unchecked. Whatever is retrieved by the downloader will then simply be transferred to the data path specified in the item group, unaffected by any other Active parsing settings (they are just ignored). New data will overwrite all previously retrieved data.
If the data requires further processing, make sure that the check box in the upper left corner of the group is checked, then decide whether to use a source format string or a script.

Format strings are easy to use and can often be quite sufficient. The source data must be in text form, preferably tabular: one record per row, each record containing a date and one or more quotes (open, high, low, close, volume, open interest, bid, ask, bid size and/or ask size). The source format string is applied to every row, one row at a time. Rows which do not match the specified format are simply ignored; headers and comments embedded in the data are therefore not a problem. Rows which do match the specified format have their data first extracted and then added to the target data file in a format specified by a second (target) format string.

Scripts are much more flexible. The source data can be in any format, as long as you know how to write a parser for it. The choice of output format is also free. If you are only extracting quote records (a date and an open, high, low, close, volume, open interest, bid, ask, bid size and/or ask size) the recommended method is to return them to the downloader through its ActiveX interface and let the downloader add them to the target data file according to a target format string. But scripts can also write directly to target files.

When a target format string is used to update the target data file, old records in the file are overwritten only if there are new records for the same dates, in which case newer records replace older ones.

To parse source data using a format string

  1. Select the Format radio button;
  2. type the source format string (used to parse raw data retrieved by the downloader) into the Format combo box, or click its spin button to choose from a list of recent input format strings;
  3. type the Target format string (used to write quote records to the the target data file) into the combo box at the bottom of the control group, or click its spin button to choose from a list of recent target format strings.

  Format string syntax is described in detail here. Right-click the format string boxes to select format string elements from a menu.

If a local file is loaded in the source URL file viewer, you can click the Test button next to the source Format box to try out the source format string. The highlighted row in the file viewer will be parsed and the result presented in a pop-up window:

  The screenshot above shows a successful test. "Open Interest" and subsequent fields are grayed out in the test report since they are not specified in the source format string. If they had been, the result would have looked like this:

  This is a partially failed test: "Open Interest" etc. are displayed in red since the format string specifies those fields, but the corresponding values are not present in the data. The failure is only partial since the date and five quote fields could be successfully extracted. In a real update run, the downloader would therefore be able to add at least some data from the source record to the target data file.

Empty quote fields are not considered fatal mismatches. A missing or incomplete date on the other hand would cause the entire record to be discarded, as would the occurrence of one or more unexpected characters.

If the target data path specified under Item points to a file containing some data, you can click the Test button next to the source Format box to try out the target format string on the highlighted row in the Item control group's file viewer. This works quite analogously to the source format string test.

To parse source data using a script

  1. Select the Script radio button;
  2. type the path to the script file in the edit box next to the Script radio button, or click next to the edit box to choose the script file using a standard Open File dialog;
  3. type the name of the parser method into the Method box, or click the spin button in the box to choose from a list of recent parser methods;
  4. select the appropriate ActiveX Scripting engine for the script in the Engine combo box;
  5. if the parser method returns quote records using the downloader's ActiveX interface (instead of writing free-format data directly to the the destination file), type the Target format string (used to write quote records to the target data file) into the combo box at the bottom of the control group, or click its spin button to choose from a list of recent target format strings. Format string syntax is described in detail here. Right-click the format string box to select format string elements from a menu.

  If the parser method requires one or more arguments, you also need to enter those under Arguments.

Note the use of the symbolic directory name "<SCRIPTS>" in the picture. You don't need to enter such symbolic names manually; the editor will automatically substitute them for actual directory paths wherever possible.

It's recommended that all downloader scripts be stored under <SCRIPTS>.

To view (and edit) the script code, click . This opens the downloader's script editor with the script file loaded.

The parser method can return one or more quote records through the downloader's ActiveX interface. If a local file is loaded in the source URL file viewer, you can click the button next to the Method box to test the parser on that file. All records returned by the parser will be presented in a pop-up window as they would normally be written to the target data file, i.e. as specified by the Target format string:

 
Warning: This kind of test relies on the parser method to use the downloader's ActiveX interface for returning quote records. If the script writes data directly to the target file, the test will be destructive, i.e. it will actually modify the designated target file. You can use a temporary target file and the file viewer in the Item control group to test such scripts.

If the target data path specified under Item points to a file containing some data, you can click the Test button next to the source Format box to try out the target format string on the highlighted row in the Item control group's file viewer. This works quite analogously to the source format string tests described above.

   
Tip: When setting up active parsing for an online data source, use the browser in the Downloads view to download a sample of the data to a local file, then use that file as a static URL to test your format strings or scripts until you're satisfied that they are working properly.