UNPKG

crypto-client

Version:

An unified client for all cryptocurrency exchanges.

216 lines (215 loc) 10.3 kB
#!/usr/bin/env node "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.testMXC = exports.testKraken = exports.testKraken1 = exports.testWhaleExEos = exports.testWhaleExMYKEY = exports.testWhaleEx = exports.testOKEx_Spot = exports.testNewdexMYKEY = exports.testNewdex = exports.testHuobi = exports.testCoinbase = exports.testBitstamp = exports.testBitfinex = exports.testBinance = void 0; /* eslint-disable no-console */ const yargs_1 = __importDefault(require("yargs")); const config_1 = require("./config"); const index_1 = require("./index"); const { argv } = yargs_1.default.options({ eosAccount: { type: 'string', }, eosPrivateKey: { type: 'string', }, BINANCE_API_KEY: { type: 'string', }, BINANCE_API_SECRET: { type: 'string', }, BITFINEX_API_KEY: { type: 'string', }, BITFINEX_API_SECRET: { type: 'string', }, BITSTAMP_API_KEY: { type: 'string', }, BITSTAMP_API_SECRET: { type: 'string', }, BITSTAMP_USER_ID: { type: 'number', }, CB_ACCESS_KEY: { type: 'string', }, CB_ACCESS_SECRET: { type: 'string', }, CB_ACCESS_PASSPHRASE: { type: 'string', }, DFUSE_API_KEY: { type: 'string', }, HUOBI_ACCESS_KEY: { type: 'string', }, HUOBI_SECRET_KEY: { type: 'string', }, HUOBI_ACCOUNT_ID: { type: 'number', }, KRAKEN_API_KEY: { type: 'string', }, KRAKEN_PRIVATE_KEY: { type: 'string', }, MXCAccessKey: { type: 'string', }, MXCSecretKey: { type: 'string', }, OKEX_SPOT_API_KEY: { type: 'string', }, OKEX_SPOT_API_SECRET: { type: 'string', }, OKEX_SPOT_API_PASSPHRASE: { type: 'string', }, OKEX_SPOT_FUND_PASSWORD: { type: 'string', }, WHALEEX_API_KEY: { type: 'string', }, }); async function testBinance() { console.info(await index_1.queryBalance('Binance', 'EOS')); const orderId = await index_1.placeOrder({ exchange: 'Binance', pair: 'EOS_USDT', type: 'Spot' }, 10.9, 1.1, true); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'Binance', pair: 'EOS_USDT', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'Binance', pair: 'EOS_USDT', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'Binance', pair: 'EOS_USDT', type: 'Spot' }, orderId)); } exports.testBinance = testBinance; async function testBitfinex() { console.info(await index_1.queryBalance('Bitfinex', 'ETH')); const orderId = await index_1.placeOrder({ exchange: 'Bitfinex', pair: 'ETH_USD', type: 'Spot' }, 241.11111, 0.04, true, '123456'); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'Bitfinex', pair: 'ETH_USD', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'Bitfinex', pair: 'ETH_USD', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'Bitfinex', pair: 'ETH_USD', type: 'Spot' }, orderId)); } exports.testBitfinex = testBitfinex; async function testBitstamp() { console.info(await index_1.queryBalance('Bitstamp', 'ETH')); const orderId = await index_1.placeOrder({ exchange: 'Bitstamp', pair: 'ETH_USD', type: 'Spot' }, 400.9, 0.1, true); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'Bitstamp', pair: 'ETH_USD', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'Bitstamp', pair: 'ETH_USD', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'Bitstamp', pair: 'ETH_USD', type: 'Spot' }, orderId)); } exports.testBitstamp = testBitstamp; async function testCoinbase() { console.info(await index_1.queryBalance('CoinbasePro', 'BCH')); const orderId = await index_1.placeOrder({ exchange: 'CoinbasePro', pair: 'BCH_USD', type: 'Spot' }, 3999.48, 0.1, true); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'CoinbasePro', pair: 'BCH_USD', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'CoinbasePro', pair: 'BCH_USD', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'CoinbasePro', pair: 'BCH_USD', type: 'Spot' }, orderId)); } exports.testCoinbase = testCoinbase; async function testHuobi() { console.info(await index_1.queryBalance('Huobi', 'EOS')); const orderId = await index_1.placeOrder({ exchange: 'Huobi', pair: 'EOS_USDT', type: 'Spot' }, 10.9, 0.1, true); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'Huobi', pair: 'EOS_USDT', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'Huobi', pair: 'EOS_USDT', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'Huobi', pair: 'EOS_USDT', type: 'Spot' }, orderId)); } exports.testHuobi = testHuobi; async function testNewdex() { const placeOrderId = await index_1.placeOrder({ exchange: 'Newdex', pair: 'EIDOS_EOS', type: 'Spot' }, 0.00121, 9.2644, false); console.info(placeOrderId); const orderInfo = await index_1.queryOrder({ exchange: 'Newdex', pair: 'EIDOS_EOS', type: 'Spot' }, placeOrderId); console.info(orderInfo); const cancelOrderId = await index_1.cancelOrder({ exchange: 'Newdex', pair: 'EIDOS_EOS', type: 'Spot' }, placeOrderId); console.info(cancelOrderId); } exports.testNewdex = testNewdex; async function testNewdexMYKEY() { const placeOrderId = await index_1.placeOrder({ exchange: 'Newdex', pair: 'MYKEY_EOS', type: 'Spot' }, 0.34567, 0.5, true); console.info(placeOrderId); const orderInfo = await index_1.queryOrder({ exchange: 'Newdex', pair: 'MYKEY_EOS', type: 'Spot' }, placeOrderId); console.info(orderInfo); const cancelOrderId = await index_1.cancelOrder({ exchange: 'Newdex', pair: 'MYKEY_EOS', type: 'Spot' }, placeOrderId); console.info(cancelOrderId); } exports.testNewdexMYKEY = testNewdexMYKEY; async function testOKEx_Spot() { console.info(await index_1.queryBalance('OKEx', 'ETH')); const orderId = await index_1.placeOrder({ exchange: 'OKEx', pair: 'ETH_USDT', type: 'Spot' }, 299.99, 0.001001, true); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'OKEx', pair: 'ETH_USDT', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'OKEx', pair: 'ETH_USDT', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'OKEx', pair: 'ETH_USDT', type: 'Spot' }, orderId)); } exports.testOKEx_Spot = testOKEx_Spot; async function testWhaleEx() { const orderId = await index_1.placeOrder({ exchange: 'WhaleEx', pair: 'EIDOS_EOS', type: 'Spot' }, 0.00121, 9.2644, false); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'WhaleEx', pair: 'EIDOS_EOS', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'WhaleEx', pair: 'EIDOS_EOS', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'WhaleEx', pair: 'EIDOS_EOS', type: 'Spot' }, orderId)); } exports.testWhaleEx = testWhaleEx; async function testWhaleExMYKEY() { const orderId = await index_1.placeOrder({ exchange: 'WhaleEx', pair: 'MYKEY_EOS', type: 'Spot' }, 0.345678, 0.5, true); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'WhaleEx', pair: 'MYKEY_EOS', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'WhaleEx', pair: 'MYKEY_EOS', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'WhaleEx', pair: 'MYKEY_EOS', type: 'Spot' }, orderId)); } exports.testWhaleExMYKEY = testWhaleExMYKEY; async function testWhaleExEos() { const action = index_1.createOrder({ exchange: 'WhaleEx', pair: 'EIDOS_EOS', type: 'Spot' }, 0.00121, 9.2644, false); console.info(action); // const txid = await sendTransaction([action], getRandomApi(USER_CONFIG.eosPrivateKey!)); // console.info(txid); } exports.testWhaleExEos = testWhaleExEos; async function testKraken1() { console.info(await index_1.queryBalance('Kraken', 'USD')); const orderId = await index_1.placeOrder({ exchange: 'Kraken', pair: 'EOS_USD', type: 'Spot' }, 1.6666, 3.11111111, false); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'Kraken', pair: 'EOS_USD', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'Kraken', pair: 'EOS_USD', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'Kraken', pair: 'EOS_USD', type: 'Spot' }, orderId)); } exports.testKraken1 = testKraken1; async function testKraken() { console.info(await index_1.queryBalance('Kraken', 'USD')); const orderId = await index_1.placeOrder({ exchange: 'Kraken', pair: 'BTC_USD', type: 'Spot' }, 1.6, 3.11111111, false); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'Kraken', pair: 'BTC_USD', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'Kraken', pair: 'BTC_USD', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'Kraken', pair: 'BTC_USD', type: 'Spot' }, orderId)); } exports.testKraken = testKraken; async function testMXC() { console.info(await index_1.queryBalance('MXC', 'EOS')); const orderId = await index_1.placeOrder({ exchange: 'MXC', pair: 'EOS_USDT', type: 'Spot' }, 9.4873, 1.111, true); console.info(orderId); console.info(await index_1.queryOrder({ exchange: 'MXC', pair: 'EOS_USDT', type: 'Spot' }, orderId)); console.info(await index_1.cancelOrder({ exchange: 'MXC', pair: 'EOS_USDT', type: 'Spot' }, orderId)); console.info(await index_1.queryOrder({ exchange: 'MXC', pair: 'EOS_USDT', type: 'Spot' }, orderId)); } exports.testMXC = testMXC; (async () => { await index_1.init(argv); console.info(config_1.USER_CONFIG); await testKraken(); })();