Click here to Login









Download Trading Data using the Post-Script

Updated on 2011-03-09





Here is how the downloader works:

- It takes the URL that is specified in the settings or executes a URL-Script to get that URL dynamically.
- It downloads data from the URL(s) and sends it to Pre-Script (If it is defined). This script can then modify the content or add custom rows.
- Before the data is inserted into the database(s), it is sent to the Post-Script (If it is defined). This script lets you update the parsed data before it is inserted.

The Post-Script is executed for every symbol/security. It contains a variable "Data" that has the following fields:
SymbolInfo: Information about the security, such as the ticker name, market, index, address...
Rows: An array of elements where each element references a date and an array of values. These values refer to the columns you have specified in the parser settings form.

Here is a sample data example: (Symbol, Date, Close, Open, High, Low and Volume),
MSFT;04-01-2010;12.5;12.6;12.6;12.5;2554
MSFT;03-01-2010;-;-;-;-;-
A;04-01-2010;12.5;12.6;12.6;12.5;2554
A;03-01-2010;12.5;12.6;12.6;12.5;2554

After the above data is parsed, the Post-Script is executed twice. One time for the symbol "MSFT" and another time for the symbol "A".
For each symbol, the variable "Rows" will contain two elements. The first element references the first date "03-01-2010" and the second one references "04-01-2010".

In the first element (Data.Rows[0]), you can access the close, open, high, low and volume prices using the property "Data".
To access the close price of the first date for example, you should type:
double close = (double)Data.Rows[0].Data[0];

The value returned by the "Data" property is of type "Object". This is because the value could be numeric or text, depending on the associated database/field.
Therefore, if the value is numeric then it should be casted to double by preceding it with "(double)" and if the value is a text then it should be casted to string by preceding it with "(string)".


Ignore a specific date

You can ignore a specific date by accessing the element pointing to it and then setting the "IsIgnoreLine" property to true.

Example:
for(int i=0;i < Data.Rows.Length;i++)
{
if((double)Data.Rows[i].Data[0] == 0)
{
Data.Rows[i].IsIgnoreLine = true;
}
}

The above script ignores dates if the corresponding close price is equal to zero. "Close" is the first element; consequently, it has an index of zero.


Recent posts about the downloader plug-in

Trading Items: Data Download using .Net Scripts
Download Trading Data using the URL-Script
Download Trading Data using the Pre-Script












no comments (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1461 days ago

Profile Graphs
Posted 1566 days ago

QuantShare
Previous Posts

More Posts

Back







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.