中文

Object

TigerHttpClient HTTP Client

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

Initialization Methods:

  1. Construct a user configuration object ClientConfig containing personal account and key information
public class TigerOpenClientConfig {
  static {
    ClientConfig clientConfig = ClientConfig.DEFAULT_CONFIG;
    clientConfig.tigerId = "your tiger id";
    clientConfig.defaultAccount = "your account";
    clientConfig.privateKey = "you private key string";
    // clientConfig.secretKey = "xxxxxx";
    // clientConfig.setEnv(Env.SANDBOX);
  }
  public static ClientConfig getDefaultClientConfig() {
    return ClientConfig.DEFAULT_CONFIG;
  }
}
  1. Initialize HttpClient using com.tigerbrokers.stock.openapi.client.config.ClientConfig
private static TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(TigerOpenClientConfig.getDefaultClientConfig());

WebSocketClient WebSocket Client

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

Initialization Methods:

  1. Construct Authentication Class

Use com.tigerbrokers.stock.openapi.client.config.ClientConfig to construct the authentication class com.tigerbrokers.stock.openapi.client.socket.ApiAuthentication, and pass it when initializing WebSocketClient for identity verification.

Example:

ClientConfig clientConfig = TigerOpenClientConfig.getDefaultClientConfig(); 
ApiAuthentication authentication = ApiAuthentication.build(clientConfig.tigerId, clientConfig.privateKey);
  1. Construct WebSocket Client
private static ClientConfig clientConfig = TigerOpenClientConfig.getDefaultClientConfig();
private static WebSocketClient client =
    WebSocketClient.getInstance().clientConfig(clientConfig).apiComposeCallback(new DefaultApiComposeCallback());