[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A.K.'s C++ code for accessing UMDS server



PureBytes Links

Trading Reference Links

Here's a private letter that others might find interesting.  At the bottom there's some C++ code for accessing the UMDS.  Enjoy.

-----Original Message-----
From:	Allan Kaminsky [SMTP:allan@xxxxxxxx]
Sent:	Wednesday, September 15, 1999 7:11 AM
To:	bnm03@xxxxxxx
Subject:	RE: FW: UMDS

At 01:22 AM 9/15/99 -0700, you wrote:
>"If you are fluent in C++, I'd be happy to send you some code I wrote for a
>LIFO stack class that makes much of this pretty simple."
>
>Yes definitely.  Thanks.  While I've never done indepth research for doing
>this, I've had the thouhgt.  What I didn't want to have to do was spend a
>lot of time programming overhead.  Overhead like buffer management, memory
>mgmnt,prog indicators in C++, etc.  I was afraid of getting bogged down in
>data management and not focusing on the trading stuff.  I like the UMDS.
>  I've had it collecting ticks for the past 2 weeks or so and it's had no
>problems on 128Meg Pentium-233.     If the UMDS worked with Omega's,
>couldn't you have it serving ticks to both the Omega app and your
>proprietary app?  

Omega keeps their interfaces proprietary. Even if you cracked it, there's 
absolutely no assurance they won't make a change. It's easier to use 
something else.


>So you continually call a UMDS API method to get a chunk of data?  The
>first tick in the list would be the most recent tick the server recieved
>for that market.  How do you "push" a single new tick on to this stack?  Do
>you just get a new chunk of ticks from UMDS with the new ticks at the top?
>  You're garunteed not to miss any ticks because the UMDS is handling all of
>that.   When a new chunck of ticks  is received, you then recalculate your
>indicators and determine your position.    Since you probably request the
>same amount of ticks from the server each time, new ticks bump the old ones
>off.  In a scenario like this there would be little memory managment and/or
>buffer management since you would allocate a block of memory on the heap
>that would probably never change.  You send UMDS a pointer to that block,
>it fills it with ticks, and you process them then have it fill it again.
>
>This is a stab in the dark but is this close to how it works?

The UMDS manages the buffering on all ticks. The preferred interface uses a 
timer to periodically poll the UMDS. This is programmer selectable. I've 
settled on a 1 second timer which works well for my application. When the 
timer produces an interrupt, I make a determination as to what the time is 
now. I do this because the UMDS continues to receive ticks but I want my 
analysis to be time synchronized. I then poll each of the issues I'm 
interested in. The tick chain for each issue starts with the newest tick. I 
follow the chain. Once the ticks get older than my 'sample time' I start 
stacking them in the LIFO stack. When I reach either the end of the chain 
or the tick I previously processed I stop. I then start popping the stack, 
which lets me play the tick sequence 'forward' rather than in reverse. The 
number of ticks is not a fixed number, as there's no control over how many 
ticks have occurred in the last second. Also, if the program has just 
started up, the search time may be more than 1 second, as it will be 
'catching up' to the beginning of the session. If you look at the code for 
the LIFO class I've attached, you'll see that the LIFO size grows and 
shrinks dynamically. Depending on how you want to do your analysis, there 
may be various tricks you resort to to 'line up' the various issues you're 
following.

The documentation for the UMDS is freely downloadable. Go to:

http://208.237.116.96/sdk.htm

and select the appropriate link. Read and understand the relevant portions 
of this document to make sure you know what you're getting into.

Allan

P.S.: I haven't posted this to the list, as this is a response to your 
private inquiry. However, there may be others with this interest, so if 
you're agreeable, please post this response to the list with the attachment 

(it's very short).


#ifndef _CLIFO_Tickh
#define _CLIFO_Tickh

#ifndef USACCESS_VERSION
#include <windows.h>
#include "usaccess.h"
#endif

// Class CLIFO_Tick

static const long LIFO_TickSegLen = 10000;

class CLIFO_Tick
{
public:
	CLIFO_Tick(){pcurr = 0; nticks = 0;}
	~CLIFO_Tick(){while(pcurr){segment *p = pcurr->pback; delete pcurr; pcurr = p;}}
	void enq(LPUS_TICK ptick)
	{
		if ((!pcurr) || (pcurr->count == LIFO_TickSegLen))
			{
			segment * pnew = new segment;
			if (!pnew)
				pnew = 0;
			pnew->pback = pcurr;
			pcurr = pnew;
			pcurr->count = 0;
			}
		pcurr->ticks[pcurr->count++] = ptick;
		++nticks;
	}
	LPUS_TICK deq(void)
	{
		if (!nticks)
			return(0);
		LPUS_TICK pret = pcurr->ticks[--pcurr->count];
		if (!pcurr->count)
			{
			segment * pold = pcurr->pback;
			delete pcurr;
			pcurr = pold;
			}
		--nticks;
		return(pret);
	}
	long num(void){return(nticks);}
private:
	struct segment
		{
		segment * pback;
		long count;
		LPUS_TICK ticks[LIFO_TickSegLen];
		};
	segment * pcurr;
	long nticks;
};

#endif