New BrokerCommand: SET_TRIGGER_PIPE

Posted By: AndrewAMD

New BrokerCommand: SET_TRIGGER_PIPE - 05/26/18 21:21

I would like to request that a new BrokerCommand SET_TRIGGER_PIPE be supported by Zorro. Below is my explanation.

The broker API is synchronous in nature. I am proposing a basic way for Zorro to set up a dedicated asynchronous listener, so that a plugin can request a BrokerAsset call for a specific Asset.

Command: SET_TRIGGER_PIPE
Text/Parameter: PipeName (f.i. "\\.\pipe\PipeName")

Sets the name of an existing named pipe. Zorro will create the named pipe and asyncronously listen to it. The plugin will write to the pipe using the Trigger Protocol defined below. Return Value: the version number of the Trigger Protocol supported, or zero if not supported.


Proposal for Trigger Protocol (Version 1):

The protocol will consist entirely of fixed-size messages. Each message will be exactly 128 bytes. The message will contain a null-terminated string.

The message struct:

Code:
typedef struct TRIGGER_V1
{
	char Asset[128];
} TRIGGER_V1;


Here's how it works:

* Plugin has a dedicated listener.
* Plugin receives market data.
* Plugin sends Asset name to pipe.
* Zorro calls BrokerAsset() for the specified Asset.

On the Zorro side, instead of sleeping for TickTime between BrokerAsset calls, there can be a listener with a timeout of TickTime. This way, no multithreading is required.

And that's it. No need to rewrite the broker API from scratch in order to support pushing market data.
Posted By: jcl

Re: New BrokerCommand: SET_TRIGGER_PIPE - 05/28/18 20:46

That makes sense. Put on the todo list.
Posted By: AndrewAMD

Re: New BrokerCommand: SET_TRIGGER_PIPE - 06/19/18 16:18

jcl,

I do realize my above method is possibly overkill.

If convenient, some alternative approaches can be employed. For example, I know that with Boost Asio, there is a trick where one can change the deadline of a timer on another thread to trigger an event on that other thread.

So really, the core issue is that we need Zorro's main thread to enter a state of waiting for a network event to occur.

Of course, I will happily employ whichever trigger method is made available. Thanks.
Posted By: jcl

Re: New BrokerCommand: SET_TRIGGER_PIPE - 07/02/18 09:46

We'll do that not with a pipe, but will make the Zorro window handle available to other processes, so that they can send messages and trigger price requests.
Posted By: AndrewAMD

Re: New BrokerCommand: SET_TRIGGER_PIPE - 07/02/18 12:07

This is even better, thanks!
© 2024 lite-C Forums