private async Task MassCancelAsync(CancellationToken cancellationToken)
        {
            // cancel orders that will open positions for specific symbol and side
            var report = await _restClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-1"),
                                                                "XBTUSD", Side.Buy, PositionEffect.Open).ConfigureAwait(false);

            _logger.LogInformation($"Order mass cancel report 1: {report}");

            // cancel all orders for specific symbol and side
            report = await _restClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-2"),
                                                            "XBTUSD", Side.Buy).ConfigureAwait(false);

            _logger.LogInformation($"Order mass cancel report 2: {report}");

            // cancel all orders for specific symbol
            report = await _restClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-3"),
                                                            "XBTUSD").ConfigureAwait(false);

            _logger.LogInformation($"Order mass cancel report 3: {report}");

            // cancel all order for account
            report = await _restClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-4"))
                     .ConfigureAwait(false);

            _logger.LogInformation($"Order mass cancel report 4: {report}");
        }
Exemple #2
0
        public async Task Test_MassCancel()
        {
            var          clOrdId = NewClOrdId("mass-cancel");
            const string symbol  = "XBTUSD";
            const string side    = Side.Buy;

            var report = await _restClient.OrderMassCancelAsync(
                MarginAccountId,
                clOrdId,
                symbol,
                side,
                cancellationToken : _token).ConfigureAwait(false);

            report.MsgType.Should().Be(MsgTypes.OrderMassCancelReport);
            report.Account.Should().Be(MarginAccountId);
            report.Side.Should().Be(side);
            report.Symbol.Should().Be(symbol);
            report.ClOrdId.Should().Be(clOrdId);
            report.TotalAffectedOrders.Should().Be(0);
            report.MassActionReportID.Should().NotBeNullOrWhiteSpace();
            report.MassCancelRejectReason.Should().BeNullOrEmpty();
            report.RejectText.Should().BeNullOrEmpty();
        }