1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 |
|
5 | const index_1 = require("./index");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | const key = process.argv[2] || 'your-api-key';
|
12 | const secret = process.argv[3] || 'your-api-secret';
|
13 | const client = new index_1.default(key, secret);
|
14 | async function tests() {
|
15 | try {
|
16 |
|
17 | const tick = await client.getTick("BTC", "AUD");
|
18 | console.log(`Tick: ${JSON.stringify(tick)}`);
|
19 |
|
20 | const orderBook = await client.getOrderBook("BTC", "AUD");
|
21 | console.log('Order Book has ' + orderBook.asks.length + ' asks with best ask having price ' +
|
22 | orderBook.asks[0][0] + ' and amount ' + orderBook.asks[0][1]);
|
23 | console.log(`OrderBook: ${JSON.stringify(orderBook)}`);
|
24 |
|
25 | const trades = await client.getTrades("BTC", "AUD", 728992317);
|
26 | console.log(`Trades: ${JSON.stringify(trades)}`);
|
27 |
|
28 | const limitOrder = await client.createOrder("ETH", "AUD", 50 * index_1.default.numberConverter, 0.001 * index_1.default.numberConverter, 'Bid', 'Limit', "10001");
|
29 | console.log(`Limit order: ${JSON.stringify(limitOrder)}`);
|
30 |
|
31 | const marketOrder = await client.createOrder("BTC", "AUD", null, 0.001 * index_1.default.numberConverter, 'Ask', 'Market', null);
|
32 | console.log(`Market order: ${JSON.stringify(marketOrder)}`);
|
33 |
|
34 | const stopLossOrder = await client.createOrder("ETH", "AUD", 50 * index_1.default.numberConverter, 0.001 * index_1.default.numberConverter, 'Bid', 'Stop Limit', "10002", 40 * index_1.default.numberConverter);
|
35 | console.log(`Stop loss order: ${JSON.stringify(stopLossOrder)}`);
|
36 |
|
37 | const cancelledOrders = await client.cancelOrders([1132477709, 1133590603]);
|
38 | console.log(`Cancelled order ${JSON.stringify(cancelledOrders)}`);
|
39 | const accountBalances = await client.getAccountBalances();
|
40 | console.log(`Account balances: ${JSON.stringify(accountBalances)}`);
|
41 |
|
42 | const tradingFee = await client.getTradingFee("BTC", "AUD");
|
43 | console.log(`Trading fee: ${JSON.stringify(tradingFee)}`);
|
44 |
|
45 | const orderDetails = await client.getOrderDetail([206855175, 23988196]);
|
46 | console.log(`Order details: ${JSON.stringify(orderDetails)}`);
|
47 |
|
48 | const tradeHistory = await client.getTradeHistory("BTC", "AUD", undefined, null);
|
49 | console.log(`Trade history ${JSON.stringify(tradeHistory)}`);
|
50 |
|
51 | const orderHistory = await client.getOrderHistory("BTC", "AUD", 50, null);
|
52 | console.log(`Order history: ${JSON.stringify(orderHistory)}`);
|
53 |
|
54 | const openOrders = await client.getOpenOrders('BTC', 'AUD', 10, null);
|
55 | console.log(`Open orders: ${JSON.stringify(openOrders)}`);
|
56 |
|
57 | const cryptoWithdrawal = await client.withdrawCrypto(0.05 * index_1.default.numberConverter, "0x775053A6125cB51e618Eb132f00E93d6033934AD", "ETH");
|
58 | console.log(`Crypto withdrawal: ${JSON.stringify(cryptoWithdrawal)}`);
|
59 |
|
60 | const defaultWithdrawHistory = await client.withdrawHistory(null, null, null);
|
61 | console.log(`Withdrawal history: ${JSON.stringify(defaultWithdrawHistory)}`);
|
62 |
|
63 | const withdrawHistory = await client.withdrawHistory(10, 0, true);
|
64 | console.log(`Withdrawal history: ${JSON.stringify(withdrawHistory)}`);
|
65 | }
|
66 | catch (err) {
|
67 | console.log(`Something when wrong in the examples. Error: ${err.message}`);
|
68 | }
|
69 | }
|
70 | tests();
|
71 |
|
\ | No newline at end of file |