Object Details

Less than 1 minute

TigerHttpClient

com.tigerbrokers.stock.openapi.client.https.client.TigerHttpClient

How to initialize an HTTP client:

  1. Construct a ClientConfig instance with personal login information, including tiger_id, account_id and your RSA private key.
public class TigerOpenClientConfig {
  static {
    ClientConfig clientConfig = ClientConfig.DEFAULT_CONFIG;
    clientConfig.tigerId = "your tiger id";
    clientConfig.defaultAccount = "your account"; 
    clientConfig.privateKey = "you private key string";

  }
  public static ClientConfig getDefaultClientConfig() {
    return ClientConfig.DEFAULT_CONFIG;
  }
}
  1. Use com.tigerbrokers.stock.openapi.client.config.ClientConfig to initialize HttpClient
private static TigerHttpClient client = new TigerHttpClient(TigerOpenClientConfig.getDefaultClientConfig());

WebSocketClient

com.tigerbrokers.stock.openapi.client.socket.WebSocketClient

Initial methods

  1. Initialize an instance of ApiAuthentication

Use com.tigerbrokers.stock.openapi.client.config.ClientConfig to construct com.tigerbrokers.stock.openapi.client.socket.ApiAuthentication for authentication. Pass in this instance when initializing WebSocketClient for authorizaiont.

Example:

ClientConfig clientConfig = TigerOpenClientConfig.getDefaultClientConfig(); 
ApiAuthentication authentication = ApiAuthentication.build(clientConfig.tigerId, clientConfig.privateKey);
  1. Initialize an instanct of Websocket client
private static ClientConfig clientConfig = TigerOpenClientConfig.getDefaultClientConfig();
private static WebSocketClient client =
    WebSocketClient.getInstance().url(clientConfig.socketServerUrl)
      .authentication(ApiAuthentication.build(clientConfig.tigerId, clientConfig.privateKey))
      .apiComposeCallback(new DefaultApiComposeCallback());
Last update: