public void TestRequestOrderBook() { var deferred = new Task(() => { }); _remote = new Remote(ServerUrl); MessageResult <OrderBookResponse> response = null; _remote.Connect(r => { var options = new OrderBookOptions(); options.Limit = 1; options.Gets = Amount.SWT(); options.Pays = new Amount("CNY", "jBciDE8Q3uJjf111VeiUNM775AMKHEbBLS"); var req = _remote.RequestOrderBook(options); req.Submit(r1 => { response = r1; deferred.Start(); }); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); var result = response.Result; Assert.IsNotNull(result); Assert.IsNotNull(result.Offers); }
private void RefreshOffers() { var optionsBuy = new OrderBookOptions(); optionsBuy.Limit = 10; optionsBuy.Gets = new Amount { Currency = "SWT", Issuer = "" }; optionsBuy.Pays = new Amount { Currency = "CNY", Issuer = "jGa9J9TkqtBcUoHe2zqhVFFbgUVED6o9or" }; Global.Remote.RequestOrderBook(optionsBuy).Submit(r => { this.SafeInvoke(() => RefreshOrderBook(lvBuy, r.Result)); }); var optionsSell = new OrderBookOptions(); optionsSell.Limit = 10; optionsSell.Pays = new Amount { Currency = "SWT", Issuer = "" }; optionsSell.Gets = new Amount { Currency = "CNY", Issuer = "jGa9J9TkqtBcUoHe2zqhVFFbgUVED6o9or" }; Global.Remote.RequestOrderBook(optionsSell).Submit(r => { this.SafeInvoke(() => RefreshOrderBook(lvSell, r.Result)); }); }
private void InitRequestOrderBookOptions() { var options = new OrderBookOptions(); options.Gets = Amount.SWT(); options.Pays = new Amount("CNY", "jBciDE8Q3uJjf111VeiUNM775AMKHEbBLS"); pgRequestOrderBookOptions.SelectedObject = options; }
public void TestRequestOrderBook_Invalid() { var deferred = new Task(() => { }); MessageResult <OrderBookResponse> response = null; var options = new OrderBookOptions(); options.Gets = new Amount("SWT", "", "1"); options.Pays = new Amount("abc", "xyz", "def"); _remote.RequestOrderBook(options).Submit(r => { response = r; deferred.Start(); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); Assert.IsInstanceOfType(response.Exception, typeof(InvalidAmountException)); var ex = response.Exception as InvalidAmountException; Assert.AreEqual("Pays", ex.Name); deferred = new Task(() => { }); response = null; options = new OrderBookOptions(); options.Pays = new Amount { Currency = "SWT", Issuer = "", Value = "1" }; options.Gets = new Amount { Currency = "abc", Issuer = "xyz", Value = "def" }; _remote.RequestOrderBook(options).Submit(r => { response = r; deferred.Start(); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); Assert.IsInstanceOfType(response.Exception, typeof(InvalidAmountException)); ex = response.Exception as InvalidAmountException; Assert.AreEqual("Gets", ex.Name); }
public void TestRequestOrderBookResponse() { var remote = new Remote(""); remote.SetMockServer(new MockServer(remote, "RequestOrderBook.json")); MessageResult <OrderBookResponse> response = null; var deferred = new Task(() => { }); var options = new OrderBookOptions(); options.Gets = Amount.SWT(); options.Pays = new Amount("CNY", "jGa9J9TkqtBcUoHe2zqhVFFbgUVED6o9or"); remote.RequestOrderBook(options).Submit(r => { response = r; deferred.Start(); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); var result = response.Result; Assert.IsNotNull(result); Assert.AreEqual(10, result.Offers.Length); var offer0 = result.Offers[0]; Assert.AreEqual("jJpfha3V2W8cHuB246Nm1EscFPyyhy5NiL", offer0.Account); Assert.AreEqual(5261, offer0.Sequence); var offer9 = result.Offers[9]; Assert.AreEqual("jJ6NTADAhFJJMKMq8bdLA84YixXX31TkaX", offer9.Account); Assert.IsFalse(offer9.IsSell); }
public FtxSymbolOrderBook(string symbol, OrderBookOptions options) : base(symbol, options) { }