Beispiel #1
0
        public async Task BuildersRisk_Revise_ShouldReturnOkStatus()
        {
            var testData = _buildersRiskHelpers.GetDefaultTestData(BuildersRiskApplicationStatus.Submitted);

            var result = await _httpHelpers.CreateApplication(testData);

            await _httpHelpers.CreateQuote(result.ApplicationId);

            await _httpHelpers.SubmitApplication(result.ApplicationId);

            var update = new QuoteUpdate {
                Subtotal = 999999
            };

            await _httpHelpers.ReviewQuote(result.ApplicationId, update);

            var reviseStatus = await _httpHelpers.ReviseQuote(result.ApplicationId, "QA Revise Quote Test");

            reviseStatus.Should().Be(HttpStatusCode.OK);
        }
Beispiel #2
0
 /// <summary>
 /// Events
 /// </summary>
 private void OnQuoteUpdate(QuoteUpdate cmd)
 {
     ThreadPool.QueueUserWorkItem(o =>
     {
         try
         {
             if (TickArrived == null || cmd.quote.last <= 0)
             {
                 return;
             }
             TickArrived(new Tick(cmd.quote.symbol, DateTime.Now, (decimal)cmd.quote.last));
         }
         catch (Exception e)
         {
             if (InfoChanged != null)
             {
                 InfoChanged(e.Message + Environment.NewLine + e.StackTrace);
             }
         }
     });
 }
Beispiel #3
0
        public async Task BuildersRisk_Review_ShouldReturnOkStatus()
        {
            var testData = _buildersRiskHelpers.GetDefaultTestData(BuildersRiskApplicationStatus.Submitted);

            var result = await _httpHelpers.CreateApplication(testData);

            await _httpHelpers.CreateQuote(result.ApplicationId);

            await _httpHelpers.SubmitApplication(result.ApplicationId);

            var update = new QuoteUpdate {
                Subtotal = 999999
            };

            var reviewResponse = await _httpHelpers.ReviewQuote(result.ApplicationId, update);

            JObject appObj = JObject.Parse(reviewResponse.Quote);

            var newSubtotal = decimal.Parse(appObj.GetValue("subtotal").ToString());

            newSubtotal.Should().Be(update.Subtotal);

            reviewResponse.StatusCode.Should().Be(HttpStatusCode.OK);
        }
