SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Sep 18, 2019 12:17 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Sep 27, 2012 8:42 pm 
Offline

Joined: Thu Jun 08, 2006 3:56 pm
Posts: 537
Location: BC Canada
I'm trying to define instruments in QuantBase programmatically, since I like to define contracts for several instruments for the coming year. The problem is that QB does not like my syntax for (1) DataCenter (the ancestor of QuantBase), or for (2) OpenQuant v3.2.2. I've tried many different combinations for syntax, but of course it is a very tedious and frustrating process, trying to guess the secret syntax for QB.

What is the syntax for defining the AltIDGroups that QB wants me to use? Thanks


Here are the syntaxes that worked for DC and OQ, to show you what I'm after.

Code:
// Here is how to add a FIX security sub group, if you have to.
// This does not work in OQ or QB, because FIX is not part of the OQ API.

         // create a group with alternate ID symbols
         //FIXSecurityAltIDGroup foo = new FIXSecurityAltIDGroup();
         //foo.SecurityAltExchange = "GLOBEX";
         //foo.SecurityAltID = "EUR";
         //foo.SecurityAltIDSource = "IB";
         //inst.AddGroup (foo);


// This works in OQ, but not QB or DC.
         inst.Currency = "USD";
         inst.SecurityDesc = pDesc;
         inst.SecurityExchange = pExchange;
         inst.SecurityID = pIbSym;
         inst.SecurityIDSource = "IB";
         inst.Factor = pFactor;          // ticksize * factor = $dollars/tick
         inst.ContractMultiplier = pFactor;
         inst.Margin = pMargin;
         inst.TickSize = pTickSize;
         inst.PriceDisplay = pPriceDisplay;
         inst.MaturityDate = numDates[n];

// What is the syntax for adding AltSource, AltSymbol, and AltExchange to QB?


Top
 Profile  
 
PostPosted: Fri Sep 28, 2012 10:00 am 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi Kevin,

AltSource, AltSymbol and AltExchange properties of Instrument class are deprecated now - you can see appropriate compiler warning..
The code should look like this:
Code:
Instrument instrument = InstrumentManager.Instruments["AAPL2"];
      
AltIDGroup group = instrument.AltIDGroups.Add("IB");
      
group.AltSymbol = "AAPL";
group.AltExchange = "SMART";

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Fri Sep 28, 2012 5:15 pm 
Offline

Joined: Thu Jun 08, 2006 3:56 pm
Posts: 537
Location: BC Canada
Hi Alex, Thanks for the syntax. Unfortunately, things are still not working.

I show my code below. QB creates the instrument, and fills out the top block of the property sheet correctly (USD, "CAD 2012", Futures, but leaves the following fields blank:
- AltIDgroups, factor, maturity,margin, ticksize, and price format (actually my F4 is ignored, the default F2 shows).

Perhaps you could try this code on your machine/QB, and see what I'm doing wrong? Thanks.

Code:
      foreach (string month in strDates) {
         string     sym = pIbSym + " " + strDates[n]; // CAD 201212
         Instrument inst = new Instrument (InstrumentType.Futures,sym);
         inst.Currency = "USD";
         inst.Description = pDesc;      // Canadian Dollar
         inst.Exchange = pExchange;      // GLOBEX

         AltIDGroup group = inst.AltIDGroups.Add("IB");
         group.AltSymbol = pIbSym;      // CAD
         group.AltExchange = pExchange;   // GLOBEX
         //group.AltSource = "IB";
         
         inst.Factor = pFactor;      // 100000
         inst.Margin = pMargin;      // 2500
         inst.TickSize = pTickSize;      // 0.0001
         inst.PriceFormat = pPriceDisplay;   // F4
         inst.Maturity = numDates[n];   // 2012-12-01

         // very important! Don't forget to save instrument changes
         // inst.Save ();
         n = n + 1;
      }


Attachments:
File comment: The instrument created by the script.
QB instrument.jpg
QB instrument.jpg [ 37.3 KiB | Viewed 4779 times ]
Top
 Profile  
 
PostPosted: Sat Sep 29, 2012 8:19 am 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi Kevin,

there is a little trick of instrument creation in OQ and QB.
if you want to work with new instrument immediately you should get it from InstrumentList again
Code:
Instrument inst = new Instrument (InstrumentType.Futures,sym);

inst = InstrumentManager.Instruments[sym];

inst.Currency = "USD";
etc...

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Sat Sep 29, 2012 8:34 am 
Offline

Joined: Thu Jun 08, 2006 3:56 pm
Posts: 537
Location: BC Canada
Ok, that was the trick, it worked fine. Thanks.

Really, someone should document all these tricks somewhere. :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 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