Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Partial fills help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Partial fills help

    Hi,

    I am having an issue during partial fills where I am missing the confirmation in OnExecutionUpdate.

    Background: I enter a position using 3 separate brackets (Bracket 1, 2, 3). In OnExecutionUpdate, I wait until all are filled and then set profits/target.

    The issue is that sometimes on partial orders, I will get confirmation that 1 or 2 of the brackets were filled, but never on the last bracket - so my target/stops never get set.

    Any advice on what I might be doing wrong?

    Code:
    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    		{
    			if (execution.Order != null && execution.Order.Name == "Long Entry 1")
    			{
    				if (execution.Order.OrderState == OrderState.Filled)
    				{
    					order1Filled = true;
    					orderTime = execution.Order.Time;
    					logEntry(Instrument.MasterInstrument.Name+"\t"+"Bracket 1 Filled - Quantity: "+execution.Order.Quantity+"\t"+"Price: "+execution.Order.AverageFillPrice);
    				}
    			}
    			if (execution.Order != null && execution.Order.Name == "Long Entry 2")
    			{
    				if (execution.Order.OrderState == OrderState.Filled)
    				{
    					order2Filled = true;
    					orderTime = execution.Order.Time;				
    					logEntry(Instrument.MasterInstrument.Name+"\t"+"Bracket 2 Filled - Quantity: "+execution.Order.Quantity+"\t"+"Price: "+execution.Order.AverageFillPrice);
    				}
    			}
    			if (execution.Order != null && execution.Order.Name == "Long Entry 3")
    			{
    				if (execution.Order.OrderState == OrderState.Filled)
    				{
    					order3Filled = true;
    					orderTime = execution.Order.Time;
    					logEntry(Instrument.MasterInstrument.Name+"\t"+"Bracket 3 Filled - Quantity: "+execution.Order.Quantity+"\t"+"Price: "+execution.Order.AverageFillPrice);
    				}
    			}
    			
    			
    			if (bracketUnits == 1 && order1Filled)
    				orderFilled = true;
    			if (bracketUnits == 2 && order1Filled && order2Filled)
    				orderFilled = true;
    			if (bracketUnits == 3 && order1Filled && order2Filled && order3Filled)
    				orderFilled = true;
    			
    			if (orderFilled)
    				logEntry(Instrument.MasterInstrument.Name+"\t"+"Order Complete - Quantity: "+Position.Quantity+"\t"+"Price: "+Position.AveragePrice);
    
    			
    			// set stop and profit targets
    			if (orderFilled && !setTargetsFlag)
    				setTargets();
    			}
    Thanks,
    Alex

Latest Posts

Collapse

Topics Statistics Last Post
Started by helpwanted, Today, 03:06 AM
1 response
12 views
0 likes
Last Post sarafuenonly123  
Started by Brevo, Today, 01:45 AM
0 responses
9 views
0 likes
Last Post Brevo
by Brevo
 
Started by aussugardefender, Today, 01:07 AM
0 responses
5 views
0 likes
Last Post aussugardefender  
Started by pvincent, 06-23-2022, 12:53 PM
14 responses
242 views
0 likes
Last Post Nyman
by Nyman
 
Started by TraderG23, 12-08-2023, 07:56 AM
9 responses
387 views
1 like
Last Post Gavini
by Gavini
 
Working...
X