ANVIL API (Assent) Developer Thread

Discussion in 'Trading Software' started by ctarmor-et, Dec 10, 2007.

  1. The purpose of this thread is for available ANVIL developers to collaborate on ideas, questions or “how to” using the ANVIL C++ API. A development forum is not available (I could not find one) anywhere on the web.
  2. tfjield


    Way to go!

    I'll kick off the questions...

    In another thread you referred to some issues regarding multithreading with the API. My extension is also multithreaded, but I have had no issues. Perhaps I just lucked out with my design structure.

    What issues were you having? What did you have to avoid in a multithreaded app to avoid causing problems with the API?
  3. I finally realized that it does not support multi-thread calls into the stockHanlde and accounthandle (I think I was the only that did not know about it :)

    I shitfed back to 1990's and ended up using a old fashion hook into the main message loop. Thurough the hook I can post my own user messages to place trades and manage ANVIL without affecting ANVIL perfromance itself.

    I do have a separate thread that receives msgs (like a multiplexer) that will calculate avgs, indicators, etc without affecting the speed on the main thread. As the portfolio grows the multiplexer can be adjusted to manage larger historical calculations by adding more thread(s).

    I have a very large portfolio and it places orders extremely fast (well as fast as possible through ANVIL). Order are being executed in about 100ms.
  4. tfjield


    I'm using a multithreaded approach as well. Perhaps why I'm not having problems is that I'm not passing the stockHandle between threads, although I'm not accessing it in the same thread that called the DLL...

    I do all of my API message processing in one thread and use an implementation of PostThreadMessage/PreTranslateMessage if I need to move from thread to thread. Unfortunately, the Windows message pump has a limitation (15k messages?) so I don't queue directly to the pump.

    Could the problem be that the API is just not thread safe?

    Anyway, it's good to know! If I start seeing weird problems crop up, I know the first place I will look.
  5. As I understood (from the dev team) any calls into SendOrder, order status, level subscribtions, can only be made form the main thread.

    PreTranslate is a better approach than what I did.

    In another note, how do you determine if there are any pending orders from the stock::pocess() method ?

    I am having a bit of difficullty determining it. I was trying to use the order iterator but it is expensive to use. So I ended up monitoring my order through M_POOL_UPDATE_ORDER in the account handle. Although it does not tell me if there are other orders unles I use the iterator.
  6. tfjield


    Sorry I can't help you, I haven't done it. :(

    I'm using the API for monitoring/scanning and don't execute trades through it. Lot's of help I am, huh?!

    The only thing I see in the examples is using the order iterator.

    I'm sure you've scoured the examples alrady, but looking through the API there are several calls defined after the line:
    void* WINAPI B_CreateOrderMonitor(const Position* position);
    in BusinessApi.h that look promising.

    Do you know what these functions do? They don't seem to be used anywhere in the example...

    Sorry I can't be of any help with this.
  7. I was try to set an observer in new positions when M_POSITION_NEW is send to the acct handle but MsgPositionNew.m_position is a const *.

    I was thinking about static_const<> the pointer and force an observer but I chickened out.

    I am not sure what B_CreateOrderMonitor() does . I suspect it will send events to to the associated stock handle.
  8. What do you use to place your orders ?

    You can PM me if you do not want to post it on the board :)
  9. tfjield


    I'm a discretionary trader -- I only use the API for analysis. I trade manually.

    Yeah, I thought B_CreateOrderMonitor() might send messages to the chosen stock handle, and that it might provide a good way to receive updates...
  10. I actually


    to attach a listener to it. It is working much nicer monitoring the position at teh stock level.

    In addition you can get M_BOOK_* messages about the underlying equity.

    In another note, to get all prints you can listen to stockhandle M_LAST_TRADE_SHORT
    #10     Dec 11, 2007