SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Fri Oct 19, 2018 10:21 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Wed Aug 31, 2011 2:17 am 
Offline

Joined: Fri Jan 15, 2010 11:25 pm
Posts: 54
I am using limit order type for both entry and exit, so the partial fill could happen on both ends.
What I am doing right now is:
if (exitOrder.LeavesQty!=Position.Qty) {
exitOrder.Qty = (exitOrder.Qty-exitOrder.LeavesQty) + Position.Qty;
exitOrder.Replace();
}
But it doesn't work. I am getting incorrect quantity when partial fill happened.
In the API doc, the Position has many quantity members, like EntryQty, Qty, QtyBought, QtySold, QtySoldShort, the descriptions are so short that I really cannot tell the differences and no idea which one to use.
Please help.
Thanks!


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 8:07 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6808
Hi,

which broker do you use?

Regards,
Anton


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 10:04 am 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi,

excuse me, but I dont understand what are you doing...
exitOrder.Qty - exitOrder.LeavesQty is exitOrder.CumQty
you are adding Position.Qty to this value and replace an order, why?
what do you want to do exactly - could you explain it with example?

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 3:16 pm 
Offline

Joined: Fri Jan 15, 2010 11:25 pm
Posts: 54
I am using MBT(does the broker matter?)
I am trying to handle partial fills on both entry and exit sides.
For example, when my entry quantity is 10000, partial filled 5000, the exit order was created as 5000.
Then the entry filled another 2500,
exitOrder.Qty=5000, exit.LeavesQty=5000, Position.Qty=7500
exitOrder.Qty = (exitOrder.Qty-exitOrder.LeavesQty) + Position.Qty;
= (5000-5000) + 7500 = 7500
Then the exit filled 2000,
exitOrder.Qty=7500, exit.LeavesQty=5500, Position.Qty=5500
exitOrder.Qty = (exitOrder.Qty-exitOrder.LeavesQty) + Position.Qty;
= (7500-5500) + 5500 = 7500
If the entry filled the remained 2500 now.
exitOrder.Qty=7500, exit.LeavesQty=5500, Position.Qty=8000
exitOrder.Qty = (exitOrder.Qty-exitOrder.LeavesQty) + Position.Qty;
= (7500-5500) + 8000 = 10000
Sorry I don't know there is a CumQty to use, which made this confusing.
So it could be exitOrder.Qty = exitOrder.CumQty + Position.Qty;
Thanks!


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 4:49 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6808
Hi,

Position is not updated until a transaction is completed (i.e. a coresponding order is filled or cancelled). It's not updated with partial fills.

Regards,
Anton


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 4:58 pm 
Offline

Joined: Fri Jan 15, 2010 11:25 pm
Posts: 54
Hmm, then any suggestion about how to handle this situation? Could I use the CumQty of the entry order?


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 5:16 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
CumQty is quantity of filled shares at the moment.
For every moment, Qty = CumQty + LeavesQty
for example, order's Qty is 1000
1000 = 0 + 1000
fill 300
1000 = 300 + 700
fill 500
1000 = 800 + 200
fill 200
1000 = 1000 + 0

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 5:21 pm 
Offline

Joined: Fri Jan 15, 2010 11:25 pm
Posts: 54
Will this work?
exitOrder.Qty = exitOrder.CumQty + entryOrder.CumQty;


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 5:29 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
I think no.
exitOrder.Qty will become greater than entryOrder.Qty
may be just change exitOrder.Qty to entryOrder.CumQty at every partial fill?

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 5:41 pm 
Offline

Joined: Fri Jan 15, 2010 11:25 pm
Posts: 54
That would be enough to cover the partial fills on the entry side, but what about the partial fills on the exit side?
Alexei Kurov wrote:
I think no.
exitOrder.Qty will become greater than entryOrder.Qty
may be just change exitOrder.Qty to entryOrder.CumQty at every partial fill?


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

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 2 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