Lesson 3. Get Market Data

In the previous lesson we got a list of trading accounts for our trader. I think it will be great to build a market data chart like trendbars for our brokers. Let's start!

  1. For trendbars data requesting our Open API has corresponding service: /connect/tradingaccounts/{id}/symbols/{symbolName}/trendbars/[h1|m1]

  2. We modified our Accounts API wrapper adding a new method for trendbars data requesting.

Accounts API Wrapper

  1. Let's try to display these thendbars as a chart. We should add a visualization library to our project. We've choosen JFreeChart but you can use another one. We have to add this library to our pom.xml file.

Adding JFreeChart to pom.xml

  1. Then we make a class TrendBarsChart. It is a wrapper for CandlestickChart which creates a chart, converts parameters from JsonTrenbar array to JFreeChart format, detects minimum and maximum value range for Y-axis, etc.

Wrapper for CandlestickChart

  1. And we can run our application. This example request trendbars for last 5 hours and displays them.

Trendbars Chart

Sources of this lesson can be found at GitHub