Sterling API Developer Thread

Discussion in 'Trading Software' started by mnx, Apr 25, 2008.

  1. Oh, I just love these kind of posts. Guess what ? Similar posts have been showing up for years now on the Interactive Broker's API forum.
    It seems as though ALL OF THESE VENDORS HAVE POOR, POOR API SUPPORT. The programmers are learning only by TRIAL AND ERROR.....many errors !
    I still can't determine WHY...you would think a good API would encouragea a lot of round-trips and therefore more commish.
     
    #61     May 2, 2008
  2. Ok, did some more researching and found out that if you use the interface to create an instance, the property setting in Delphi becomes twice as fast. This is how I did it before:

    delcared order this way:
    order: TSTIOrder;
    Then instantiated this way:
    order:= TSTIOrder.Create(self);

    in the above, TSTIOrder = class(TOleServer)

    Way faster is this way:

    declare order as:
    order: ISTIOrder;
    Then instantiate like this:
    order:= CoSTIOrder.Create;

    Wherein this case ISTIOrder = interface(IDispatch)

    This way, 5000 times setting a property takes 12 seconds instead of 24 seconds if you do it the other way (compared to 10 seconds in C++ and 14 seconds in VB). The Sterling example code does the exact same thing in VB and C++ (using the interface), so I guess I shouldn't blame Delphi here :) Only problem I'm facing when using the interfaces is that I don't know how to do the event sinking in Delphi ... Because, for example, the TSTIQuote class has properties for events like 'OnSTIQuoteSnap' and the ISTIQuote interface has not ...
     
    #62     May 2, 2008
  3. ers811

    ers811

    Just FYI, not sure if anybody has commented on COM w/ C++, but I'm using C# (.Net)...

    Eric
     
    #63     May 2, 2008
  4. Hi guys, I am very interested in learning how to create automated trading programs, and since I am currently using sterling myself, I figure this would be the place to ask since you all seems pretty knowledgeable on this subject. Where should I start? Learning c++, reading the sterling support documents, visual basic, get in depth knowledge of excel....have no idea where to start, any comments suggestions would be greatly appreciated. Sorry for asking such a noob question on a advance thread. Thanks
     
    #64     May 2, 2008
  5. mnx

    mnx

    No worries, basic and avanced questions about the sterling API are all welcome.

    Do you have any programming experience?

    If you have some or are a very faster learner, I'd recommend downloading the examples off of Sterling's website. I especially reccommend getting both the Excel Basket Order Example, and the Visual Basic basket order example. Both are great examples of getting quotes and sending orders.

    Excel is easier to work with in general, so play with that first. Open the Excel Basket Order example and press Alt+F11 to see the code. Poke around try to understand what it is doing.

    If you have no programming experience, I'd recommend getting a book on VBA or visual basic, and then looking at the examples...

    Finally feel free to continue asking questions here...

    - mnx
     
    #65     May 3, 2008
  6. bespoke

    bespoke

    Do you guys have any special methods for identifying that you're offline? You know when Sterling gets disconnected every so often and you get the message box "sterling needs to shut down". But data still comes in regardless and your ATS will only know you're offline when it sends out an order and you get "Error Code -16 (Sterling Trader® Pro is Offline)".

    Also, why would you get an Error Code -12 (Long Sale Position Rules Violation)? Is it when you use "T" to cover? I guess I can just wait until tomorrow to find out.
     
    #66     May 5, 2008
  7. Forget about API, this software is such a POS lately you may as well just start from scratch. Officially the biggest piece of garbage software there is.

    MM
     
    #67     May 7, 2008
  8. For the interested ppl: the reason why VB can handle so much more quote events/second is this:

    The 'WithEvents' keyword that's used in VB, ensures 'early binding' of the events, this means the compiler and linker optimize at compile time. This is also called 'static event binding' ( http://msdn.microsoft.com/en-us/magazine/cc188762.aspx ).

    The other way of event binding is called 'dynamic event binding' and this is late binding, which causes the program to execute much more overhead at runtime.

    The way I understand it, events can only be early bound via VB. Well, most probably there are also ways to do it via other programming languages but I haven't found out how yet. So this is the reason i can only get about 2000 quotes/second in C++ while VB can handle over 10,000/second ...
     
    #68     May 13, 2008
  9. Interesting, but this doesn't explain why VB6 is so much faster than VB.net does it? Or am I missing something here?
     
    #69     May 14, 2008
  10. I've explained that before: .NET can only interact with COM via a 'wrapper'. That wrapper translates everything at realtime, which will consume a lot of your CPU time. You can google for 'COM + interop + .NET' or read sites like these:

    http://www.blong.com/Conferences/BorConUK2002/Interop2/COMNetInterop.htm

    especially pay attention to this part:

    COM itself is slow already, but .NET + COM is just a nightmare if speed is important.
     
    #70     May 14, 2008