Beispiel #4
0
		private static QuoteUpdate[] createUpdaters ()
		{
            mMaxFid = MamdaQuoteFields.getMaxFid();
			QuoteUpdate[] updaters = new QuoteUpdate[mMaxFid+1];

			addToUpdatersList(updaters, MamdaQuoteFields.SYMBOL, new MamdaQuoteSymbol());
			addToUpdatersList(updaters, MamdaQuoteFields.ISSUE_SYMBOL, new MamdaQuoteIssueSymbol());
			addToUpdatersList(updaters, MamdaQuoteFields.PART_ID, new MamdaQuotePartId());
			addToUpdatersList(updaters, MamdaQuoteFields.SRC_TIME, new MamdaQuoteSrcTime());
			addToUpdatersList(updaters, MamdaQuoteFields.ACTIVITY_TIME, new MamdaQuoteActivityTime());
			addToUpdatersList(updaters, MamdaQuoteFields.LINE_TIME, new MamdaQuoteLineTime());
			addToUpdatersList(updaters, MamdaQuoteFields.SEND_TIME, new MamdaQuoteSendTime());
			addToUpdatersList(updaters, MamdaQuoteFields.PUB_ID, new MamdaQuotePubId());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_PRICE, new MamdaQuoteBidPrice());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_SIZE, new MamdaQuoteBidSize());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_PART_ID, new MamdaQuoteBidPartId());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_DEPTH, new MamdaQuoteBidDepth());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_CLOSE_PRICE, new MamdaQuoteBidClosePrice());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_CLOSE_DATE, new MamdaQuoteBidCloseDate());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_PREV_CLOSE_PRICE, new MamdaQuoteBidPrevClosePrice());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_PREV_CLOSE_DATE, new MamdaQuoteBidPrevCloseDate());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_HIGH, new MamdaQuoteBidHigh());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_LOW, new MamdaQuoteBidLow());
			addToUpdatersList(updaters, MamdaQuoteFields.ASK_PRICE, new MamdaQuoteAskPrice());
			addToUpdatersList(updaters, MamdaQuoteFields.ASK_SIZE, new MamdaQuoteAskSize());
			addToUpdatersList(updaters, MamdaQuoteFields.ASK_PART_ID, new MamdaQuoteAskPartId());
			addToUpdatersList(updaters, MamdaQuoteFields.ASK_DEPTH, new MamdaQuoteAskDepth());
			addToUpdatersList(updaters, MamdaQuoteFields.ASK_CLOSE_PRICE, new MamdaQuoteAskClosePrice());
			addToUpdatersList(updaters, MamdaQuoteFields.ASK_CLOSE_DATE, new MamdaQuoteAskCloseDate());
			addToUpdatersList(updaters, MamdaQuoteFields.ASK_PREV_CLOSE_PRICE, new MamdaQuoteAskPrevClosePrice());
			addToUpdatersList(updaters, MamdaQuoteFields.ASK_PREV_CLOSE_DATE, new MamdaQuoteAskPrevCloseDate());
			addToUpdatersList(updaters, MamdaQuoteFields.ASK_HIGH, new MamdaQuoteAskHigh());
			addToUpdatersList(updaters, MamdaQuoteFields.ASK_LOW, new MamdaQuoteAskLow());
			addToUpdatersList(updaters, MamdaQuoteFields.QUOTE_SEQ_NUM, new MamdaQuoteSeqNum());
			addToUpdatersList(updaters, MamdaQuoteFields.QUOTE_TIME, new MamdaQuoteTime());
            addToUpdatersList(updaters, MamdaQuoteFields.QUOTE_DATE, new MamdaQuoteDate());
			addToUpdatersList(updaters, MamdaQuoteFields.QUOTE_QUAL, new MamdaQuoteQual());
			addToUpdatersList(updaters, MamdaQuoteFields.QUOTE_QUAL_NATIVE, new MamdaQuoteQualNative());
			addToUpdatersList(updaters, MamdaQuoteFields.QUOTE_COUNT, new MamdaQuoteCount());
            addToUpdatersList(updaters, MamdaQuoteFields.CONFLATE_COUNT, new MamdaConflateCount());
			addToUpdatersList(updaters, MamdaQuoteFields.SHORT_SALE_BID_TICK, new MamdaShortSaleBidTick());
            addToUpdatersList(updaters, MamdaQuoteFields.SHORT_SALE_CIRCUIT_BREAKER, new MamdaShortSaleCircuitBreaker());
			addToUpdatersList(updaters, MamdaQuoteFields.BID_TICK, new MamdaShortSaleBidTick());
            
            addToUpdatersList (updaters, MamdaQuoteFields.ASK_TIME, new MamdaAskTime ());
            addToUpdatersList (updaters, MamdaQuoteFields.BID_TIME, new MamdaBidTime ());
            addToUpdatersList (updaters, MamdaQuoteFields.ASK_INDICATOR, new MamdaAskIndicator ());
            addToUpdatersList (updaters, MamdaQuoteFields.BID_INDICATOR, new MamdaBidIndicator ());
            addToUpdatersList (updaters, MamdaQuoteFields.ASK_UPDATE_COUNT, new MamdaAskUpdateCount ());
            addToUpdatersList (updaters, MamdaQuoteFields.BID_UPDATE_COUNT, new MamdaBidUpdateCount ());
            addToUpdatersList (updaters, MamdaQuoteFields.ASK_YIELD, new MamdaAskYield ());
            addToUpdatersList (updaters, MamdaQuoteFields.BID_YIELD, new MamdaBidYield ());
			return updaters;
		}
Beispiel #5
0
		private static void addToUpdatersList(
			QuoteUpdate[]		updaters,
			MamaFieldDescriptor	fieldDesc,
			QuoteUpdate			updater)
		{
			if (fieldDesc == null) return;
			int fieldId = fieldDesc.getFid();
            if (fieldId <= mMaxFid)
            {
                updaters[fieldId] = updater;
            }
		}
