SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Thu Oct 01, 2020 10:33 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: partial and overfills
PostPosted: Wed Mar 21, 2012 10:24 am 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Could someone please help here?

I’m confused as to how OQ handles partial and overfills. I’ve ended up with a position profile as included here. This doesn’t make sense as I have no code that gets short, handle partial fills or overfills.

I can’t find any documentation or a overview thread on partial or overfills – sorry if I’ve missed it.

Thanks and regards,

drolles


Attachments:
Fills view.jpg
Fills view.jpg [ 31.03 KiB | Viewed 4981 times ]
Top
 Profile  
 
PostPosted: Tue Mar 27, 2012 12:45 am 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Hi, wondering if someone can help here please?

Thanks,

drolles


Top
 Profile  
 
PostPosted: Tue Mar 27, 2012 1:59 pm 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi Drolles.

When an order gets done (parially filled and cancelled, or completely filled) - new transaction is added to the portfolio. This transaction can close the current position completely/partially or reverse the position. If it reverses the position, for example from long to short, the remaning Qty of the transaction (the qty that is now short) is counted as ShortQty.

The position is closed only when after some transaction there is no position on a given instrument at all. Reversing position does not lead to the position close. So, I guess in your sitution you have 1 position opened for a long time, sometimes it gets reversed into short.

Maybe you can override the OnPositionChanged handler and print Position.Amount in it to make sure you never go short?

Regards,
Sergey.


Top
 Profile  
 
PostPosted: Tue Mar 27, 2012 11:41 pm 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Sergey,

Thanks for that.

I'll put some thought into this and get back to you.

Thanks and regards,

drolles


Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 3:54 pm 
Offline

Joined: Wed Apr 27, 2005 4:41 pm
Posts: 609
Location: Helsinki, Finland
Hi Drolles,

additionally do note that OnOrderFilled, OnOrderPartiallyFilled gets fired on the filling of the order.

And of course the order.IsNew, order.IsFiller, order.IsPartiallyFilled are really handy at monitoring the situation of the order.

BR,
Eelofi


Top
 Profile  
 
PostPosted: Tue Apr 10, 2012 3:58 pm 
Offline

Joined: Wed Apr 27, 2005 4:41 pm
Posts: 609
Location: Helsinki, Finland
So before shooting a new order, I check:

Code:
!EntryOrder.IsNew && !EntryOrder.IsPartiallyFilled && !EntryOrder.IsPendingNew && !EntryOrder.IsPendingReplace


So the status should be filled, cancelled, expired etc, before my strategy fires a new one.

BR,
Eelofi


Top
 Profile  
 
PostPosted: Sat Sep 08, 2012 12:45 pm 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Eelofi,

Thanks very much for that.

I’m just returning back to this issue after a while. Your help is great.

I’m going to give your coding approach a go.

Whilst thinking about how to implement it though I was thinking of some scenarios. I’m wondering once you have identified a partial fill, what you do with it? Do you know of any heuristic rules for this?

Thanks again. I’ll let you know how I get on.

Regards,

drolles


Top
 Profile  
 
PostPosted: Mon Sep 17, 2012 3:33 pm 
Offline

Joined: Wed Apr 27, 2005 4:41 pm
Posts: 609
Location: Helsinki, Finland
Oh yes,

one problem which has been around for ever and it would be good to hear how other people have overcome it. Sometimes the order stays in PendingNew for ever (maybe 1/100th-1000th order). I've never completely diagnosted the problem, but I believe the logic goes as follows:
1) once OQ creates a new order it's state is PendingNew
2) once IB acknowledges the order it's in the New state
3) with partial fill it becomes partially filled and so on

But the problem lies in between 1) and 2). What happens if IB never acknowledges the order? It remains in PendingNew. The natural reaction would be to cancel orders after maybe 15sec or what ever, if they haven't been acknowledged. But (and here's the catch), because OQ has sent the order to IB it doesn't allow cancelling it without acknowledgement from IB. This problem has been around for years and it's properly fixed yet - yes it was worse it the past so progress has been made.

All of this results in that your program might wait forever for the acknowlegement from IB and stall your progress.

My solution has been that I've added that, if an order is PendingNew and older than 10sec, then my program logic omits that order completely - presuming that it's not really there at all. But ideally I'd like this to be fixed in OQ = an order gets stuck in PendingNew state -> I want to cancel it -> OQ checks with IB, is IB aware of the order -> if not, cancelling of PendingNew is possible.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group