SmartQuant Discussion
http://www.smartquant.com/forums/

How to add new instruments programatically
http://www.smartquant.com/forums/viewtopic.php?f=64&t=6233
Page 1 of 1

Author:  Dr. Anton Fokin [ Fri Nov 30, 2007 9:14 pm ]
Post subject:  How to add new instruments programatically

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);
   }
}

Author:  ophth1 [ Thu Jan 15, 2009 5:28 pm ]
Post subject:  strategy.instruments??

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!

Author:  14417335 [ Wed May 20, 2009 4:02 pm ]
Post subject:  Re: strategy.instruments??

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.

Author:  Technician [ Sun Aug 02, 2009 5:37 pm ]
Post subject: 

Hi, I am considering OQ and I would also like to know if the above is possible.

Author:  EDetterman [ Tue Aug 04, 2009 3:40 pm ]
Post subject: 

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>

Author:  warren631 [ Sun Nov 08, 2009 10:31 pm ]
Post subject: 

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?

Author:  kkkwj [ Sun Nov 08, 2009 10:39 pm ]
Post subject: 

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.

Author:  warren631 [ Mon Nov 09, 2009 5:47 am ]
Post subject: 

Oh, that. Only a couple scripts in there including "hello world".
Thanks.

Author:  scrubolio [ Sun Mar 14, 2010 7:55 am ]
Post subject: 

is there a way to get the list of symbols in the global list? or a way to remove symbols in the list?

Author:  Dr. Anton Fokin [ Sun Mar 14, 2010 11:28 am ]
Post subject: 

Hi,


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

Regards,
Anton

Author:  necho [ Thu Jul 08, 2010 5:10 pm ]
Post subject: 

Any hint how you can add additional parameters to the instrument list, e.g. Exchange or any other property field?

Author:  Dr. Anton Fokin [ Thu Jul 08, 2010 5:31 pm ]
Post subject: 

Click on an instrument and edit its properties in the Porperties window?

Regards,
Anton

Author:  Dr. Anton Fokin [ Thu Jul 08, 2010 5:33 pm ]
Post subject: 

Or you mean you want to do it programmatically?

Author:  necho [ Sat Nov 06, 2010 5:03 pm ]
Post subject:  Re: How to add new instruments programatically

yep .. i figured out in the meantime .. thanks


for each Intstrument of MyList

Instrument instrument = InstrumentManager.Instrument[symbol];

instrument.xxx = yyy;

Author:  Dr. Anton Fokin [ Sat Jan 22, 2011 10:16 am ]
Post subject:  Re: How to add new instruments programatically

Now you can use solution scenario to add instruments to solution instrument list programmatically

viewtopic.php?f=64&t=8636

Regards,
Anton

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/