Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Management of Partial Take Profit fills
 Post subject: Management of Partial Take Profit fills Post rating: 0   New post Posted: Sun 11 Nov, 2012, 19:27 

User rating: 0
Joined: Sun 11 Nov, 2012, 19:10
Posts: 1
Hello everyone.

I have a trading system which mainly uses Limit Orders and Take Profits as order types.

I want to handle this particular scenario:

1) Limit Order is posted for amount X, with Take Profit.
2) Price hits limit and order fills for full amount X.
3) Price hits Take Profit and order partially closes for amount Y < X, so position is now X - Y.
3) At this point, if price hits again the limit price, I want my position to go back to full X, i.e. I want to post a new limit order for Y or add Y to the current order so that this happens.

Now the question is, how can I detect that a partial take profit has happened and thus the order has been partially closed ? I'm quite sure it can be done using the onMessage callback, but ATM all my code is running into the onBar section, so it would be great if I could do everything using the getAmount()/getRequestedAmount() functions. Unfortunately this is not something I can test in the historical tester (AFAIK) because I can't simulate partials there.

Also please note that the X amount is constant and fixed.

Thanks for your attention.


 
 Post subject: Re: Management of Partial Take Profit fills Post rating: 0   New post Posted: Tue 13 Nov, 2012, 08:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You can fetch the orders from onMessage which got partially closed and then process the in the next onBar, similarly as it is done in the following example:
https://www.dukascopy.com/wiki/#Manage_Order_State/Stop_loss_update_on_fill_with_queue
If you want to do this just by comparing the amounts, then consider keeping the previous order amounts in a Map<IOrder,Double>.


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com