-
Notifications
You must be signed in to change notification settings - Fork 1
/
ccxt-test.js
52 lines (52 loc) · 2.96 KB
/
ccxt-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//cjs
require('dotenv').config();
var ccxt = require ('ccxt-xpr')
console.log (ccxt.exchanges) // print all available exchanges
;(async () => {
const exchange = new ccxt.protondex ({
'secret': process.env.PROTONDEX_API_SECRET,
'verbose': true,
'timeout': 60000,
})
try {
// API doc: https://api-docs.protondex.com/reference/what-is-proton-dex
// const response = await exchange.loadMarkets ()
// const response = await exchange.fetchStatusSync ()
// 1. Fetch markets
// const response = await exchange.fetchMarkets ()
// 2. Fetch ticker
// const response = await exchange.fetchTickers ()
// const response = await exchange.fetchTicker ('XPR_XMD')
// 3. Fetch order book
// const response = await exchange.fetchOrderBook ('XPR_XMD', 100, {'step': 10000})
// 4. Fetch recent trades
// const response = await exchange.fetchTrades ('XPR_XMD', 1, 100, {'offset': 0})
// 5. Fetch OHLCV
// const response = await exchange.fetchOHLCV ("XPR_XMD", 60, 1, 100, {'from_time': '2023-04-12T17:20:13Z', 'to_time': '2023-05-12T17:20:13Z'})
// 6. Fetch account balances
// const response = await exchange.fetchBalance ({'account': 'otctest'})
// 7. Fetch order
// const response = await exchange.fetchOrder ('1603774', {'ordinal_order_id': ''})
// 8. Fetch open orders
// const response = await exchange.fetchOpenOrders ('XPR_XMD', 1, 100, {'account': 'metaltest1', 'offset': 0, 'ordinal_order_ids': ''})
// 9. Fetch orders history
// const response = await exchange.fetchOrders ('XPR_XMD', 1, 100, {'account': 'testme1', 'offset': 0, 'ordinal_order_ids': '', 'trx_id': '', 'status': ''})
// const response = await exchange.fetchOrders ('XPR_XMD', 1, 100, {'account': 'testme1', 'offset': '0', 'ordinal_order_ids': '293d13c47603e5c81c270a2d8e197823584cec071d139631f6e1990e62ae8ed8', 'trx_id': '', 'status': ''})
// 10. Fetch trades history
// const response = await exchange.fetchMyTrades ('XPR_XMD', 1, 10, {'account': 'pbonblockc', 'offset': 0})
// 11. Create order
// const response = await exchange.createOrder ('XPR_XMD', 1, 1, 1.100000, 0.0009, {'account': 'pbonblockc', 'filltype': 0, 'triggerprice': 0})
// 12. Cancel order
//const response = await exchange.cancelOrder (5380376, 'METAL_XMD', {'account': 'trading.paul'});
// 13. Cancel all orders for specific symbol
const response = await exchange.cancelAllOrders ('XBTC_XMD', {'account': 'trading.paul'});
console.log (response);
console.log ('Succeeded.')
} catch (e) {
console.log ('--------------------------------------------------------')
console.log (e.constructor.name, e.message)
console.log ('--------------------------------------------------------')
console.log (exchange.last_http_response)
console.log ('Failed.')
}
}) ()