public BrokerDto(IOrderBroker orderBroker)
            {
                if (orderBroker == null)
                {
                    return;
                }

                this.Id         = string.IsNullOrWhiteSpace(orderBroker.Id) ? null : orderBroker.Id;
                this.ExternalId = string.IsNullOrWhiteSpace(orderBroker.ReddeerId) ? null : orderBroker.ReddeerId;
                this.Name       = string.IsNullOrWhiteSpace(orderBroker.Name) ? null : orderBroker.Name?.ToLower();
                this.Live       = orderBroker.Live;
            }
        public async Task <string> InsertOrUpdateBrokerAsync(IOrderBroker broker)
        {
            this._logger?.LogInformation($"{broker?.Name} about to insert or update broker");

            if (broker == null)
            {
                return(string.Empty);
            }

            try
            {
                using (var dbConn = this._dbConnectionFactory.BuildConn())
                {
                    var id = await dbConn.ExecuteScalarAsync <string>(InsertBrokerSql, broker);

                    return(id);
                }
            }
            catch (Exception e)
            {
                this._logger?.LogError(e, $"Error in broker insert or update");
                return(string.Empty);
            }
        }
示例#3
0
 public OrderService(IOrderRepository orderRepository, IOrderBroker orderBroker, ILogger <OrderService> logger)
 {
     _orderRepository = orderRepository;
     _orderBroker     = orderBroker;
     _logger          = logger;
 }
        public Order(
            FinancialInstrument instrument,
            Market market,
            int?reddeerOrderId,
            string orderId,
            DateTime?created,
            string orderVersion,
            string orderVersionLinkId,
            string orderGroupId,
            DateTime?placedDate,
            DateTime?bookedDate,
            DateTime?amendedDate,
            DateTime?rejectedDate,
            DateTime?cancelledDate,
            DateTime?filledDate,
            OrderTypes orderType,
            OrderDirections orderDirection,
            Currency orderCurrency,
            Currency?orderSettlementCurrency,
            OrderCleanDirty orderCleanDirty,
            decimal?orderAccumulatedInterest,
            Money?orderLimitPrice,
            Money?orderAverageFillPrice,
            decimal?orderOrderedVolume,
            decimal?orderFilledVolume,
            string orderTraderId,
            string orderTraderName,
            string orderClearingAgent,
            string orderDealingInstructions,
            IOrderBroker orderBroker,
            Money?orderOptionStrikePrice,
            DateTime?orderOptionExpirationDate,
            OptionEuropeanAmerican orderOptionEuropeanAmerican,
            IReadOnlyCollection <DealerOrder> trades)
            : base(placedDate, bookedDate, amendedDate, rejectedDate, cancelledDate, filledDate)
        {
            // keys
            this.Instrument     = instrument ?? throw new ArgumentNullException(nameof(instrument));
            this.Market         = market ?? throw new ArgumentNullException(nameof(market));
            this.ReddeerOrderId = reddeerOrderId;
            this.OrderId        = orderId ?? string.Empty;

            // versioning
            this.OrderVersion       = orderVersion ?? string.Empty;
            this.OrderVersionLinkId = orderVersionLinkId ?? string.Empty;
            this.OrderGroupId       = orderGroupId ?? string.Empty;

            // dates
            this.CreatedDate = created;

            // order fundamentals
            this.OrderType                = orderType;
            this.OrderDirection           = orderDirection;
            this.OrderCurrency            = orderCurrency;
            this.OrderSettlementCurrency  = orderSettlementCurrency;
            this.OrderCleanDirty          = orderCleanDirty;
            this.OrderAccumulatedInterest = orderAccumulatedInterest;
            this.OrderLimitPrice          = orderLimitPrice;
            this.OrderAverageFillPrice    = orderAverageFillPrice;
            this.OrderOrderedVolume       = orderOrderedVolume;
            this.OrderFilledVolume        = orderFilledVolume;
            this.OrderBroker              = orderBroker;

            // order trader and post trade
            this.OrderTraderId            = orderTraderId ?? string.Empty;
            this.OrderTraderName          = orderTraderName ?? string.Empty;
            this.OrderClearingAgent       = orderClearingAgent ?? string.Empty;
            this.OrderDealingInstructions = orderDealingInstructions ?? string.Empty;

            // options
            this.OrderOptionStrikePrice      = orderOptionStrikePrice;
            this.OrderOptionExpirationDate   = orderOptionExpirationDate;
            this.OrderOptionEuropeanAmerican = orderOptionEuropeanAmerican;

            // associated dealer orders
            this.DealerOrders = trades ?? new DealerOrder[0];
        }