Class Config

    • Method Detail

      • fromApikey

        public static Config fromApikey​(String appKey,
                                        String appSecret,
                                        String accessToken)
                                 throws OpenApiException
        Create a new Config from API key credentials.

        Optional environment variables are read automatically: LONGBRIDGE_HTTP_URL, LONGBRIDGE_LANGUAGE, LONGBRIDGE_QUOTE_WS_URL, LONGBRIDGE_TRADE_WS_URL, LONGBRIDGE_ENABLE_OVERNIGHT, LONGBRIDGE_PUSH_CANDLESTICK_MODE, LONGBRIDGE_PRINT_QUOTE_PACKAGES, LONGBRIDGE_LOG_PATH. Use the chainable setter methods (e.g. httpUrl(java.lang.String)) to override any of these values.

        Parameters:
        appKey - App key
        appSecret - App secret
        accessToken - Access token
        Returns:
        Config object
        Throws:
        OpenApiException - If an error occurs
      • fromApikeyEnv

        public static Config fromApikeyEnv()
                                    throws OpenApiException
        Create a new Config from the given environment variables

        It first gets the environment variables from the .env file in the current directory.

        Variables

        • LONGBRIDGE_LANGUAGE - Language identifier, zh-CN, zh-HK or en (Default: en)
        • LONGBRIDGE_APP_KEY - App key
        • LONGBRIDGE_APP_SECRET - App secret
        • LONGBRIDGE_ACCESS_TOKEN - Access token
        • LONGBRIDGE_HTTP_URL - HTTP endpoint url (Default: https://openapi.longbridge.com)
        • LONGBRIDGE_QUOTE_WS_URL - Quote websocket endpoint url (Default: wss://openapi-quote.longbridge.com/v2)
        • LONGBRIDGE_TRADE_WS_URL - Trade websocket endpoint url (Default: wss://openapi-trade.longbridge.com/v2)
        • LONGBRIDGE_ENABLE_OVERNIGHT - Enable overnight quote, true or false (Default: false)
        • LONGBRIDGE_PUSH_CANDLESTICK_MODE - realtime or confirmed (Default: realtime)
        • LONGBRIDGE_PRINT_QUOTE_PACKAGES - Print quote packages when connected, true or false (Default: true)
        • LONGBRIDGE_LOG_PATH - Set the path of the log files (Default: no logs)
        Returns:
        Config object
        Throws:
        OpenApiException - If an error occurs
      • httpUrl

        public Config httpUrl​(String httpUrl)
        Set the HTTP endpoint URL.

        NOTE: Usually you don't need to change it.

        Parameters:
        httpUrl - OpenAPI endpoint (Default: https://openapi.longbridge.com)
        Returns:
        this object
      • quoteWebsocketUrl

        public Config quoteWebsocketUrl​(String quoteWsUrl)
        Set the quote websocket endpoint URL.

        NOTE: Usually you don't need to change it.

        Parameters:
        quoteWsUrl - OpenAPI quote websocket endpoint
        Returns:
        this object
      • tradeWebsocketUrl

        public Config tradeWebsocketUrl​(String tradeWsUrl)
        Set the trade websocket endpoint URL.

        NOTE: Usually you don't need to change it.

        Parameters:
        tradeWsUrl - OpenAPI trade websocket endpoint
        Returns:
        this object
      • language

        public Config language​(Language language)
        Set the language identifier.
        Parameters:
        language - Language identifier (Default: Language.EN)
        Returns:
        this object
      • enableOvernight

        public Config enableOvernight()
        Enable overnight quote.
        Returns:
        this object
      • disablePrintQuotePackages

        public Config disablePrintQuotePackages()
        Disable printing quote packages when connected to the server.
        Returns:
        this object
      • logPath

        public Config logPath​(String path)
        Set the path of the log files.
        Parameters:
        path - The path of the log files (Default: no logs)
        Returns:
        this object