public async Task Buy(Sample rate) { rate = rate ?? throw new ArgumentNullException(nameof(rate)); if (!initialized) { throw new InvalidOperationException("Broker cannot Buy until Initialized!"); } Order order = await this.exchange.Buy(rate, asset2); if (order == null) { return; // nothing to do; already all-in on Asset 1 } do { await time.Wait(1000); order = await this.exchange.CheckOrder(order); } while (!order.Fulfilled); this.asset1 = await this.exchange.GetAssetBalance(asset1Type); this.asset2 = await this.exchange.GetAssetBalance(asset2Type); }