Creating and Monitoring a Sell Order

Creating buy and sell orders is, of course, a fairly vital part of the crypto industry and here we will look at how we can interact with this core functionality

Let's get straight into the script and see how to create a sell order, and then view it.

Account A from before will be creating a market sell order for 10 XHT.

As before, check comments for explanations

//using the index file, get access to the functions we will be using throughout
//Note: make sure the index file is pointed in the correct relative folder to this
//script
const Network = require('./index');

const network = new Network({
    apiUrl: 'https://api.hollaex.network',
    apiKey: '<YOUR_API_KEY>',
    apiSecret: '<YOUR_API__SECRET_KEY>',
    activation_code: '<YOUR_ACTIVATION_CODE>',
});

//main function for adding user and their address
(async () => {
	try {
		//initialise the network
		const init = await network.init();

		//account's IDs
		let idAccountA = 2275;

		//balance before the sell order
		console.log(await network.getUserBalance(idAccountA));

		//fee data (in percentages ie. 0.03 = 0.03% fee)
		let feeData = { fee_structure: { maker: 0.03, taker: 0.03 } };
		//create the order
		await network.createOrder(
			idAccountA, 	//account placing order
			'xht-usdt', 	//symbol of market
			'sell',		//type of order
			10,		//order amount
			'market',	//type of order (limit/ market)
			undefined,	//limit if limit order
			feeData		//feeobject from above
		);

		//balance after the order
		console.log(await network.getUserBalance(idAccountA));

		//see what trades this user has completed
		console.log(await network.getUserTrades(idAccountA));

		//see what active orders this user has
		console.log(await network.getUserOrders(idAccountA));
	} catch (err) {
		console.log(err);
	}
})();

Transfer Assets Script: The Output

As before edited lines for readability, shortened sections noted with '~~':

As the amount for my order was fairly small, and it using the shared liquidity system of HollaEx, my list of orders may look empty, but that's just due to how quickly the trade was made. Shows how nifty shared liquidity is, given we only had one user actually doing something on this exchange ain't it?

Last updated