Discussion:
[Quickfix-developers] Using .seqnums file to trigger a full resend
d***@yahoo.co.jp
2017-02-23 03:29:06 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
Grant Birchmeier
2017-02-23 04:07:19 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-02-23 05:24:25 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
Grant Birchmeier
2017-02-23 15:16:43 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
Mike Gatny
2017-02-23 15:50:05 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-02-23 16:29:20 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
Mike Gatny
2017-02-23 16:41:46 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-02-24 17:21:03 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
Mike Gatny
2017-02-24 18:05:58 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-02-26 15:00:49 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-02-28 13:23:12 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
Mike Gatny
2017-02-28 13:39:17 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-02-28 15:11:18 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
Mike Gatny
2017-02-28 16:38:26 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-02-28 17:05:34 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-04-13 14:37:48 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-04-13 15:18:35 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
Mike Gatny
2017-04-13 15:31:44 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-04-13 15:37:18 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
d***@yahoo.co.jp
2017-04-17 09:45:07 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
K. Frank
2017-04-17 12:33:32 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/

Hi Dermot!
...
Hi Mike,
Just getting back to orders that are sent (and don't go anywhere) during network downtime - is there a recommended approach to identifying and cleaning these up? I'm thinking to just run a process every minute or so that checks "if currently logged on and order hasn't been acked in the last minute then delete from database". What do you think?
Some words of advice from the trenches ...

Think through your recovery strategy carefully (as you seem to
be doing).

First, if you send an order and receive an ack, then your counter-
party has accepted responsibility for that order. (Hopefully he
fulfills his responsibility.)

If you try to send an order and don't receive an ack, you don't
know whether your counter-party has it or not. (Send order,
receive and process order, send ack -- network goes down --
don't receive ack. Note, in this scenario, your counter-party
doesn't know -- until and unless you request a gap fill -- that
you didn't receive the ack. FIX doesn't ack acks.) Note, this
means that you REALLY don't want to delete unacked orders
from your database and forget about them -- they might be
live on your counter-party's side. So you need, at least, to
put them in some kind of limbo state, and have a protocol
for cleaning them up (or leaving them live when you get your
ack after a reconnect and gap fill).

You need to decide on a business protocol for handling network
outages. Some counter-parties will let you (or require) that you
have them (pre-arranged -- not via FIX) auto-cancel any orders
if connectivity drops. Note such a "cure" can be worse than the
problem if your network goes down for a few milliseconds or a
few seconds or even a few minutes. It depends on your use case.

Similarly, you need to decide what you want to do with orders
that you have attempted to issue but haven't sent yet. Again,
if the outage was only for a few milliseconds or seconds, you
might be best to just send them.

The problem is with orders that you might have sent. You can't
really not resend them in a gap fill because that could be
inconsistent with the traffic you counter-party has already seen.
You could negotiate with your counter-party an "auto-cancel" policy
for new, previously unseen orders that come in a gap fill.

Let's say you do decide to filter out (somehow) possibly unsent traffic
when gap filling after an outage. While you might want to "filter out"
new orders (or have your counter-party ignore / auto-cancel them)
you almost certainly do not want to filter out possibly unsent cancel
requests.

You are right that it makes a lot of sense to monitor whether you
have connectivity with your counter-party. Note there are several
levels to this:

Business "connectivity" -- e.g., receive acks
FIX connectivity -- heartbeats, isLoggedOn
Network connectivity -- e.g., a free-standing "ping" watchdog

It does make sense -- to reduce potential gap-fill load and economic
exposure if you don't manage a timely reconnect -- to pause
sending orders on your side if you detect possible connectivity
interruption. You may or may not wish to queue up such unsent
traffic to send if you reestablish connectivity after a "short" amount
of time. Note, there is real business logic in how you decide to
handle this. Would you really not want to send cancel requests
that you generated and got queued up during a (real or imagined)
loss of connectivity?

Repeating two key points:

It is well worth designing your recovery strategy with care.

The details of your strategy will depend on your specific business
use case -- auto-cancellation policies, how long an outage puts
you into a clean-up mode, rather than recovering and proceeding
normally (keeping orders live, etc.).

And last: Test to the extent you can afford and your business requires.
I have NEVER seen automated recovery work completely correctly in
institutional environments -- even with reasonably well-tested systems.
(I'm not saying it can't happen -- I've just never seen it.)
Dermot
Good luck.


K. Frank
d***@yahoo.co.jp
2017-04-18 13:48:44 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
K. Frank
2017-04-19 21:15:20 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/

Hello Dermot!
Hi K. Frank,
Really appreciate the comprehensive response. Advice from the trenches is
exactly what I need!
So actually for this business case we do NOT want to resend any orders or
cancels that didn't get through during downtime. The order submission is
fast-paced and the limit prices may be stale by the time we reconnect.
This is reasonable.
Also, cancels are always linked to new orders.
(we don't allow more than one open order of the same ticker/side)
From this I take it that your trading strategy, roughly speaking,
consists of having outstanding limit orders (possibly on both sides)
for a set of securities, more or less continuously, at least until they
get filled. You do, however, adjust limit prices, by first cancelling such
an order, and then issuing a new order with a new limit price (rather
than issuing a single cancel-replace request that, in essence, modifies
the limit price of an existing order.

As side note: I would imagine that, if only as a matter of operational risk
control, there would be instances where you would want to cancel an
order without then issuing a new order. It's your business logic, so
maybe you really don't ever do this, but it would seem prudent to have
this capability. Anyway, if you do ever have "unpaired" cancels, it would
seem that you would want to resend them in the event of a reconnect and
a resend request from your counter-party.
This makes the approach simple -
any unacked messages can be 'cancelled' on our side. You're right about
deleting orders, that's not a good idea. Instead will set them to
'Withdrawn' status.
This seems reasonable. When QuickFIX reconnects for you and responds
to the resend request from your counter-party, it will give you a chance to
intervene before it actually resends a given message. It does this through
the Application::toApp() callback that you can override in your MyApp (or
whatever) class that you have derived from Application. You can then tweak
the messages before they are sent, or -- as in your use case -- throw a
DoNotSend exception, in which case QuickFIX will gap-fill the sequence
number (in effect telling your counter-party that the missed message was
an ignorable admin message), rather than resend the message.
My plan is to have process which runs 120 seconds after each successful
logon [that should be enough time for any missing acks/fills to get back in
the resend].
This should work. However, as a matter of general practice, using this kind
of magic-number wait time to insure that something has happened should
be avoided when possible.

When you reconnect, your counter-party tells you what sequence number
it's on. You (i.e., QuickFIX) notice that you've missed some messages so
you (QuickFIX) issue a resend request. You can then wait until your
counter-party is done with its resend.

I'm not entirely sure how to get QuickFIX to tell you that the resend is done,
though. The resent messages ought to have their PosDupFlag set, so it
might work to wait until you get a message that was sent post reconnect
because its PosDupFlag isn't set. (QuickFIX queues up out-of-order
messages for you, so messages should delivered to your application logic
in order after the resend is complete.) Maybe you could status a known
good order and use its status message as a flag that the resend is complete.

(It would be nice if you could get a callback from QuickFIX or query it directly
somehow to get it to tell you that the resend is complete. I don't know of a
way to do this, but perhaps there is one.)
The process checks if there are any orders in 'Sent' status
(unacked) and created before last logon time - update these orders to
'Withdrawn' status.
Yes, so the logic would be something like:

Inspect orders that QuickFIX is resending on your behalf in the toApp callback,
and throw the DoNotSend exception so that you don't resend new orders and
cancel requests that presumably haven't been sent.

Wait until your counter-party's resend is complete (e.g., as outlined
above), and
then update unacked orders in your own order store to your proposed "Withdrawn"
status.
Simple but should do the job. Definitely need to get unacked orders out of
the way as they will interfere with new orders being sent (we don't allow
more than one open order of the same ticker/side). There's no auto-cancel
requirements from the broker so the policy is up to us.
You still have a small potential issue. According to you, after
sending the initial
order for a ticker/side, you only send pairs of cancel / new orders.
It's possible
that before a disconnect your cancel makes it through, but your new
order doesn't.

So you will want to have a little bit of logic that recognizes this
situation and lets
you send another new order without it being part of a cancel / new order pair
(because the cancel was already sent and correctly processed).
What do you think?
If you (try to) send an order, reconnect, get all of your
counter-party's messages
through a proper resend request, and you don't get an ack for that
order, then it's
fair to say that your counter-party has told you that he did not
receive the order.

But relying on your counter-party's silence to communicate this could be less
reliable that getting an affirmative statement that the order was not received.

To be redundantly cautious, you could proactively send status requests for your
unacked orders, and if your counter-party never got them, you should get back
some kind of unknown order message. I believe that the FIX specification says
you can do this using the ClOrdID (the order id generated on your end and sent
as part of your new order message). However, bear in mind, some counter-parties
may require that you status the order using the OrdID (the order id assigned by
the counter-party and sent back in the ack). Well, since you never got an ack,
you wouldn't be able to do it this way. (As I said, I don't believe
that requiring the
OrdID in place of the ClOrdID is really meets the spec, but it is a
pitfall to watch
out for.)

Similarly, if you tried to send a cancel (in your case, presumably as part of a
cancel / new order pair), but never got a ur-out, you could status the order to
confirm that it is still alive, rather than relying on silence (i.e.,
the absence of
the ur-out) to indicate that the order is alive.

Although this kind of double-check requires building some additional application
logic, it will probably be worth it if you're going to trade any
significant flow
through your application or your application is going to be in service for more
than, say, a few months.

Trust me, stuff happens.

It always seems cheaper not to invest in this kind of additional
development cost.
Cheaper, at least, until you're on the losing side of a trading error
(and automated-
trading trading errors can blow up in a hurry).
Thanks!
Dermot
Happy Trading!


K. Frank
----- Original Message -----
Date: 2017/4/17, Mon 21:33
Subject: Re: [Quickfix-developers] Network disconnect recovery testing
Hi Dermot!
...
Hi Mike,
Just getting back to orders that are sent (and don't go anywhere) during
network downtime - is there a recommended approach to identifying and
cleaning these up? I'm thinking to just run a process every minute or so
that checks "if currently logged on and order hasn't been acked in the last
minute then delete from database". What do you think?
Some words of advice from the trenches ...
Think through your recovery strategy carefully (as you seem to
be doing).
...
d***@yahoo.co.jp
2017-05-10 17:32:45 UTC
Permalink
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/
Loading...