Example #1
0
        public PricingRequest(IQuoteRequest request) : this(request.ClientRequestId, request.Symbol, string.Empty)
        {
            NearTenor          = request.Tenor;
            NearAmount         = request.Amount;
            Account            = request.Account;
            Side               = request.Side.ToString();
            NearSettlementDate = request.SettlementDate;
            Currency           = request.Currency;

            if (request.GetType() != typeof(SwapQuoteRequest))
            {
                NearAllocations = request.GetType() == typeof(SpotQuoteRequest) ? ((SpotQuoteRequest)request).Allocations : ((ForwardQuoteRequest)request).Allocations;
                return;
            }

            var swapRequest = (SwapQuoteRequest)request;

            NearAllocations   = swapRequest.Allocations;
            FarTenor          = swapRequest.FarTenor;
            FarSettlementDate = swapRequest.FarSettleDate;
            FarAmount         = swapRequest.FarAmount;
            FarAllocations    = swapRequest.FarAllocations;

            Prices = new EntitySet <PricingResponse>();
        }
Example #2
0
        private void OnEntryRequesting(IQuoteRequest quoteRequest)
        {
            _rfqUpdateSubject.OnNext(new RfqUpdate(RfqState.Requesting, null, null));

            _requestSubscription.Disposable = _rfqService.RequestQuoteStream(quoteRequest)
                                              .Timeout(TimeSpan.FromSeconds(5))
                                              .ObserveOn(_concurrencyService.Dispatcher)
                                              .SubscribeOn(_concurrencyService.TaskPool)
                                              .Subscribe(
                // /!\ we are only allowed to transition the state machine here, no other code!
                // This applies to all server callbacks
                quote => _stateMachine.Fire(_rfqEventServerSendsQuote, quote),
                ex => _stateMachine.Fire(_rfqEventServerQuoteError, ex),
                () => _stateMachine.Fire(RfqEvent.ServerQuoteStreamComplete));
        }
Example #3
0
        public bool RequestQuote(IQuoteRequest quoteRequest)
        {
            try {
                var tags = new List <Tuple <int, string> > {
                    new Tuple <int, string>(35, "R"),
                    new Tuple <int, string>(34, SequenceId.ToString(CultureInfo.InvariantCulture)),
                    new Tuple <int, string>(49, SenderId),
                    new Tuple <int, string>(56, TargetId),
                    new Tuple <int, string>(52, DateTime.Now.ToString("yyyyMMdd-HH:mm:ss.fff")),
                    new Tuple <int, string>(131, quoteRequest.ClientRequestId),
                    new Tuple <int, string>(146, "1"),
                    new Tuple <int, string>(55, quoteRequest.Symbol),
                    new Tuple <int, string>(15, quoteRequest.Currency),
                    new Tuple <int, string>(167, "FOR"),
                    new Tuple <int, string>(54, ((int)quoteRequest.Side).ToString(CultureInfo.InvariantCulture)),
                    new Tuple <int, string>(38, quoteRequest.Amount.ToString(CultureInfo.InvariantCulture)),
                    new Tuple <int, string>(40, quoteRequest.GetType() == typeof(SwapQuoteRequest) ? "G" : "H"),
                    new Tuple <int, string>(64, quoteRequest.SettlementDate.ToString("yyyyMMdd")),
                    new Tuple <int, string>(6215, quoteRequest.Tenor),
                    new Tuple <int, string>(1, quoteRequest.Account)
                };

                if (quoteRequest.GetType() == typeof(SwapQuoteRequest))
                {
                    var swapQuoteRequest = (SwapQuoteRequest)quoteRequest;
                    tags.AddRange(new [] {
                        new Tuple <int, string>(192, swapQuoteRequest.FarAmount.ToString(CultureInfo.InvariantCulture)),
                        new Tuple <int, string>(193, swapQuoteRequest.FarSettleDate.ToString("yyyyMMdd")),
                        new Tuple <int, string>(6216, swapQuoteRequest.FarTenor)
                    });
                }

                SendFixMessage(tags);
            } catch (Exception ex) {
                _logger.WriteLine("{0:yyyy-MM-dd HH:mm:ss.fff} - Failed to send Quote Request, {1}", DateTime.Now, ex.Message);
                return(false);
            }

            return(true);
        }
Example #4
0
        public bool RejectQuote(IQuoteRequest quoteRequest, string quoteId)
        {
            try {
                var tags = new[] {
                    new Tuple <int, string>(35, "b"),
                    new Tuple <int, string>(34, SequenceId.ToString(CultureInfo.InvariantCulture)),
                    new Tuple <int, string>(49, SenderId),
                    new Tuple <int, string>(56, TargetId),
                    new Tuple <int, string>(52, DateTime.Now.ToString("yyyyMMdd-HH:mm:ss.fff")),
                    new Tuple <int, string>(131, quoteRequest.ClientRequestId),
                    new Tuple <int, string>(117, quoteId),
                    new Tuple <int, string>(297, "5") // quote ack status rejected
                };

                SendFixMessage(tags);
            } catch (Exception ex) {
                _logger.WriteLine("{0:yyyy-MM-dd HH:mm:ss.fff} - Quote Rejection failed, {1}", DateTime.Now, ex.Message);
                return(false);
            }

            return(true);
        }
Example #5
0
        /* ----------------------------------------
        *              PUBLIC API
        *
        *  /!\ Only statemachine transitions allowed here /!\
        *
        * ---------------------------------------*/

        public void RequestQuote(IQuoteRequest quoteRequest)
        {
            _stateMachine.Fire(_rfqEventUserRequests, quoteRequest);
        }
 public IObservable<IQuote> RequestQuoteStream(IQuoteRequest quoteRequest)
 {
     return RequestQuoteSubject;
 }
Example #7
0
        /* ----------------------------------------
         *              PUBLIC API
         *              
         *  /!\ Only statemachine transitions allowed here /!\ 
         * 
         * ---------------------------------------*/

        public void RequestQuote(IQuoteRequest quoteRequest)
        {
            _stateMachine.Fire(_rfqEventUserRequests, quoteRequest);
        }
Example #8
0
        private void OnEntryRequesting(IQuoteRequest quoteRequest)
        {
            _rfqUpdateSubject.OnNext(new RfqUpdate(RfqState.Requesting, null, null));

            _requestSubscription.Disposable = _rfqService.RequestQuoteStream(quoteRequest)
                .Timeout(TimeSpan.FromSeconds(5))
                .ObserveOn(_concurrencyService.Dispatcher)
                .SubscribeOn(_concurrencyService.TaskPool)
                .Subscribe(
                // /!\ we are only allowed to transition the state machine here, no other code! 
                // This applies to all server callbacks
                    quote => _stateMachine.Fire(_rfqEventServerSendsQuote, quote), 
                    ex => _stateMachine.Fire(_rfqEventServerQuoteError, ex),
                    () => _stateMachine.Fire(RfqEvent.ServerQuoteStreamComplete));
        }
Example #9
0
 public IObservable <IQuote> RequestQuoteStream(IQuoteRequest quoteRequest)
 {
     return(RequestQuoteSubject);
 }