SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Aug 19, 2019 9:10 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 46 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Mon Jun 02, 2014 6:16 pm 
Offline

Joined: Wed May 14, 2014 9:35 pm
Posts: 10
Hello guys, can somebody help me out a bit with coding a snippet to get the quotes from sterling. I've made this so far but it doesn't give me a correct quote, it returns me a -1 so I'm sure I'm doing something wrong. The code uses the sterling API and is in C#. And the code is:

namespace Test
{
using System;
using SterlingLib;
class myQuotes
{
private STIQuote sterlingQuote = new STIQuote();

public void Initialize()
{
this.sterlingQuote.DeRegisterAllQuotes();
}

public void RegisterQuote(string symbol, string markets)
{
Console.WriteLine("Trying to register for {0} at {1} venues", symbol, markets);
this.sterlingQuote.RegisterQuote(symbol, markets);
}

public double AskPrice()
{
this.sterlingQuote.RegisterQuote("SPY", "");
return this.sterlingQuote.AskPrice;
}

public double BidPrice()
{
return this.sterlingQuote.BidPrice;
}

public int AskSize()
{
return this.sterlingQuote.AskSize;
}

public int BidSize()
{
return this.sterlingQuote.BidSize;
}

public double LastPrice()
{
throw new NotImplementedException();
}
}
}

When I initialize and register the symbol, and then try to pull the quote it doesn't work. Let's say the code to do that is:

myQuotes sterlingQuote = new myQuotes();
sterlingQuote.Initialize();
sterlingQuote.RegisterQuote("SPY", "");
Console.WriteLine("Ask price / size: {0} x {1}", sterlingQuote.AskPrice(), sterlingQuote.AskSize());
Console.WriteLine("Bid price / size: {0} x {1}", sterlingQuote.BidPrice(), sterlingQuote.BidSize());


Top
 Profile  
 
PostPosted: Mon Jun 02, 2014 6:46 pm 
Offline

Joined: Mon Oct 04, 2010 5:13 pm
Posts: 353
I would suggest you to create a solution with your code and post it here, so maybe (not promising :)) I can run it in debug and see what the problem is. One of the things I don't see in your code is where you register an event handler for quotes, something like:

stiQuote.OnSTIQuoteUpdate += new SterlingLib._ISTIQuoteEvents_OnSTIQuoteUpdateEventHandler(OnSTIQuoteUpdate);

Then you get your quotes in OnSTIQuoteUpdate handler.

Another thing to remember - the Sterling supports only .NET 3.5. Attempting to work in 4 or later will, sometimes result in inability to get events. We have specifically downgraded our projects for Sterling to 3.5.

E


Top
 Profile  
 
PostPosted: Mon Jun 02, 2014 8:05 pm 
Offline

Joined: Wed May 14, 2014 9:35 pm
Posts: 10
edwardgonen wrote:
I would suggest you to create a solution with your code and post it here, so maybe (not promising :)) I can run it in debug and see what the problem is. One of the things I don't see in your code is where you register an event handler for quotes, something like:

stiQuote.OnSTIQuoteUpdate += new SterlingLib._ISTIQuoteEvents_OnSTIQuoteUpdateEventHandler(OnSTIQuoteUpdate);

Then you get your quotes in OnSTIQuoteUpdate handler.

Another thing to remember - the Sterling supports only .NET 3.5. Attempting to work in 4 or later will, sometimes result in inability to get events. We have specifically downgraded our projects for Sterling to 3.5.

E


Thanks for the quick reply. I fixed that. Another thing is at structQuote there is no execution time? Is that normal because each transaction has an execution time when it happened.

BTW, i was wondering is there an event to check for actual transactions happening instead of flashing quotes. This will greatly reduce the events that come to the bot? I mean change these lines:

this.sterlingQuote.OnSTIQuoteUpdateXML += new _ISTIQuoteEvents_OnSTIQuoteUpdateXMLEventHandler(OnSTIQuoteUpdateXML);
this.sterlingQuote.OnSTIQuoteSnapXML += new _ISTIQuoteEvents_OnSTIQuoteSnapXMLEventHandler(OnSTIQuoteSnapXML);

because I want to get the quotes only with the current transaction, not all flashesh and changes without actual trading. Thanks again


Top
 Profile  
 
PostPosted: Mon Jun 02, 2014 8:43 pm 
Offline

Joined: Mon Oct 04, 2010 5:13 pm
Posts: 353
1. Try to issue stiQuote.SetTradesOnly(true); to get the trades. I'm not sure how it works since we have this in our code and not sure if we tried without it.

2. Regarding the time - I'm not sure if it is there or not. Did you look at all fields of the event arguments? We don't use it.


Top
 Profile  
 
PostPosted: Mon Jun 02, 2014 8:49 pm 
Offline

Joined: Mon Oct 04, 2010 5:13 pm
Posts: 353
BTW - I would like to ask you something about your usage of Sterling. How long have you been working with it? The reason I ask is that we have a very annoying problem with it - namely the reconnect - the Sterling Pro crashes whenever there is a network disconnect for more than 20-30 sec. This means it cannot work in a fully automated mode 24x5. I guess if there will be a critical mass of complains they might consider to fix it.


Top
 Profile  
 
PostPosted: Mon Jun 02, 2014 8:53 pm 
Offline

Joined: Wed May 14, 2014 9:35 pm
Posts: 10
I'll meddle a bit more with the code and then post it here, because I think there is a memory leak somewhere in the code. It freezes my machine after a few minutes of activity. Maybe someone can help with it.

BTW


Top
 Profile  
 
PostPosted: Mon Jun 02, 2014 9:02 pm 
Offline

