コード例 #1
0
 public InstructionExecutionContext(InvestorInstruction investorInstruction)
 {
     this.investorInstruction = investorInstruction;
     this.initialQuantity = investorInstruction.Quantity;
     this.Quantity = investorInstruction.Quantity;
     this.Price = investorInstruction.Price;
     this.Way = investorInstruction.Way;
     this.AllowPartialExecution = investorInstruction.AllowPartialExecution;
 }
コード例 #2
0
        //// TODO: remove investor instruction as arg here?
        private void RouteImpl(InvestorInstruction investorInstruction, InstructionExecutionContext instructionExecutionContext)
        {
            var solver = new MarketSweepSolver(this.marketSnapshotProvider);

            var orderBasket = solver.Solve(instructionExecutionContext);
            
            EventHandler<DealExecutedEventArgs> handler = (executedOrder, args) => instructionExecutionContext.Executed(args.Quantity);
            EventHandler<OrderFailedEventArgs> failHandler = (s, failure) => this.SendOrderFailed(investorInstruction, failure, instructionExecutionContext);

            investorInstruction.Executed += (sender, e) => this.investorInstruction_Executed(sender, e);

            orderBasket.OrderExecuted += handler;
            orderBasket.OrderFailed += failHandler;

            orderBasket.Send();

            orderBasket.OrderExecuted -= handler;
            orderBasket.OrderFailed -= failHandler;
        }
コード例 #3
0
        private void SendOrderFailed(InvestorInstruction investorInstruction, OrderFailedEventArgs reason, InstructionExecutionContext instructionExecutionContext)
        {
            this.marketSnapshotProvider.MarketFailed(reason.Market);

            if (investorInstruction.GoodTill != null && 
                investorInstruction.GoodTill > DateTime.Now && 
                instructionExecutionContext.Quantity > 0)
            {
                // retries
                this.RouteImpl(investorInstruction, instructionExecutionContext);
            }
            else
            {
                Action<string> failureCallback;
                if (this.failureCallbacks.TryGetValue(investorInstruction.IdentifierDto, out failureCallback))
                {
                    failureCallback(reason.Reason);
                }
            }
        }