Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SmartOrderRoutingEngine"/> class.
        /// </summary>
        /// <param name="marketsProvider">The markets provider.</param>
        /// <param name="routeOrders">The order routing.</param>
        /// <param name="marketDataProvider">The market data provider.</param>
        public SmartOrderRoutingEngine(IProvideMarkets marketsProvider, ICanRouteOrders routeOrders, ICanReceiveMarketData marketDataProvider)
        {
            this.routeOrders = routeOrders;
            var availableMarkets = marketsProvider.GetAvailableMarketNames();

            this.marketSnapshotProvider = new MarketSnapshotProvider(availableMarkets, marketDataProvider);
        }
 public SmartOrderRoutingEngine(IProvideMarkets provideMarkets, ICanRouteOrders canRouteOrders, ICanReceiveMarketData canReceiveMarketData)
 {
     this.provideMarkets = provideMarkets;
     this.canRouteOrders = canRouteOrders;
     this.canReceiveMarketData = canReceiveMarketData;
     var availableMarkets = provideMarkets.GetAvailableMarkets();
     this.markets = availableMarkets.ToDictionary(market => market, market => market);
     this.marketSnapshotProvider = new MarketSnapshotProvider(availableMarkets, canReceiveMarketData);
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OrderBasket"/> class.
        /// </summary>
        /// <param name="ordersDescriptions">The orders descriptions.</param>
        /// <param name="canRouteOrders">The can route orders.</param>
        public OrderBasket(List <OrderDescription> ordersDescriptions, ICanRouteOrders canRouteOrders)
        {
            this.OrdersDescriptions = ordersDescriptions;
            this.canRouteOrders     = canRouteOrders;

            if (ordersDescriptions.Count > 0)
            {
                this.Way = ordersDescriptions[0].OrderWay;

                foreach (var orderDescription in ordersDescriptions)
                {
                    if (orderDescription.AllowPartialExecution)
                    {
                        this.AllowPartialExecution = true;
                    }

                    this.Quantity += orderDescription.Quantity;
                }
            }
        }
        /// <summary>
        /// Build the description of the orders needed to fulfill an <see cref="SimpleOrderRouting.Infra.InvestorInstruction" /> which
        /// is aggregated within an <see cref="InstructionExecutionContext" /> instance.
        /// </summary>
        /// <param name="instructionExecutionContext">The <see cref="InstructionExecutionContext" /> instance that aggregates the <see cref="SimpleOrderRouting.Infra.InvestorInstruction" />.</param>
        /// <param name="canRouteOrders"></param>
        /// <returns>
        /// An <see cref="OrderBasket" /> containing all the orders to be routed in order to fulfill the initial <see cref="SimpleOrderRouting.Infra.InvestorInstruction" />.
        /// </returns>
        public OrderBasket Solve(InstructionExecutionContext instructionExecutionContext, ICanRouteOrders canRouteOrders)
        {
            // Checks liquidities available to weighted average for execution
            int     remainingQuantityToBeExecuted = instructionExecutionContext.RemainingQuantityToBeExecuted;
            decimal requestedPrice = instructionExecutionContext.Price;

            var validMarkets = this.GetValidMarkets(requestedPrice);
            int availableQuantityOnMarkets = this.ComputeAvailableQuantityForThisPrice(validMarkets);

            if (availableQuantityOnMarkets == 0)
            {
                return(new OrderBasket(new List <OrderDescription>(), canRouteOrders));
            }

            var ordersDescription = GenerateOrdersDescription(instructionExecutionContext, remainingQuantityToBeExecuted, validMarkets, requestedPrice, availableQuantityOnMarkets);

            return(new OrderBasket(ordersDescription, canRouteOrders));
        }