public void ParseYes()
        {
            var data = new TradeData();

            // Header

            data.Data.Add(new object[] { "Uuid", "Exchange", "Type", "Quantity", "Limit", "CommissionPaid", "Price", "Opened", "Closed" });

            // Buy

            data.Data.Add(new object[] { "031d20b1-6394-4ea5-b89b-52fe677fc731", "USDT-BTC", "LIMIT_BUY", "0.00117194", "8042.82891", "0.02356428", "9.42571291", "12/16/2017 7:12:09 AM", "12/16/2017 10:04:17 AM" });

            // Sell

            data.Data.Add(new object[] { "a19fbf2d-73f8-4526-9856-95b715c1dd42", "USDT-BTC", "LIMIT_SELL", "5.17527292", "5980", "77.39161894", "30956.6476", "12/16/2017 10:47:27 AM", "12/16/2017 10:47:27 AM" });

            Assert.IsTrue(_exchange.IsThis(data));

            var source = new TradeDataSource()
            {
                Data = new TradeData[] { data }
            };
            var trades = _exchange.GetTrades(source, data).ToArray();

            Assert.AreEqual(trades.Length, 2);

            // Check

            Assert.IsInstanceOfType(trades[0], typeof(BuyTrade));
            Assert.AreEqual(trades[0].Date, new DateTime(2017, 12, 16, 7, 12, 09, DateTimeKind.Utc));
            Assert.AreEqual(trades[0].Fees.Length, 1);
            Assert.AreEqual(trades[0].Fees[0].Coin, ECoin.USDT);
            Assert.AreEqual(trades[0].Fees[0].Value, 0.02356428M);
            Assert.AreEqual(trades[0].From.Coin, ECoin.USDT);
            Assert.AreEqual(trades[0].From.Value, 9.42571291M);
            Assert.AreEqual(trades[0].To.Coin, ECoin.BTC);
            Assert.AreEqual(trades[0].To.Value, 0.00117194M);
            Assert.AreEqual(trades[0].Price, 8042.828907623257163336006963M);

            Assert.IsInstanceOfType(trades[1], typeof(SellTrade));
            Assert.AreEqual(trades[1].Date, new DateTime(2017, 12, 16, 10, 47, 27, DateTimeKind.Utc));
            Assert.AreEqual(trades[1].Fees.Length, 1);
            Assert.AreEqual(trades[1].Fees[0].Coin, ECoin.USDT);
            Assert.AreEqual(trades[1].Fees[0].Value, 77.39161894M);
            Assert.AreEqual(trades[1].From.Coin, ECoin.BTC);
            Assert.AreEqual(trades[1].From.Value, 5.17527292M);
            Assert.AreEqual(trades[1].To.Coin, ECoin.USDT);
            Assert.AreEqual(trades[1].To.Value, 30956.6476M);
            Assert.AreEqual(trades[1].Price, 5981.6454278898203498029240166M);
        }
        public void ParseYes()
        {
            var data = new TradeData();

            // Header

            data.Data.Add(new object[] { "Date(UTC)", "Market", "Type", "Price", "Amount", "Total", "Fee", "Fee Coin" });

            // Buy

            data.Data.Add(new object[] { "2019-03-19 9:45:47", "ETHUSDT", "BUY", "138.15", "100.5359", "13889.03459", "0.1005359", "ETH" });

            // Sell

            data.Data.Add(new object[] { "2019-02-24 17:02:45", "OMGBTC", "SELL", "0.000334", "4402.61", "1.47047174", "0.42969395", "BNB" });

            Assert.IsTrue(_exchange.IsThis(data));

            var source = new TradeDataSource()
            {
                Data = new TradeData[] { data }
            };
            var trades = _exchange.GetTrades(source, data).ToArray();

            Assert.AreEqual(trades.Length, 2);

            // Check

            Assert.IsInstanceOfType(trades[0], typeof(BuyTrade));
            Assert.AreEqual(trades[0].Date, new DateTime(2019, 03, 19, 9, 45, 47, DateTimeKind.Utc));
            Assert.AreEqual(trades[0].Fees.Length, 1);
            Assert.AreEqual(trades[0].Fees[0].Coin, ECoin.ETH);
            Assert.AreEqual(trades[0].Fees[0].Value, 0.1005359M);
            Assert.AreEqual(trades[0].From.Coin, ECoin.USDT);
            Assert.AreEqual(trades[0].From.Value, 13889.03459M);
            Assert.AreEqual(trades[0].To.Coin, ECoin.ETH);
            Assert.AreEqual(trades[0].To.Value, 100.5359M);
            Assert.AreEqual(trades[0].Price, 138.15000004973347828984472213M);

            Assert.IsInstanceOfType(trades[1], typeof(SellTrade));
            Assert.AreEqual(trades[1].Date, new DateTime(2019, 02, 24, 17, 02, 45, DateTimeKind.Utc));
            Assert.AreEqual(trades[1].Fees.Length, 1);
            Assert.AreEqual(trades[1].Fees[0].Coin, ECoin.BNB);
            Assert.AreEqual(trades[1].Fees[0].Value, 0.42969395M);
            Assert.AreEqual(trades[1].From.Coin, ECoin.OMG);
            Assert.AreEqual(trades[1].From.Value, 4402.61M);
            Assert.AreEqual(trades[1].To.Coin, ECoin.BTC);
            Assert.AreEqual(trades[1].To.Value, 1.47047174M);
            Assert.AreEqual(trades[1].Price, 0.000334M);
        }
