SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon May 29, 2023 4:45 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Fri Nov 30, 2007 9:14 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
The code below demonstrates how to write a simple script that adds new instruments to the instrument data base and application instrument list.

This example can be found in the Script Explorer among other script samples.

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  
 
 Post subject: strategy.instruments??
PostPosted: Thu Jan 15, 2009 5:28 pm 
Offline

Joined: Fri Jan 02, 2009 9:31 pm
Posts: 16
hi! how to add the instruments not to the global instrument list, but to the strategy instrument list? If it is not possible when the strategy is running, how to add the instruments to a strategy BEFORE it is running? Any code snippet available out there??
It can't be true that it might be necessary to add 1000s of symbols/instruments manually to each strategy??????
thanks!


Top
 Profile  
 
PostPosted: Wed May 20, 2009 4:02 pm 
Offline

Joined: Wed Apr 01, 2009 4:20 pm
Posts: 2
ophth1 wrote:
hi! how to add the instruments not to the global instrument list, but to the strategy instrument list? If it is not possible when the strategy is running, how to add the instruments to a strategy BEFORE it is running? Any code snippet available out there??
It can't be true that it might be necessary to add 1000s of symbols/instruments manually to each strategy??????
thanks!


Very good question. I have the same needs.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 02, 2009 5:37 pm 
Offline

Joined: Sat Aug 01, 2009 10:37 pm
Posts: 15
Hi, I am considering OQ and I would also like to know if the above is possible.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 04, 2009 3:40 pm 
Offline

Joined: Mon Mar 05, 2007 7:02 am
Posts: 58
Each OpenQuant project file (i.e. ABCD.oqp) is an XML file so I just generate the instrument symbols to manually add to the file.

This works very well.

Code:
<?xml version="1.0" encoding="utf-16"?>
<!--project file-->
<project schemaVersion="1" name="ABCD" description="" version="1" lang="CSharp">
  <intruments>
    <instrument symbol="A" />
    <instrument symbol="AA" />
    <instrument symbol="AAI" />
    <instrument symbol="AAP" />
    <instrument symbol="AAPL" />
  </intruments>
  <properties>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 08, 2009 10:31 pm 
Offline

Joined: Sat Sep 26, 2009 12:08 am
Posts: 62
Location: Ireland
Dr. Anton Fokin wrote: "This example can be found in the Script Explorer among other script samples".

Where is the "Script Explorer"?
Does he just mean the samples installed with OQ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 08, 2009 10:39 pm 
Offline

Joined: Thu Jun 08, 2006 3:56 pm
Posts: 537
Location: BC Canada
Menu View -> Show Script Explorer

The script explorer then appears in the same top right window pane as the solution explorer, but on a different tab.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 09, 2009 5:47 am 
Offline

Joined: Sat Sep 26, 2009 12:08 am
Posts: 62
Location: Ireland
Oh, that. Only a couple scripts in there including "hello world".
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 14, 2010 7:55 am 
Offline

Joined: Wed Mar 10, 2010 1:42 am
Posts: 63
is there a way to get the list of symbols in the global list? or a way to remove symbols in the list?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 14, 2010 11:28 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Hi,


InstrumentManager.Instruments;
InstrumentManager.Remove(...);

Regards,
Anton


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 08, 2010 5:10 pm 
Offline

Joined: Mon May 21, 2007 2:51 pm
Posts: 30
Any hint how you can add additional parameters to the instrument list, e.g. Exchange or any other property field?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 08, 2010 5:31 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Click on an instrument and edit its properties in the Porperties window?

Regards,
Anton


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 08, 2010 5:33 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Or you mean you want to do it programmatically?


Top
 Profile  
 
PostPosted: Sat Nov 06, 2010 5:03 pm 
Offline

Joined: Mon May 21, 2007 2:51 pm
Posts: 30
yep .. i figured out in the meantime .. thanks


for each Intstrument of MyList

Instrument instrument = InstrumentManager.Instrument[symbol];

instrument.xxx = yyy;


Top
 Profile  
 
PostPosted: Sat Jan 22, 2011 10:16 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Now you can use solution scenario to add instruments to solution instrument list programmatically

viewtopic.php?f=64&t=8636

Regards,
Anton


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 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:  
cron
Powered by phpBB® Forum Software © phpBB Group