Skip to content

Instantly share code, notes, and snippets.

@you-think-you-are-special
Last active April 3, 2019 10:17
Show Gist options
  • Save you-think-you-are-special/a4f95415caf1514fe5c1b613f13181a1 to your computer and use it in GitHub Desktop.
Save you-think-you-are-special/a4f95415caf1514fe5c1b613f13181a1 to your computer and use it in GitHub Desktop.
// exchange btc to eth
// trx - transaction from db
let hitbtc = new ccxt.hitbtc();
hitbtc.apiKey = '';
hitbtc.secret = '';
// check balance
const balance = await hitbtc.fetchBalance();
// balance >= trx.amountFrom check in btc
// exchange process
await hitbtc.paymentPostTransferToTrading({
'amount': trx.amountFrom,
'currency_code': 'btc',
});
await hitbtc.create_market_buy_order('BTC/ETH', trx.amountTo, {'trading_agreement': 'agree'});
await hitbtc.paymentPostTransferToMain({
'amount': trx.amountTo,
'currency_code': 'eth',
});
// sending process
await hitbtc.withdraw('eth', trx.amountTo, trx.payoutAddress)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment