INNER CODE UNIT · Java

isOrderFilled

qtds35k/HighFrequencyTradingBot · src/trading/HttpHelper.java:338

	public boolean isOrderFilled(String orderId) throws IOException, InterruptedException {
		Connection.Response resp = Jsoup.connect("https://invest.firstrade.com/cgi-bin/orderstatus?showopenorder=1&showexeorder=1&showrejectorder=1&showtype=ALL")
				.userAgent(agent)
				.referrer(referer)
				.cookies(session)
				.method(Method.GET)
				.execute();
		session.putAll(resp.cookies());
		// randomSleep(1);
		Document doc = resp.parse();
		String orderStatus = doc.select("#order_status > tbody > tr#" + orderId + " > td.last > div").get(0).text();
		println("order " + orderId + " is " + orderStatus);
		
		if (orderStatus.contains("Bought") || orderStatus.contains("Sold")) {
			this.tempFilledPrice = Math.round(Double.parseDouble(orderStatus.substring(orderStatus.indexOf("@") + 2)) * 100.0) / 100.0;
			return true;
		}
		else {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…