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

Quantbase script syntax for defining new AltIDGroups?
http://www.smartquant.com/forums/viewtopic.php?f=81&t=10348
Page 1 of 1

Author:  kkkwj [ Thu Sep 27, 2012 8:42 pm ]
Post subject:  Quantbase script syntax for defining new AltIDGroups?

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?

Author:  Alexei Kurov [ Fri Sep 28, 2012 10:00 am ]
Post subject:  Re: Quantbase script syntax for defining new AltIDGroups?

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";

Author:  kkkwj [ Fri Sep 28, 2012 5:15 pm ]
Post subject:  Re: Quantbase script syntax for defining new AltIDGroups?

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 5657 times ]

Author:  Alexei Kurov [ Sat Sep 29, 2012 8:19 am ]
Post subject:  Re: Quantbase script syntax for defining new AltIDGroups?

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

Author:  kkkwj [ Sat Sep 29, 2012 8:34 am ]
Post subject:  Re: Quantbase script syntax for defining new AltIDGroups?

Ok, that was the trick, it worked fine. Thanks.

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

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