How to read real time ticker data from a text file ( it is update by every ticker )

The futures broker give quote API for user by VC++ or VC# (In asia , not USA )
but this is not good way for end user.
because the API ver. update every time , the user must modify plugin-in (DLL) again for new funtion or even frome vc++ change to vc# (because new API not support VC++ any more)

so The futures broker has new idea is : (because they receive too much Customer complaints) :

API ( RT quote: ticker level data ) ----> TXT FILE <------ any program ( etc AB , R , python )
API (Order) <------ EXE FILE <------ any program ( etc AB , R , python )

the ticker data like below (time -- price --- volume )

22:49:31.60,10712,2
22:49:31.60,10712,1
22:49:31.98,10711,3
22:49:32.84,10711,1
22:49:35.47,10711,5
22:49:36.72,10711,1
22:49:39.49,10711,1
22:49:39.84,10711,8
22:49:47.21,10711,5
22:49:47.48,10711,2
22:49:47.59,10711,1

If you put the TXT FILE in ram-disk , it is not slow
so my problem is :
to write a loop to read last line from the TXT FILE (RT , it is updating now)
is very easy , but how to put the data to AB is very hard.

I read ASCII sample code in ADK .
it seems must read data in

PLUGINAPI int GetQuotesEx( LPCTSTR pszTicker, int nPeriodicity, int nLastValid, int nSize, struct Quotation *pQuotes, GQEContext *pContext )

but the TXT FILE it is updating now , if the loop in GetQuotesEx()
It is wrong.

Could you tell me have any sample code it is easy tell me how to let ticker data (updating)
to AB ?

Thanks

1 Like

There are examples in the ADK (see ASCII plugin and QT plugins). ASCII plugin is pretty much it. But broker's idea is weak (using text files). It is slow. And it does not matter if you have data in RAM. What is slow is conversion from binary to text (on their side) and then conversion back from text to binary (on client side). Two things that are done without sense.

Anyway to improve performance you can read the file in one thread and put it to array in binary form and observe only updates so you just add last line if file changes. Then in GetQuotesEx just memcpy() ready to use table (possibly only from nLastValid) so only few bytes are actually copied.

2 Likes