Click here to Login









Automated Parsing in QS Trading Software

Updated on 2010-12-14





Almost everything can be automated in QuantShare.
Imagine the following scenario: A trader downloads some files from a server or another PC every day and saves them into the hard drive. The trader opens then the ASCII Importer tools of QS Trading Software, adds the previously downloaded files then parses the data and inserts it in the database.

Let us start automating this process; first, we can create a download item and use it instead of the ASCII Importer for the parsing and insertion of the data/quotes. The advantage is that with a single click (We can add the download item in the bookmark panel) the downloader can read a directory and automatically parses its files. To prevent it from parsing old files, we can read the "LastAccessTime" attribute of each file and ignore those that are older than a few minutes or seconds.

Here is an example of a URL-Script that allows you to perform this: (Update Download Item -> Settings -> Create a URL-Script)

string dir = @"C:\myfiles";
string[] files = System.IO.Directory.GetFiles(dir);
for(int i=0;i < files.Length;i++)
{
System.IO.FileInfo info = new System.IO.FileInfo(files[i]);
TimeSpan ts = DateTime.Now.Subtract(info.LastAccessTime);
if(ts.TotalSeconds < 60)
{
Functions.AddURL(files[i], "Parsing...");
}
}

To further automate the process and make it fully automated, we will need something that detects whenever a change occurs in a specific directory (file added or updated). This can be done using the "Task Manager" plug-in.


A fully Automated Process

First, we must create a Global Script that starts and executes the download item we have previously created.
Select Tools -> Script Editor, create a new script then type the following formula:
Downloader.StartDownloader("Download Item Name");

In the "Task Manager" plug-in (Tools -> Task Manager), create a new task and select "File based task" tab. Select directory, click on "Add" and select the directory that you want to monitor.
In the "Run" panel select "Changed" and in the "Scripts" panel, select the previously created script, type the task name then save it.

That is it, we have just created an automated parsing process in QuantShare trading software.

Now each time our trader adds or modifies a file in the monitored directory, the task manager executes the corresponding task, which in turn executes a script that starts the parsing process.











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

QS Trading Software: Global Script
Posted 5152 days ago

Stock Market Prediction
Posted 5180 days ago


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.