class O2GTimeframeCollection
Parents | |
java.lang.Iterable |
Brief
The class provides access to the list of time frames available for the historical prices request.
Details
The historical prices can be requested for different time frames (one minute, five minutes, one hour, etc).
The trading server defines the list of time frames that are available for the historical prices request.
The list is represented by the O2GTimeframeCollection
class.
The historical prices request is created by the O2GRequestFactory.createMarketDataSnapshotRequestInstrument method. The method has a time frame as one of the arguments. Before creating a request to get historical prices using a specific time frame, you must check whether it exists in the trading server list.
First, you must get an instance of the class by using the
O2GRequestFactory
.getTimeFrameCollection
method.
For example,
O2GTimeframeCollection timeFrames = requestFactory.getTimeFrameCollection();
Then, use the get method of the class
to check whether the time frame that you specified is available. For example,
O2GTimeframe timeFrame = timeFrames.get(mTimeFrame);
You can also obtain the complete list of available time frames by calling another implementation of the get method in a loop.
For example,
for (int i = 0; i < timeFrames.size(); i++) {
O2GTimeframe tF = timeFrames.get(i);
}
For complete details on requesting historical prices, refer to the How to get historical prices section.
Example
Check if a time frame is available [hide]
O2GRequestFactory requestFactory = mSession.getRequestFactory(); O2GTimeframeCollection timeFrames = requestFactory.getTimeFrameCollection(); O2GTimeframe timeFrame = timeFrames.get(mTimeFrame); if (timeFrame == null) { System.out.println("You specified an invalid time frame."); System.exit(1); }
The namespace is com.fxcore2
.
Public Methods | |
Gets a time frame by its index. |
|
Finds a time frame by its unique identifier. |
|
Returns an iterator over the list of time frames available for the historical prices request. |
|
Gets the number of time frames available for the historical prices request. |