コード例 #1
0
        public async Task ChildOrder()
        {
            await apiClient.CancelAllOrders(new CancelAllOrdersParameter
            {
                ProductCode = ProductCode.FxBtcJpy
            });

            var res1 = await apiClient.SendChildOrder(new SendChildOrderParameter
            {
                ProductCode    = ProductCode.FxBtcJpy,
                ChildOrderType = ChildOrderType.Limit,
                Side           = Side.Buy,
                Price          = buyPrice,
                Size           = OrderSize,
                MinuteToExpire = 10000,
                TimeInForce    = TimeInForce.GoodTilCanceled
            });

            var childOrderAcceptanceId = res1?.ChildOrderAcceptanceId;

            Assert.NotNull(childOrderAcceptanceId);

            var health = await PublicApi.GetHealth();

            ThreadSleep(health.Status);

            var res2 = await apiClient.GetChildOrders(ProductCode.FxBtcJpy);

            Assert.Contains(res2, x => x.ProductCode == ProductCode.FxBtcJpy &&
                            x.ChildOrderState == ChildOrderState.Active);

            await apiClient.CancelChildOrder(new CancelChildOrderParameter
            {
                ProductCode            = ProductCode.FxBtcJpy,
                ChildOrderAcceptanceId = childOrderAcceptanceId
            });

            await Task.WhenAll(Enumerable.Range(0, 3).Select(_ => apiClient.SendChildOrder(new SendChildOrderParameter
            {
                ProductCode    = ProductCode.FxBtcJpy,
                ChildOrderType = ChildOrderType.Limit,
                Side           = Side.Buy,
                Price          = buyPrice,
                Size           = OrderSize,
                MinuteToExpire = 10000,
                TimeInForce    = TimeInForce.GoodTilCanceled
            })));

            ThreadSleep(health.Status);

            await apiClient.CancelAllOrders(new CancelAllOrdersParameter
            {
                ProductCode = ProductCode.FxBtcJpy
            });

            ThreadSleep(health.Status);

            var res3 = await apiClient.GetChildOrders(ProductCode.FxBtcJpy);

            Assert.True(res3.Count(x => x.ProductCode == ProductCode.FxBtcJpy &&
                                   x.ChildOrderState == ChildOrderState.Active) == 0);
        }