ANVIL API (Assent) Developer Thread

Quote from tfjield:

Anyone know how to start Anvil during the off hours, so that when the servers come up in the morning it will automatically log in?

I've been trying to use the A/no password login and tell that to pre-load another account, which looked promising... But when the morning rolls around, it always says the pre-load account failed to logon.

Is there a better/more direct way to do this?

Have you tried running it in service mode ? You could use an AT job to start/stop it every day ...
 
Quote from tfjield:

pandabear, while re-reading this thread, I realized I wasn't very clear in my response to your question about creating another window. I thought that elaborating a bit might help new users of the API get started.

If you are programming in MFC, you can create a CDialog. CDialog's don't create their own message pump, but use the message pump of their parent window, the handle to which you can get to pass to the CDialog initialization routines via a call to AfxGetMainWnd(). This follows the examples given by Assent with the API.

Now you can set up a paradigm where you call, say, CMyDialog::CreateStock() which then posts a custom (WM_USER+) message to the CMyDialog, where by using PreTranslateMessage you can route the message to CMyDialog::OnCreateStock() which will be executed in the main Anvil thread.

I use event handles to simulate SendMessage across threads (i.e. so that CreateStock() will not return until OnCreateStock() is finished, so that I can pass a return value, etc.)

I didn't want to use SendMessage or SendMessageTimeout, because this will preempt the other messages already in the queue and may cause (fatal) delays in Anvil -- you might get booted from the server if you cause too much of a delay.

You can do this with a hook, as well. I chose the CDialog approach because I'm very comfortable with MFC and it suited my style better. But either approach will give you suitable results.

Hope this helps.

In addition to tjfield comment, you can create your dialog resource like this:

g_pCDlgStatusMsg = new CDlgStatusMsg(::AfxGetMainWnd());
g_pCDlgStatusMsg->Create(IDD_STATAMSGDLG, ::AfxGetMainWnd());
g_pCDlgStatusMsg->ShowWindow(SW_SHOW);
 
Quote from ctarmor-et:

Does anyone know how to get the Best Bid/Ask ECN in
MsgInsideQuote - M_NW2_INSIDE_QUOTE message ?

You can get the Bid/Ask (m_stockHandle->GetBid()) but I need to figure out what ECN is the NBBO.

I finally found the code :D

.....
B_StartIteration(bBid ? m_bidIterator : m_askIterator);
return (BookEntry *) B_GetNextBookEntry(bBid ? m_bidIterator : m_askIterator);

This will give you the first Leve2 quote in the book. Create the iteratros as follow:

// Book Iteratros
unsigned int bookQuotesIntegrated[MAX_BOOKS];
for(unsigned int i = 0; i < MAX_BOOKS; i++)
bookQuotesIntegrated = 1;
unsigned int mmLines = 1;//0xFFFFFFFF - all
static bool ecnsOnly = false;
static bool twoDecPlaces = true;
m_bidIterator = B_CreateLevel2AndBookIterator(m_stockHandle, true, ecnsOnly, twoDecPlaces, bookQuotesIntegrated, mmLines, this);
m_askIterator = B_CreateLevel2AndBookIterator(m_stockHandle, false, ecnsOnly, twoDecPlaces, bookQuotesIntegrated, mmLines, this);


You can find more samples in the AnviExtTest sample
 
Quote from ctarmor-et:

Have you tried running it in service mode ? You could use an AT job to start/stop it every day ...

I can run Anvil in service mode, but I'm finding that it's not loading my DLL, which it does during a normal logon... Any ideas?

Anyway, I'm still debugging, so I would like to run it from the debugger. If I start it before the servers shut down and let it run all night, it properly reconnects to the servers in the morning. But if I'm a bit too late, I need to start it manually in the a.m.

I'm not sure why pre-loading the real account from the A account doesn't work.
 
Quote from tfjield:

I can run Anvil in service mode, but I'm finding that it's not loading my DLL, which it does during a normal logon... Any ideas?

Anyway, I'm still debugging, so I would like to run it from the debugger. If I start it before the servers shut down and let it run all night, it properly reconnects to the servers in the morning. But if I'm a bit too late, I need to start it manually in the a.m.

I'm not sure why pre-loading the real account from the A account doesn't work.

I never used it in service mode. Are you using the SYSTEM account on the serivce registration ?

I have not dealt with automatically loading the account. We manually open ANVIL in the morning since we run a gray box.
 
Has anyone been noticing these msgs form the account observeable ?

MSGID_CONNECTION_FAILED
MSGID_CONNECTION_STARTED

FAILED seems to happen every 20 seconds after STARTED. Once FAILED is received, it taked 4 seconds to get the STARTED one.

The funny thing is that most time than not, data still continues to flow .... weird...
 
I haven't noticed them, but I haven't been looking for them, either. Tonight I'll add trace statements to see if I'm getting them and we can go from there.
 
Quote from tfjield:

I can run Anvil in service mode, but I'm finding that it's not loading my DLL, which it does during a normal logon... Any ideas?

Anyway, I'm still debugging, so I would like to run it from the debugger. If I start it before the servers shut down and let it run all night, it properly reconnects to the servers in the morning. But if I'm a bit too late, I need to start it manually in the a.m.

I'm not sure why pre-loading the real account from the A account doesn't work.

I did not see this posting earlier.

Loading the dll: Could it be becasue the service working folder is system32 ?

To debug you could start the service and "attach" to the process for debugging.

Just wondering, what account are you running the service ?
 
Quote from ctarmor-et:

I did not see this posting earlier.

Loading the dll: Could it be becasue the service working folder is system32 ?

To debug you could start the service and "attach" to the process for debugging.

Just wondering, what account are you running the service ?
I'm not sure that the working folder matters... I thought about that, but the path to the DLL folder is explicit.

But you just made me think of something... Maybe it isn't even finding Anvil.ini. I'll try moving it to system32 and seeing if that helps. Thanks!

I have tried to attach to the service, which I can do, but if I place a break point on, say, my PreTranslateMessage routine, nothing gets hit. Also, my DLL creates a log file to dump trace statements into, and that file isn't created, all making me believe that the DLL is not being run.

I'm running it with credentials to use my desktop -- the one I'm logged in to.
 
Quote from tfjield:

I'm not sure that the working folder matters... I thought about that, but the path to the DLL folder is explicit.

But you just made me think of something... Maybe it isn't even finding Anvil.ini. I'll try moving it to system32 and seeing if that helps. Thanks!

I have tried to attach to the service, which I can do, but if I place a break point on, say, my PreTranslateMessage routine, nothing gets hit. Also, my DLL creates a log file to dump trace statements into, and that file isn't created, all making me believe that the DLL is not being run.

I'm running it with credentials to use my desktop -- the one I'm logged in to.

I do not know if you tried this but once the service is running, try digging into the loaded dlls using the old listdlls from Mark R.

http://www.microsoft.com/technet/sysinternals/ProcessesAndThreads/ListDlls.mspx
 
Back
Top