|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FXClient
An FXClient object facilitates communication with OANDA's servers. Once connected the FXClient object provides access to two root objects; User and RateTable.
Nested Class Summary | |
---|---|
static class |
FXClient.FXNotify
|
Field Summary | |
---|---|
static java.lang.String |
CONNECTED
Used when notifying Observers of a connection to the server |
static java.lang.String |
DISCONNECTED
Used when notifying Observers of a disconnection to the server |
static java.lang.String |
FATAL_ERROR
Used when notifying Observers of fatal errors |
static long |
INTERVAL_1_DAY
|
static long |
INTERVAL_1_HOUR
|
static long |
INTERVAL_1_MIN
|
static long |
INTERVAL_10_SEC
|
static long |
INTERVAL_15_MIN
|
static long |
INTERVAL_3_HOUR
|
static long |
INTERVAL_30_MIN
|
static long |
INTERVAL_30_SEC
|
static long |
INTERVAL_5_MIN
|
static long |
INTERVAL_5_SEC
The INTERVAL_ constants are useful when calling getHistory() |
static java.lang.String |
NEW_SESSION_TOKEN
Used when notifying Observers of new session token |
static java.lang.String |
SESSION_INVALID
Used when notifying Observers of invalid/expired session token |
static java.lang.String |
STREAM_CONNECTED
|
static java.lang.String |
STREAM_DISCONNECTED
|
static java.lang.String |
UPDATE
Used when notifying Observers of asynchronous updates |
static java.lang.String |
UPDATE_ORDERS
Used when notifying Observers of asynchronous updates |
static java.lang.String |
UPDATE_TRADES
Used when notifying Observers of asynchronous updates |
static java.lang.String |
UPDATE_TRANSACTIONS
Used when notifying Observers of asynchronous updates |
Method Summary | |
---|---|
void |
addObserver(java.util.Observer observer)
Compensates Observable methods |
boolean |
createEventManagerThread(boolean force)
This method is used to create a new instance of the event dispatch thread. |
boolean |
createKeepAliveThread(boolean force)
This method is used to create a new instance of the keepalive thread. |
boolean |
createRateThread(boolean force)
Deprecated. |
void |
deleteObserver(java.util.Observer observer)
|
long |
getFXServerTime()
Deprecated. |
java.util.Vector<? extends FXHistoryPoint> |
getHistory(FXPair pair,
long interval,
int numTicks)
Deprecated. Use getHistory from the RateTable instead |
RateTable |
getRateTable()
Returns the RateTable object |
long |
getServerTime()
Returns the current time held by the OANDA server expressed as a unix timestamp. |
java.lang.String |
getSessionKey()
Returns the current session key. |
User |
getUser()
Returns the User object currently connected to the OANDA server |
boolean |
getWithKeepAliveThread()
Deprecated. |
boolean |
getWithRateThread()
Deprecated. |
boolean |
isLoggedIn()
Returns true if a connection exists with the server, false otherwise. |
void |
login(java.lang.String username,
java.lang.String password)
Attempts to establish a connection to OANDA's servers. |
void |
login(java.lang.String username,
java.lang.String password,
java.lang.String reason)
Attempts to establish a connection to OANDA's servers. |
void |
login(java.lang.String username,
java.lang.String password,
java.lang.String sessionKey,
java.lang.String reason,
java.lang.String partnerName)
Attempts to establish a connection to OANDA's servers. |
void |
logout()
Disconnects from the server. |
void |
setProxy(boolean state)
Sets the proxy status for future connections to the server. |
void |
setRateTimeout(int timeout)
Set the socket timeout for the rate thread. |
void |
setTimeout(int timeout)
Sets the timeout for server response in seconds. |
void |
setWithKeepAliveThread(boolean wt)
When the keep alive thread flag is set to true, a new thread is created which will periodically send requests to the server in order to keep this connection alive. |
void |
setWithRateThread(boolean wt)
When the rate thread flag is set to true, a new thread is created which will keep receive rates from the server. |
void |
setWithTrailingStopMonitor(boolean wtsm)
Enabling this feature allows the API to actively track the current value of a trailing stop for your trades. |
Field Detail |
---|
static final java.lang.String CONNECTED
static final java.lang.String DISCONNECTED
static final java.lang.String FATAL_ERROR
static final java.lang.String UPDATE
static final java.lang.String UPDATE_ORDERS
static final java.lang.String UPDATE_TRADES
static final java.lang.String UPDATE_TRANSACTIONS
static final java.lang.String SESSION_INVALID
static final java.lang.String NEW_SESSION_TOKEN
static final java.lang.String STREAM_CONNECTED
static final java.lang.String STREAM_DISCONNECTED
static final long INTERVAL_5_SEC
getHistory()
static final long INTERVAL_10_SEC
static final long INTERVAL_30_SEC
static final long INTERVAL_1_MIN
static final long INTERVAL_5_MIN
static final long INTERVAL_15_MIN
static final long INTERVAL_30_MIN
static final long INTERVAL_1_HOUR
static final long INTERVAL_3_HOUR
static final long INTERVAL_1_DAY
Method Detail |
---|
java.util.Vector<? extends FXHistoryPoint> getHistory(FXPair pair, long interval, int numTicks) throws OAException
pair
- the desired FXPairinterval
- The time interval in milliseconds. For your convenience,
the following following constants have been provided for you:
numTicks
- the number of ticks to retrieve (maximum 500)
OAException
FXPair
,
FXHistoryPoint
,
RateTable
RateTable getRateTable() throws SessionDisconnectedException
SessionDisconnectedException
RateTable
long getServerTime()
long getFXServerTime() throws OAException
OAException
- may throw out when the return data is brokenUser getUser() throws SessionException
SessionException
User
boolean getWithRateThread()
boolean getWithKeepAliveThread()
boolean isLoggedIn()
void login(java.lang.String username, java.lang.String password) throws InvalidUserException, InvalidPasswordException, SessionException, MultiFactorAuthenticationException
This is equivalent to calling:
FXClient.login(username, password, null);
password
- the password for the user associated with this API
MultiFactorAuthenticationException
InvalidUserException
InvalidPasswordException
SessionException
void login(java.lang.String username, java.lang.String password, java.lang.String reason) throws InvalidUserException, InvalidPasswordException, SessionException, MultiFactorAuthenticationException
If a valid session key is provided, this will be used to resume a previous session which avoids the key negotiation phase and prevents increasing the session count on OANDA's server.
If the session key has expired, a new session will be negotiated with the server during the login request.
Providing a null
value for the key is the same as creating a
new session.
username
- the account usernamepassword
- the account passwordreason
- the reason for last disconnection.
InvalidUserException
InvalidPasswordException
SessionException
MultiFactorAuthenticationException
void login(java.lang.String username, java.lang.String password, java.lang.String sessionKey, java.lang.String reason, java.lang.String partnerName) throws InvalidUserException, InvalidPasswordException, SessionException, MultiFactorAuthenticationException
This is equivalent to calling:
FXClient.login(username, password, null);
username
- the account usernamepassword
- the password for the user associated with this APIreason
- the reason for last disconnection.sessionKey
- existing session key to be used if continueing a pre-existing session.partnerName
- the name of the partner for tracking
MultiFactorAuthenticationException
InvalidUserException
InvalidPasswordException
SessionException
boolean createKeepAliveThread(boolean force)
force
- attempt to force creation of the keepalive thread even if it's alive
@Deprecated boolean createRateThread(boolean force)
force
- attemp to force creation of the rate thread even if it's alive
boolean createEventManagerThread(boolean force)
force
- attemp to force creation of the event thread even if it's alive
java.lang.String getSessionKey()
null
return value indicates
that there is no active session on this instance of FXClient
.
The session key encodes both the current session identifier as well as last
activity time.
The generated session key will be valid on OANDA's sever as long as there has been recent activity through the API (such as getting transaction history, retrieving the server time, etc). If there has been no communication with OANDA's server, the session may have been timed out (which is approximately 10 minutes). In this case, a valid but expired session key will be generated.
void logout()
void setProxy(boolean state)
Proxy connections are made via port 443, whereas non-proxy connection are made through port 9700.
state
- the boolean state for proxy connection.void setTimeout(int timeout)
timeout
- timeout for server response in secondsvoid setWithRateThread(boolean wt)
When the rate thread flag is set to true, a new thread is created which will
keep receive rates from the server. If this flag is not set, rates cannot be
received. This also has the side effect not not being able to retrieve
the history on instruments (via RateTable
).
The rate thread also acts as a keep alive thread by periodically sending requests to the server in order to keep this connection alive. It is not necessary to run both the rate thread and the keep alive thread. On the other hand if both the rate thread and keep alive thread are enabled, the rate thread will delegate this task to the keep alive thread.
wt
- for active or inactivevoid setWithKeepAliveThread(boolean wt)
When the keep alive thread flag is set to true, a new thread is created which will periodically send requests to the server in order to keep this connection alive.
If this flag and the rate thread flag are set, only the keep alive thread will send keep alive requests to the server even though the rate thread has this capability.
wt
- set KeepAliveThread active or notvoid setWithTrailingStopMonitor(boolean wtsm)
This property must be set before login.
wtsm
- void addObserver(java.util.Observer observer)
observer
- observer instance to be passed to implementationObservable
void deleteObserver(java.util.Observer observer)
void setRateTimeout(int timeout)
timeout
- timeout for the rate thread in seconds
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |