The ASCII
Importer is used to parse text or CSV files and include the parsed content into
the application's databases. The ASCII imported has many settings that let
you import any kind of data into quotes or custom databases.
N.B. the
downloader plug-in use the ASCII Importer engine to parse the downloaded
data.
To import
data into the application's databases, click on 'Data' in the menu, then select
'ASCII Import'.
Once the
import form opens, select one or many files by clicking on 'Pick files'. If
there are no reference to symbols in your files then you have to associate each
file with a symbol name. To do so, just select a file in the list box, then type
in a symbol name in the text box nearby the button 'Update symbol name', click
on that button to associate a symbol to the file.
Note that you do not have to do that
if there are references to symbols in your files content.
Click on
'Next' to go to the next screen. This screen let you define how to parse the
content of your files, extract dates, symbols, execute script before or after
parsing, associate symbols to groups, markets...
Let us take an example;
we are going to show you how to parse the current lines:
A;01/12/08;12.2;13.3;11.5;12.1;1200 A;01/13/08;12.2;13.3;11.5;12.1;1200 A;01/14/08;12.2;13.3;11.5;12.1;1200
First, we
have to define the separator, in this case its ';'.
We do not
need to escape any lines. We have to choose '/' as a separator for
dates. Since the date format is Mont/Day/Year, we then choose MDY as 'Date
type'. Now we are going to create columns by clicking on the button 'Add
Column'; we need to create seven columns. For each column, we select 'Quotes'
as database. The first column field will be 'Symbol', the second one 'Date',
the third 'Open', the forth 'High', the fifth 'Low', the seventh 'Close', the
eighth 'Volume'.
Click on
'Next' to go to the 'Input & Output' panel. There, you get a sample of your
files content as well as a sample of the parsed content. You have to click
on 'Database->Field' items to see what the output will look like. Click
again on 'Next', so that the application can parse your files. After parsing the
data, you will get the number of errors if any, the number of symbols that will
be added... If during the parsing the engine found errors, go back to the
previous panel and correct the errors; if there are no errors then click on
'Next' to start the importing process.
The columns are used to parse the
content of the files. Look at the 'Import Text or CSV data' paragraph for an
example.
Click on
the Red Cross to remove a column. You can associate a column to a quote or a
custom database; double click on the cells that belong to the 'Database' column
to see the available databases. You can set 'Skip' as a field to skip the
current column.
Automatically add new symbols: Add the new symbols the parser
finds.
"Disable 'Associate new symbols to ...'": Make sure symbols will
not be associated with any market, industry, group or index.
"Replace data if same date": When parsing content, override the old
content.
"Remove old data from database if exists": Before parsing, remove
all the available content for the symbols that are going to be used in the
import process.
"Continue parsing even if there are errors": Continue the parsing
process even if there are errors.
"Text Qualifiers": Text block inside a text qualifiers is treated as a single element.
Example: (comma as separator and double quotes as text qualifiers)
12,"12,5" -> element 1: (12) and element 2: (12.5).
If we haven't specified a text qualifiers, we would have: element1 : (12), element 2: ("12) and element 3: (5")
In the
'ASCII Import' form, set 'Data type' to custom.
The date
format is defined as: [Y]/[M]/[D] [h]:[m]:[s]:[i]
[Y]: year
with four digits, example: 2008. {Y}: year with two digits, example:
08. [M]: month [D]: date [h]: Hour [m]: Month [s]: Second [i]:
Milliseconds
If the date
you want to parse if for example: 12 01 2002 20:10, then set the date format to
[D] [M] [Y] [h]:[m].
Exclude
button:
Exclude
keywords from a date. Example: If your date is "Monday 12/01/2004", before
parsing this date, you should get rid of the word 'Monday'. To do so, click on
'Exclude button' and insert the word 'Monday'.
Replace
button:
Replace a
keyword with another one. Example: If your date is "2001M1" and M1 means
January. You should click on replace button, and then click on 'Add row'. In
that row, you have to type 'M1' under the 'old' column and type '/01/01' under
the 'new column'. The date value will be "2001/01/01".
Pre-Parsing Script is used to
modify content before parsing begins.
Example:
Your content looks like this: A;01/01/2008;A was upgraded by JP
Morgan B;01/01/2008;B was upgraded by JP Morgan C;02/01/2008;C was
downgraded by JP Morgan D;01/01/2008;D was upgraded by JP
Morgan
You want to
create a column that contains data indicating whether the stock was downgraded
or upgraded.
First, we should create four columns; set the databases and
fields.
Now click
on "Pre-Script" button. At any moment you can press on 'CTRL+SPACE' to see
the available variables. In the Pre-Parsing script, we have one variable:
"Content".
"Content"
is of type "PreScript"
"Content" contains the content of each row or line. It also contains two functions: AddRow: Add a new row or line. You must pass the elements to add as a parameter. The number of elements must be equal to the number of elements in the orginal content. There are three elements in our example. GetURLORFileName: Gets the URL of file name of the content we are going to parse.
Each
row contains two variables: 'Data' and 'IsIgnoreLine' "Data" is an array of string:
Contains the parsed line data. In our example: (for line number 1) Data[0]
contains 'A', Data[1] contains '01/01/2008'... "IsIgnoreLine" is a Boolean:
Specify whether to accept or ignore the current line or
row.
The
Pre-Script is executed for each file or document.
In our
example, we want to check if the column number three (referenced by Data[2]
-arrays starts with the index zero-) contains the word 'Upgraded'.
Here
is the script:
for(var i:int = 0;i<Content.Rows.Length;i++)
{
if(Content.Rows[i].Data[2].Contains("Upgraded"))
{
Content.Rows[i].Data[3] = "1";
}
else
{
Content.Rows[i].Data[3]
= "0";
}
}
Now our
forth column value is '1' if the stock was upgraded, otherwise its value will be
'0'. You can remove the 'else' statement in the script and set a default
value of '0' in the forth column.
Post-Parsing Script is used to modify parsed content.
Example
of usage: Look at the parsed symbol quotes and correct bad ticks.
The
Post-Parsing Script contains one variable: "Data"
"Data" is
of type "PostScript" "Data" contains the parsed content for each
date.
Each row contains two variables:
Date: A
date Data: An array of objects (could be numeric 'double' or
'text') for the date referenced by the variable
'Date'
IsIgnoreLine: Specify whether to ignore the current row or not.
The
Post-Script is executed for each symbol.
If your columns are defined
like this: Column 1: Symbol Column 2: Date Column 4: Open Column 5:
High Column 6: Low Column 7: Close Column 8:
Volume
Then
variable 'Data' (of type PostScript) will contains two rows. In the first
row, the variable 'Date' will have '13/12/2008' as value and the variable 'Data'
will be an array. Data[0] = 11 Data[1] = 11 Data[2] = 11 Data[3] =
11 Data[4] = 100
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.