SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Oct 19, 2020 6:04 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Nov 30, 2007 8:02 pm 
Offline

Joined: Sat Jul 24, 2004 12:40 am
Posts: 77
Location: Odessa, Florida
I hqve a text file that contains the ticker symbol and names of all the stocks and indexes I am interested in using my strategy on. I know that I can manually add them to the list of stocks in the instrument window, but doing this to 500 stocks or more would be too tedious. I know from asking this question previously that I can use the OnStrategyStart event to open my text file and read all the symbols and create instruments with the Instrument object constructor. Based on what I've read in the help file I assume that I can do the following:
Instrument stk = new Instrument("C",InstrumentType.Stock)
or
Instrument dji = new Instrument("^DJI",InstrumentType.Index)

The documentation says that the constructor automatically adds the instrument to the database. Does that also mean that the stock (or index) is automatically added to the "Stock" or "Index" folders or is there a method I must use to add a particular instrument to a particular folder?

A short code sample showing how to automatically add stocks would be appreciated.
Another part of the question is the following:
How do I create an instrument (for example IBM) with different time scales? By this I mean, how do I create an IBM that is made from Daily bars, another IBM made from weekly bars, one from Monthly bars and finally one from Intraday, 1 minute bars?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 30, 2007 8:50 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
You have this sample below in the script explorer. Have you seen it? Instruments are sorted by instrument type, so stocks will be automatically added in the stocks folder in the GUI.


Code:
using System;

using OpenQuant.API;
using OpenQuant.API.Indicators;

public class MyScript : Script
{
   public override void Run()
   {
      string[] symbols = new string[] {"Stock1", "Stock2", "Stock3"};
      
      foreach (string symbol in symbols)
         new Instrument(InstrumentType.Stock, symbol);
   }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group