Exemplo n.º 1
0
static void print_top(helix_order_book_t ob)
{
	uint64_t timestamp = helix_order_book_timestamp(ob);
	uint64_t timestamp_in_sec = timestamp / 1000;
	uint64_t hours   = timestamp_in_sec / 60 / 60;
	uint64_t minutes = (timestamp_in_sec - (hours * 60 * 60)) / 60;
	uint64_t seconds = (timestamp_in_sec - (hours * 60 * 60) - (minutes * 60));
	uint64_t msecs   = timestamp - (timestamp_in_sec * 1000);

	if (helix_order_book_state(ob) == HELIX_TRADING_STATE_TRADING) {
		clear();
		move(0, 0);
		printw("%16s    %02lu:%02lu:%02lu.%03lu\n",
			helix_order_book_symbol(ob),
			hours, minutes, seconds, msecs
			);
		for (unsigned i = 0; i < 5; i++) {
			move(i+1, 0);
			printw("| %6lu  %.3f  %.3f  %-6lu |\n",
				helix_order_book_bid_size(ob, i),
				(double)helix_order_book_bid_price(ob, i)/10000.0,
				(double)helix_order_book_ask_price(ob, i)/10000.0,
				helix_order_book_ask_size(ob, i)
				);
		}
		refresh();
	}
}
Exemplo n.º 2
0
static void fmt_csv_ob(helix_session_t session, helix_order_book_t ob)
{
	if (helix_order_book_state(ob) == HELIX_TRADING_STATE_TRADING) {
		fprintf(output, "%s,%lu,%f,%lu,%f,%lu,,\n",
			helix_order_book_symbol(ob),
			helix_order_book_timestamp(ob),
			(double)helix_order_book_bid_price(ob, 0)/10000.0,
			helix_order_book_bid_size(ob, 0),
			(double)helix_order_book_ask_price(ob, 0)/10000.0,
			helix_order_book_ask_size(ob, 0)
			);
		fflush(output);
	}
}
Exemplo n.º 3
0
static void fmt_pretty_ob(helix_session_t session, helix_order_book_t ob)
{
	uint64_t timestamp = helix_order_book_timestamp(ob);
	uint64_t timestamp_in_sec = timestamp / 1000;
	uint64_t hours   = timestamp_in_sec / 60 / 60;
	uint64_t minutes = (timestamp_in_sec - (hours * 60 * 60)) / 60;
	uint64_t seconds = (timestamp_in_sec - (hours * 60 * 60) - (minutes * 60));

	if (helix_order_book_state(ob) == HELIX_TRADING_STATE_TRADING) {
		fprintf(output, "%s | %02lu:%02lu:%02lu %lu | %6lu  %.3f  %.3f  %-6lu |\n",
			helix_order_book_symbol(ob),
			hours, minutes, seconds, timestamp,
			helix_order_book_bid_size(ob, 0),
			(double)helix_order_book_bid_price(ob, 0)/10000.0,
			(double)helix_order_book_ask_price(ob, 0)/10000.0,
			helix_order_book_ask_size(ob, 0)
			);
	}
}