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.
|