SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Sep 17, 2019 10:45 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Mon Mar 24, 2008 3:16 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
You can find examples of custom market data and execution providers in OpenQuant installation folder (windows Start menu SmartQuant Ltd -> OpenQuant -> Samples -> Sample Providers). These examples include full source code for MBT, OEC and TT FIX providers that can be compiled under MSVS 2005. You can use this code as a pattern to develop interfaces to brokers and market data providers not supported out of the box.

Once you develop a new provider and compile it as dll in MSVS, you can add this new provider to OpenQuant via main menu -> Tools -> Options -> Configuration -> Providers -> User -> Add.


Last edited by Dr. Anton Fokin on Thu Jul 30, 2009 12:08 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 1:40 pm 
Offline

Joined: Thu Jan 31, 2008 11:39 am
Posts: 166
I want to create a very simple "MarketData" provider to treat the performance of the system as an instrument.

If I had the performance as an OpenQuant Instrument, I could add it to the instruments list of my system, visualize the chart and than use f.e. indicators to manage equity trading. I dont want to send orders etc., I just want to recieve the new "price" of the performance if a position of my base system is closed.

To be honest, I looked at the sample code of the different user providers and do not understand everything. For example: In the connection void, a new client object is generated, and some events are added to the object.


Code:
client = new OECClient();

            client.OnLoginComplete += new OnLoginCompleteEvent(client_OnLoginComplete);
            client.OnLoginFailed   += new OnLoginFailedEvent(client_OnLoginFailed);
            client.OnDisconnected  += new OnDisconnectedEvent(client_OnDisconnected);
            client.OnError         += new OnErrorEvent(client_OnError);
            client.OnPriceTick     += new OnPriceChangedEvent(client_OnPriceTick);



This client object is of type OECClient (which inherits from the Component Object of MS I assume). There, I don't find the code where exactly this object is getting the actual price (and therefore triggers the OnPriceChangedEvent).

In my case, I think it would work like this: My base system closes a position. The actual performance of the system is send to another application (I have to write I assume). This application provides the new price to the userprovider in OpenQuant and so I can display the new price on the chart f.e.

Is there an easy way to get this done?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 8:03 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
flotschie wrote:
This client object is of type OECClient (which inherits from the Component Object of MS I assume). There, I don't find the code where exactly this object is getting the actual price (and therefore triggers the OnPriceChangedEvent).


OECClient is OEC API object, so I guess OEC API gets prices from OEC servers and then OECClient fires these event...

Regards,
Anton


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 8:12 pm 
Offline

Joined: Thu Jan 31, 2008 11:39 am
Posts: 166
Thank you anton. I think now I have to write my own API Client which gets prices and then fires the events.

Does anyone from the community know how I can create this kind of client?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 8:40 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
You don't really need to write a separate API client, you can get prices right in OQ provider. The rest depends on how you get prices (performance) from your trading application...

Regards,
Anton


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 12:07 am 
Offline

Joined: Thu Jan 31, 2008 11:39 am
Posts: 166
Ok thx. I made this User Provider:

Code:
using System;
using System.ComponentModel;
using System.Collections.Generic;
using OpenQuant.API;
using System.Threading;
using System.Windows.Forms;
namespace EProv.dll
{
    class EProv : OpenQuant.API.Plugins.UserProvider
    {
        public EProv()
        {
            base.name = "EPROV";
            base.description = "testing";
            base.id = 100;
            base.url = "http://www.hello.com";
        }
        protected override void Subscribe(Instrument instrument)
        {           
            base.Subscribe(instrument);
        }
        protected override void Connect()
        {
            base.isConnected = true;
            Instrument i = new Instrument(InstrumentType.Stock, "EC");
            Subscribe(i);
            double p = 0;
            while (true)
            {
                Thread.Sleep(1000);
                MessageBox.Show("Bing!");
                recieveprice(i, p);
                p++;
            }
        }
        public void recieveprice(Instrument i, double p)
        {
            base.EmitNewTrade(i, Clock.Now, p, 1);
        }
        protected override void Disconnect()
        {

            base.isConnected = false;
        }
        protected override bool IsConnected
        {
            get
            {
                return base.IsConnected;
            }
        }

    }
}



to test it. But everytime I connect, I get a NullReferenceException:

System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei SmartQuant.Instruments.DataManager.UKF3Ns8gP(Object , TradeEventArgs )
bei SmartQuant.Providers.ProviderManager.TrSc6nZMi(Object , TradeEventArgs )
bei OpenQuant.API.Plugins.SQProvider.EmitTrade(Instrument instrument, DateTime time, Double price, Int32 size)

Its in the line

Code:
base.EmitNewTrade(i, Clock.Now, p, 1);


I think it has something to do with the instrument. I have this instrument in the list of instruments in my strategy.

By the way: Is it possible to have more than one market data provider for a strategy? Because I had to set the Live trading Market Date Provider to my User Provider. I wonder then where my base system is getting the IB Market Data.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 12:37 am 
Offline

Joined: Thu Jan 31, 2008 11:39 am
Posts: 166
I solved this by getting the instrument via the OpenQuant.API.Instrument list, don't know if this is elegant...

Code:
 Instrument i; //= new Instrument(InstrumentType.Stock, "EC");
            i = OpenQuant.API.InstrumentManager.Instruments["EC"];


But I still have this last question above.


Top
 Profile  
 
PostPosted: Sun Nov 07, 2010 8:53 pm 
Offline

Joined: Sun Oct 17, 2010 2:26 am
Posts: 8
Hi Dr. Anton Fokin,

I am unable to locate the sample as mentioned in this post, can you give me some light where i can download the sample.

Thanks

Dr. Anton Fokin wrote:
You can find examples of custom market data and execution providers in OpenQuant installation folder (windows Start menu SmartQuant Ltd -> OpenQuant -> Samples -> Sample Providers). These examples include full source code for MBT, OEC and TT FIX providers that can be compiled under MSVS 2005. You can use this code as a pattern to develop interfaces to brokers and market data providers not supported out of the box.

Once you develop a new provider and compile it as dll in MSVS, you can add this new provider to OpenQuant via main menu -> Tools -> Options -> Configuration -> Providers -> User -> Add.


Top
 Profile  
 
PostPosted: Sun Nov 07, 2010 9:09 pm 
Offline

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

exactly as discussed in the original post:

Windows Start menu SmartQuant Ltd -> OpenQuant -> Samples -> Sample Providers

These folder contains two shortcuts to MS Visual Studio projects, so that you need to have Visual Studio installed to click and load them. Just in case... Windows Start menu is the main Windows menu (-> All Programs under Vista or Win 7), it's not OpenQuant menu.

Regards,
Anton


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