Beispiel #6
0
        /// <summary>
        /// Process the incoming messages
        /// </summary>
        /// <param name="message">Incoming message</param>
        private void processMessage(string message)
        {
            // Deserialize the incoming command to check wich message has just arrived
            // The action property brings the command name
            switch (Command.Deserialize(message).action)
            {
            case KeepAlive.CLASSNAME:
            {           // If it is a KeepAlive message, just answer Quantsis Conneciton Box another KeepAlive message
                        //CheckAsyncTaskInProgress
                this.send(new KeepAlive().Serialize());
                break;
            }

            case NewOrderResponse.CLASSNAME:
            {           // If it is an NewOrderResponse message and it contains error, show the error message
                var cmd = NewOrderResponse.Deserialize(message);
                if (!cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case NewStopOrderResponse.CLASSNAME:
            {           // If it is an NewStopOrderResponse message and it contains error, show the error message
                var cmd = NewStopOrderResponse.Deserialize(message);
                if (!cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case NewStopGainLossOrderResponse.CLASSNAME:
            {           // If it is an NewStopGainLossOrderResponse message and it contains error, show the error message
                var cmd = NewStopGainLossOrderResponse.Deserialize(message);
                if (!cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case CancelOrderResponse.CLASSNAME:
            {           // If it is an CancelOrderResponse message and it contains error, show the error message
                var cmd = CancelOrderResponse.Deserialize(message);
                if (!cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case ExecutionReport.CLASSNAME:
            {           // If it is an ExecutionReport message, check if it was successful and updates the order list or show error message
                var cmd = ExecutionReport.Deserialize(message);
                if (cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                else
                {
                    NotifyOMS(cmd.ToString());
                }

                break;
            }

            case OrderListResponse.CLASSNAME:
            {           // If it is an OrderListResponse, check if it was successful. In negative case show error message.
                var cmd = OrderListResponse.Deserialize(message);
                if (!cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case PositionResponse.CLASSNAME:
            {           // If it is a Position Response, check if it was successful and updates the position list. In case of failure, show error messasge
                var cmd = PositionResponse.Deserialize(message);
                if (cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                else
                {
                    NotifyOMS(cmd.ToString());
                }

                break;
            }

            case QuoteResponse.CLASSNAME:
            {           // If it is a Quote Response, check if it was successful and logs the message
                var cmd = QuoteResponse.Deserialize(message);
                if (cmd.success)
                {
                    OnQuoteResponse(cmd);
                }
                else
                {
                    NotifyQCB(cmd.ToString());
                }
                break;
            }

            case QuoteUpdate.CLASSNAME:
            {           // If it is a Quote Update, check if it was successful and logs the message
                var cmd = QuoteUpdate.Deserialize(message);
                if (cmd.success)
                {
                    OnQuoteUpdate(cmd);
                }
                else
                {
                    NotifyQCB(cmd.ToString());
                }
                break;
            }

            case QuoteUnsubscribeResponse.CLASSNAME:
            {           // If it is a Quote Unsubscribe Response, check if it was successful
                var cmd = QuoteUnsubscribeResponse.Deserialize(message);
                if (cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                else
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case CandleResponse.CLASSNAME:
            {           // If it is a Quote Update, check if it was successful and logs the message
                var cmd = CandleResponse.Deserialize(message);
                if (cmd.success)
                {
                    if (cmd.candles != null)
                    {
                        if (cmd.candles.Count <= 0)
                        {
                            NotifyOMS("Nenhum foi possivel retornar nenhum candle para " + cmd.security + " - Timeframe: " + cmd.timeframe);
                        }
                        else
                        {
                            NotifyOMS("Dados Historicos Intraday para: " + cmd.security + " - Qtd de Candles: " + cmd.candles.Count + " - Timeframe: " + cmd.timeframe);
                            //foreach (Candle candle in cmd.candles)
                            //    this.mainForm.log(candle.ToString());
                        }
                    }
                }
                else
                {
                    NotifyOMS(cmd.ToString());
                }

                break;
            }

            // Candle Update
            case CandleUpdate.CLASSNAME:
            {           // If it is a Candle Update, check if it was successful and logs the message
                var cmd = CandleUpdate.Deserialize(message);

                if (cmd.success)
                {
                    if (cmd.candle != null)
                    {
                        switch (cmd.timeframe)
                        {
                        case CandleUpdate.TIMEFRAME_INTRADAY_1_MIN:
                            NotifyOMS("Candle Intraday Update: " + cmd.security + " - Last: " + cmd.candle.close + " - Time: " + cmd.candle.date);
                            break;

                        case CandleUpdate.TIMEFRAME_DAILY:
                            NotifyOMS("Candle Daily Update: " + cmd.security + " - Last: " + cmd.candle.close + " - Time: " + cmd.candle.date);
                            break;
                        }
                    }
                }
                //this.mainForm.updatePositions(cmd);
                else
                {
                    NotifyOMS(cmd.ToString());
                }

                break;
            }

            // QCB has disconnected (shut down)
            case Disconnect.CLASSNAME:
                this.disconnect();
                break;
            }
        }