public async Task PlaceLimitOrderTest()
        {
            _handler.Expect(HttpMethod.Post, $"{BaseUri}orders/limit-order")
            .WithQueryString(new Dictionary <string, string>
            {
                ["figi"]            = Figi,
                ["brokerAccountId"] = BrokerAccountId
            })
            .WithJsonContentFromFile("limit-order-request")
            .RespondJsonFromFile("limit-order-response");

            var placedLimitOrder = await _context.PlaceLimitOrderAsync(new LimitOrder(Figi, 10,
                                                                                      OperationType.Sell, 288.3m, BrokerAccountId));

            var expected = new PlacedLimitOrder(
                "12345687",
                OperationType.Sell,
                OrderStatus.New,
                "That's Why",
                10,
                0,
                new MoneyAmount(Currency.Usd, 1.44m));

            placedLimitOrder.Should().BeEquivalentTo(expected);
        }
Beispiel #2
0
        public async Task PlaceLimitOrderTest()
        {
            var handler          = new HttpMessageHandlerStub(HttpStatusCode.OK, "{\"trackingId\":\"QBASTAN\",\"status\":\"OK\",\"payload\":{\"orderId\":\"12345687\",\"operation\":\"Sell\",\"status\":\"New\",\"rejectReason\":\"That's Why\",\"requestedLots\":10,\"executedLots\":0,\"commission\":{\"currency\":\"USD\",\"value\":1.44}}}");
            var connection       = new Connection(BaseUri, WebSocketBaseUri, Token, new HttpClient(handler));
            var context          = connection.Context;
            var placedLimitOrder = await context.PlaceLimitOrderAsync(new LimitOrder("BBG000CL9VN6", 10, OperationType.Sell, 288.3m));

            Assert.NotNull(handler.RequestMessage);
            Assert.Equal(HttpMethod.Post, handler.RequestMessage.Method);
            Assert.Equal(new Uri($"{BaseUri}orders/limit-order?figi=BBG000CL9VN6"), handler.RequestMessage.RequestUri);
            Assert.NotNull(handler.RequestMessage.Content);

            var content = await handler.RequestMessage.Content.ReadAsStringAsync();

            Assert.Equal("{\"lots\":10,\"operation\":\"Sell\",\"price\":288.3}", content);

            Assert.NotNull(placedLimitOrder);

            var expected = new PlacedLimitOrder(
                "12345687",
                OperationType.Sell,
                OrderStatus.New,
                "That's Why",
                10,
                0,
                new MoneyAmount(Currency.Usd, 1.44m));

            Assert.Equal(expected.OrderId, placedLimitOrder.OrderId);
            Assert.Equal(expected.Operation, placedLimitOrder.Operation);
            Assert.Equal(expected.Status, placedLimitOrder.Status);
            Assert.Equal(expected.RejectReason, placedLimitOrder.RejectReason);
            Assert.Equal(expected.RequestedLots, placedLimitOrder.RequestedLots);
            Assert.Equal(expected.ExecutedLots, placedLimitOrder.ExecutedLots);
            Assert.Equal(expected.Commission.Value, placedLimitOrder.Commission.Value);
            Assert.Equal(expected.Commission.Currency, placedLimitOrder.Commission.Currency);
        }
 public LimitOrderResponse([JsonProperty("payload")] PlacedLimitOrder limitOrder)
 {
     Order = limitOrder;
 }