示例#3
0
        public void ParseYes()
        {
            var data = new TradeData();

            // Header

            data.Data.Add(new object[] { "txid", "refid", "time", "type", "aclass", "asset", "amount", "fee", "balance" });

            // Ordered

            data.Data.Add(new object[] { "LOCEOI-OZ3UZ-U4IGW3", "TK6PI7-LU6O6-4TFNSX", "'2019-01-08 23:14:00.7934", "trade", "currency", "XETH", "-495.336348", "0", "0.00000001" });
            data.Data.Add(new object[] { "LOW427-2YEAY-KRSPN4", "TK6PI7-LU6O6-4TFNSX", "'2019-01-08 23:14:00.7934", "trade", "currency", "ZEUR", "64735.5072", "142.4183", "64593.0889" });

            // Unordered

            data.Data.Add(new object[] { "LOW427-2YEAY-KRSPN1", "TK6PI7-LU6O6-4TFNSA", "'2019-01-08 23:14:00.7934", "trade", "currency", "ZEUR", "64735.5072", "142.4183", "64593.0889" });
            data.Data.Add(new object[] { "LOCEOI-OZ3UZ-U4IGW2", "TK6PI7-LU6O6-4TFNSA", "'2019-01-08 23:14:00.7934", "trade", "currency", "XETH", "-495.336348", "0", "0.00000001" });


            Assert.IsTrue(_exchange.IsThis(data));

            var source = new TradeDataSource()
            {
                Data = new TradeData[] { data }
            };
            var trades = _exchange.GetTrades(source, data).ToArray();

            Assert.AreEqual(trades.Length, 0);

            // Check

            var vars  = (Dictionary <string, IList <Quantity> >)(source.Variables[KrakenLedgerParser.KrakenLedgerVariableName]);
            var trade = vars["TK6PI7-LU6O6-4TFNSX"].ToArray();

            Assert.AreEqual(trade.Length, 1);
            Assert.AreEqual(trade[0].Coin, ECoin.EUR);
            Assert.AreEqual(trade[0].Value, 142.4183M);

            trade = vars["TK6PI7-LU6O6-4TFNSA"].ToArray();

            Assert.AreEqual(trade.Length, 1);
            Assert.AreEqual(trade[0].Coin, ECoin.EUR);
            Assert.AreEqual(trade[0].Value, 142.4183M);
        }
        public void ParseYes()
        {
            var data = new TradeData();

            // Header

            data.Data.Add(new object[] { "txid", "ordertxid", "pair", "time", "type", "ordertype", "price", "cost", "fee", "vol", "margin", "misc", "ledgers" });

            // Sell

            data.Data.Add(new object[] { "TK6PI7-LU6O6-4TFNSU", "OL4PWT-PATIC-H34G7C", "XETHZEUR", "'2019-01-08 23:14:00.1234", "sell", "limit", "130.69", "64735.5073", "142.41814", "495.336348", "0", "", "LOW427-2YEAY-KRSPNH,LOCEOI-OZ3UZ-U4IGWP" });

            // Buy

            data.Data.Add(new object[] { "TLREIQ-ESBRY-SYVMIE", "ORS77A-PB5OK-GJLNBM", "XETHZEUR", "'2019-01-09 21:35:00.1234", "buy", "limit", "129.37", "6468.5", "14.2307", "50", "0", "", "LRUCE5-2P6JX-UPBY2F,LF5JER-3CDMZ-WJIGQK" });


            Assert.IsTrue(_exchange.IsThis(data));

            var source = new TradeDataSource()
            {
                Data = new TradeData[] { data }
            };

            source.Variables[KrakenLedgerParser.KrakenLedgerVariableName] = new Dictionary <string, IList <Quantity> >()
            {
                { "TK6PI7-LU6O6-4TFNSU", new Quantity[] { new Quantity()
                                                          {
                                                              Coin = ECoin.EUR, Value = 142.4183M
                                                          } } },
                { "TLREIQ-ESBRY-SYVMIE", new Quantity[] { new Quantity()
                                                          {
                                                              Coin = ECoin.EUR, Value = 142.4183M
                                                          } } }
            };
            var trades = _exchange.GetTrades(source, data).ToArray();

            Assert.AreEqual(trades.Length, 2);

            // Check

            Assert.IsInstanceOfType(trades[0], typeof(SellTrade));
            Assert.AreEqual(trades[0].Date, new DateTime(2019, 01, 08, 23, 14, 0, DateTimeKind.Utc).AddTicks(1234));
            Assert.AreEqual(trades[0].Fees.Length, 1);
            Assert.AreEqual(trades[0].Fees[0].Coin, ECoin.EUR);
            Assert.AreEqual(trades[0].Fees[0].Value, 142.4183M);
            Assert.AreEqual(trades[0].From.Coin, ECoin.ETH);
            Assert.AreEqual(trades[0].From.Value, 495.336348M);
            Assert.AreEqual(trades[0].To.Coin, ECoin.EUR);
            Assert.AreEqual(trades[0].To.Value, 64735.5073M);
            Assert.AreEqual(trades[0].Price, 130.68999995938113550269886514M);

            Assert.IsInstanceOfType(trades[1], typeof(BuyTrade));
            Assert.AreEqual(trades[1].Date, new DateTime(2019, 01, 09, 21, 35, 0, DateTimeKind.Utc).AddTicks(1234));
            Assert.AreEqual(trades[1].Fees.Length, 1);
            Assert.AreEqual(trades[1].Fees[0].Coin, ECoin.EUR);
            Assert.AreEqual(trades[1].Fees[0].Value, 142.4183M);
            Assert.AreEqual(trades[1].From.Coin, ECoin.EUR);
            Assert.AreEqual(trades[1].From.Value, 6468.5M);
            Assert.AreEqual(trades[1].To.Coin, ECoin.ETH);
            Assert.AreEqual(trades[1].To.Value, 50M);
            Assert.AreEqual(trades[1].Price, 129.37M);
        }