对象

小于 1 分钟

TigerHttpClient HTTP客户端

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

初始化方法:

  1. 构造含有个人账户及密钥的用户配置对象ClientConfig
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. 使用com.tigerbrokers.stock.openapi.client.config.ClientConfig初始化HttpClient
private static TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(TigerOpenClientConfig.getDefaultClientConfig());

WebSocketClient Websocket客户端

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

初始化方法:

  1. 构造认证类

使用com.tigerbrokers.stock.openapi.client.config.ClientConfig构造认证类com.tigerbrokers.stock.openapi.client.socket.ApiAuthentication,并在初始化WebSocketClient时传入,用于身份验证

示例如下:

ClientConfig clientConfig = TigerOpenClientConfig.getDefaultClientConfig(); 
ApiAuthentication authentication = ApiAuthentication.build(clientConfig.tigerId, clientConfig.privateKey);
  1. 构造Websocket客户端
private static ClientConfig clientConfig = TigerOpenClientConfig.getDefaultClientConfig();
private static WebSocketClient client =
    WebSocketClient.getInstance().clientConfig(clientConfig).apiComposeCallback(new DefaultApiComposeCallback());
上次编辑于: