public async Task ParentOrder() { await apiClient.CancelAllOrders(new CancelAllOrdersParameter { ProductCode = ProductCode.FxBtcJpy }); var parameter = new SendParentOrderParameter { OrderMethod = OrderMethod.IfDone, MinuteToExpire = 10000, TimeInForce = TimeInForce.GoodTilCanceled, Parameters = new[] { new ParentOrderDetailParameter { ProductCode = ProductCode.FxBtcJpy, ConditionType = ConditionType.Limit, Side = Side.Buy, Price = buyPrice, Size = OrderSize }, new ParentOrderDetailParameter { ProductCode = ProductCode.FxBtcJpy, ConditionType = ConditionType.Stop, Side = Side.Sell, TriggerPrice = sellPrice, Size = OrderSize } } }; var res1 = await apiClient.SendParentOrder(parameter); var parentOrderAcceptanceId = res1?.ParentOrderAcceptanceId; Assert.NotNull(parentOrderAcceptanceId); var health = await PublicApi.GetHealth(); ThreadSleep(health.Status); var trail = new SendParentOrderParameter { Parameters = new[] { new ParentOrderDetailParameter { ProductCode = ProductCode.FxBtcJpy, ConditionType = ConditionType.Trail, Side = Side.Buy, Offset = 30000, Size = OrderSize } } }; var resTrail = await apiClient.SendParentOrder(trail); var trailParentOrderAcceptanceId = resTrail?.ParentOrderAcceptanceId; Assert.NotNull(trailParentOrderAcceptanceId); ThreadSleep(health.Status); var resAll = await apiClient.GetParentOrders(ProductCode.FxBtcJpy, 10); Assert.NotNull(resAll); ThreadSleep(health.Status); var res2 = await apiClient.GetParentOrder(ProductCode.FxBtcJpy, parentOrderAcceptanceId : parentOrderAcceptanceId); Assert.NotNull(res2); await apiClient.CancelParentOrder(new CancelParentOrderParameter { ProductCode = ProductCode.FxBtcJpy, ParentOrderAcceptanceId = parentOrderAcceptanceId }); ThreadSleep(health.Status); var resTrail2 = await apiClient.GetParentOrder(ProductCode.FxBtcJpy, parentOrderAcceptanceId : trailParentOrderAcceptanceId); Assert.NotNull(resTrail2); await apiClient.CancelParentOrder(new CancelParentOrderParameter { ProductCode = ProductCode.FxBtcJpy, ParentOrderAcceptanceId = trailParentOrderAcceptanceId }); ThreadSleep(health.Status); await Task.WhenAll(Enumerable.Range(0, 3).Select(_ => apiClient.SendParentOrder(parameter))); ThreadSleep(health.Status); await apiClient.CancelAllOrders(new CancelAllOrdersParameter { ProductCode = ProductCode.FxBtcJpy }); ThreadSleep(health.Status); var res3 = await apiClient.GetParentOrders(ProductCode.FxBtcJpy); Assert.True(res3.Count(x => x.ProductCode == ProductCode.FxBtcJpy && x.ParentOrderState == ParentOrderState.Active) == 0); }
public async Task GetHealth() { var res1 = await PublicApi.GetHealth(); Assert.NotNull(res1); }
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); }