Joined: Wed May 14, 2014 9:35 pm
Posts: 10
edwardgonen wrote:
BTW - I would like to ask you something about your usage of Sterling. How long have you been working with it? The reason I ask is that we have a very annoying problem with it - namely the reconnect - the Sterling Pro crashes whenever there is a network disconnect for more than 20-30 sec. This means it cannot work in a fully automated mode 24x5. I guess if there will be a critical mass of complains they might consider to fix it.


Hello, I've been using Sterling for more than a year as a manual trader. I hate this program. Absolute disaster. And the api I guess is the same as the program and support.


Top
 Profile  
 
PostPosted: Mon Jun 02, 2014 9:31 pm 
Offline

Joined: Mon Oct 04, 2010 5:13 pm
Posts: 353
Actually I'm quite content with API - very simple, straight forward and quite reliable. The only problem we have with it - crash on disconnect. Even if there is no connection problem, they restart their systems at night and the client just crashes. Naturally we have no way to restart it automatically so it makes our systems "semi"-automatic :). We never had such problem with IB...

Anyway - good luck with your quest. I'm wondering why you posted this question in SQ forum? Are you planning to use Sterling with OQ?


Top
 Profile  
 
PostPosted: Mon Jun 02, 2014 10:24 pm 
Offline

Joined: Wed May 14, 2014 9:35 pm
Posts: 10
edwardgonen wrote:
Actually I'm quite content with API - very simple, straight forward and quite reliable. The only problem we have with it - crash on disconnect. Even if there is no connection problem, they restart their systems at night and the client just crashes. Naturally we have no way to restart it automatically so it makes our systems "semi"-automatic :). We never had such problem with IB...

Anyway - good luck with your quest. I'm wondering why you posted this question in SQ forum? Are you planning to use Sterling with OQ?


OQ? I saw that here is a discussion about the api and figured it would be a good place to try to post and solve api problems. So far averybody has been very helpful and nice, not like in elitetrader or other forums. This one rocks!


Top
 Profile  
 
PostPosted: Tue Jun 03, 2014 2:07 pm 
Offline

Joined: Wed May 14, 2014 9:35 pm
Posts: 10
Hi guys,

i'm going through the C# examples now. Does anyone know why the code keeps returning $0 prices as last price on change in quote activity? Is this normal?


Attachments:
File comment: C# quote demo from sterling
VS2010C#QuotesExample.zip [220.89 KiB]
Downloaded 293 times
Top
 Profile  
 
PostPosted: Sat Jul 19, 2014 2:09 pm 
Offline

Joined: Wed May 14, 2014 9:35 pm
Posts: 10
slicky_pete wrote:
Hi guys,

i'm going through the C# examples now. Does anyone know why the code keeps returning $0 prices as last price on change in quote activity? Is this normal?


All problems so far are fixed and I'm into optimization. I have a tiny problem which I still can't figure out. If someone is interested maybe he can share some insights on how to fix it. I have a stock and a pending limit buy order waiting in stock XYZ. Let's assume the conditions change and I want to update the price of that same limit order with the Sterling Api? How to achieve it. I can cancel it but canceling is sooooo slow with ST, slow like really slow and I think the price update will be much faster. I've dug into the guide (here: http://sterlingfinancialsystems.com/documents/Documentation/ActiveX_API_Guide.pdf) but can't find anything suitable with a bit of available information how to use and pass it. Does anyone know how to update the limit price of an order? Thanks


Top
 Profile  
 
PostPosted: Mon Jul 21, 2014 2:18 pm 
Offline

Joined: Mon Oct 04, 2010 5:13 pm
Posts: 353
Hi,

I'm sorry for not answering this and your other questions. Unfortunately this topic is dedicated to development of Sterling plug-in for OpenQuant only. The plug-in does not need the order replacement functionality so I guess we are not able to answer your question. I'm not sure you will be able to get much assistance with your code here since we use the API in a very stripped down manner (send order, get order status, cancel and similar).

From my experience the Sterling support guys are reasonably responsive so I may suggest you to call them. They had already helped me with quite a lot of questions.

E


Top
 Profile  
 
PostPosted: Tue Jul 22, 2014 8:23 pm 
Offline

Joined: Wed May 14, 2014 9:35 pm
Posts: 10
edwardgonen wrote:
Hi,

I'm sorry for not answering this and your other questions. Unfortunately this topic is dedicated to development of Sterling plug-in for OpenQuant only. The plug-in does not need the order replacement functionality so I guess we are not able to answer your question. I'm not sure you will be able to get much assistance with your code here since we use the API in a very stripped down manner (send order, get order status, cancel and similar).

From my experience the Sterling support guys are reasonably responsive so I may suggest you to call them. They had already helped me with quite a lot of questions.

E


Hello and thank you for clarifying a lot of questions for me. I won't spam here anymore if it's for quant only. I tried to communicate with sterling through my bucketshop but they're not very responsive. Always point to the guide, but I need to take a look some repositories like the ones on github to find out how to find my way around in the messy code.


Top
 Profile  
 
PostPosted: Tue Jul 22, 2014 8:49 pm 
Offline

Joined: Mon Oct 04, 2010 5:13 pm
Posts: 353
I just had few free minutes and had a look at API. It seems like replacing an existing order is a quite a straight-forward procedure. You just create new order and then, using the existing order IDs call the Replace method.

Am I missing anything?

Ed


Top
 Profile  
 
PostPosted: Tue Jul 22, 2014 9:04 pm 
Offline

Joined: Wed May 14, 2014 9:35 pm
Posts: 10
edwardgonen wrote:
I just had few free minutes and had a look at API. It seems like replacing an existing order is a quite a straight-forward procedure. You just create new order and then, using the existing order IDs call the Replace method.

Am I missing anything?

Ed


I will try that. I'll buy you a beer if it works.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 46 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 2 guests


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