Tag Archives: sockets

Demo to submit order to Dukascopy JForex via sockets for forex algo trading

Demo to submit order to Dukascopy JForex via sockets for forex algo trading

Wow that was easy once again thanks to Dukascopy API demos

Dukascopy JForex submitting order Java source code notes

Join my FREE newsletter to learn more about on how this broker can help in your automated algo forex trading

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Demo of Sockets for DotNet for CSharp

Demo of Sockets for DotNet for CSharp

This is useful as it adds added security. Also, I could use UDP which is standard for HFT

PowerTCP Sockets for .NET

Join my FREE newsletter to understand socket programming throught this

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

For HFT: Lowest latency with sockets over APIs? How to build a C++ Linux based open source FIX engine

Hi there

Another opportunity, get in the on the action soon as we are closing out this FREEMIUM stuff soon! In other words, join the QuantLabs.net Premium membership while you can for the upcoming private webinars. .

I went to my Meetup last nite where I always learn lots of things. From what I see, everything is being streamed into trading platforms these days. Also, screw APIs as they becomes bottlenecks with latency so you need to learn how to program sockets.  Interactive Brokers comes to mind with their Trader Workstation  versus their FIX gateway options.
Not only that, many in the past have told me that using R with RCpp/RInside could be a bottleneck. There is a potential with that so it leads me into investigating event rule based programming using a Complext Event Processing engine like Esper. Well, there is none for C++ as Esper is for C# or Java. Too bad but there is an option to stream it in. I posted about that yesterday. There are some options I posted at:
I am investigating 2 options currently.
I also got my backups in place if R does indeed become the bottleneck, I can hint it is most popular part of QuantLabs.net. It also involves a very big expense but you gotta do what you gotta do to get things working. Aahh… the joyous challenges in working on these HFT potential platforms?
Another important element are FIX engines built on top of wonky QuickFIX. I documented my experience on one solution called FIX8
These are the most complicated parts of any HFT platform. As I am building this out, I am realizing the incredible value people are getting being on this list. 

JOIN NOW 

Benefits are listed are here. 
Bryan

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Tough TCP interview question on C++ with sockets and network

Code should be in C or C++ and should be ‘production quality’. I.e. has to check for errors at runtime, and cannot overflow or underflow buffers or corrupt memory.
• Pls include a paragraph explaining how you would test this:

TCP:
Implement a routine that processes packets from the network over a reliable TCP connection:

HRESULT ProcessData(PBYTE pDataBuffer, IN ULONG cbBufferSize)// you need to implement this routine

Information:

typedef struct tag_HEADER
{
ULONG cbTotalPacketLen;
ULONG cbThisChunkLen;
#define FLAG_FIRST_CHUNK_IN_PACKET 1
#define FLAG_LAST_CHUNK_IN_PACKET 2
ULONG flags;
} CHUNK_HEADER;

The format the server sends will be a sequence of PACKETs.
Each packet is broken up into a sequence of one or more CHUNKs. Each Chunk starts with a CHUNK_HEADER.
The first CHUNK in a packet has ‘flags’ field set to FLAG_FIRST_CHUNK_IN_PACKET.
The last chunk that has ‘flags’ FLAG_LAST_CHUNK_IN_PACKET sets.
Chunks in the ‘middle’ of packet will have neither flag set.
A chunk can be any size up to 16384 bytes. A packet can be any size unbounded.

The ‘total’ length of the packet will be cbTotalPacketLen, each chunk in the packet will have this same length set in the chunk header.
The ‘length’ of the current chunk will be always ‘cbThisChunkLen’.

The ProcessData(…) routine will be called many times, with whatever data has arrived from the network. The network is reliable so data will arrive in sequence it was sent. However as this is a TCP stream, not a message there is no guarantee that the call to ProcessData will correspond to a complete chunk. I

That is important point, ProcessData may be called many times for even one CHUNK. And may be called with an arbitrary number of bytes each time ranging from just one byte.

Your goal: with ProcessData(…) is to implement a routine that reads the stream and the CHUNKs and from that reconstructs a _complete_ Packet (i.e. has data from all chunks in the packet). Once a packet is constructed you should pass it to a routine:

HRESULT ProcessPacket(PBYTE pPacketBytes, IN ULONG cbCompletePacketSize); //you do not need to implement this. Just call it EVERY time you have a completed packet.
7

Hi All,

the solution can be::::::

HRESULT ProcessData(PBYTE pDataBuffer, IN ULONG cbBufferSize)//

typedef struct tag_HEADER
{
ULONG cbTotalPacketLen;
ULONG cbThisChunkLen;
#define FLAG_FIRST_CHUNK_IN_PACKET 1
#define FLAG_LAST_CHUNK_IN_PACKET 2
ULONG flags;
} CHUNK_HEADER;

HRESULT ProcessData(PBYTE pDataBuffer, IN ULONG cbBufferSize) {

CHUNK_HEADER *header = (CHUNK_HEADER *) malloc(sizeof(CHUNK_HEADER));
static PBYTE *packet;
static int length;
header = (CHUNK_HEADER *)pDataBuffer;

if (header->flags == FLAG_FIRST_CHUNK_IN_PACKET) {
packet = NULL;
packet = (char *) malloc(header->cbTotalPacketLen);
length = header->cbThisChunkLen;
}

elseif(header->flags == FLAG_LAST_CHUNK_IN_PACKET) {
memcpy(packet+length, pDataBuffer+sizeof(CHUNK_HEADER), header->cbThisChunkLen);
ProcessPacket(packet);
packet = NULL;
length = 0;

}
else {

memcpy(packet+length, pDataBuffer+sizeof(CHUNK_HEADER), header->cbThisChunkLen);
}

IF this is called with only 1 byte from the very beginning, you’ll get wrong flag.

HOW DO YOU START A PROFITABLE TRADING BUSINESS? Read more NOW >>>

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!