Config

Configuration options for LongPort sdk

Parameters:

Name Type Description Default
app_key str

App Key

required
app_secret str

App Secret

required
access_token str

Access Token

required
http_url Optional[str]

HTTP API url

None
quote_ws_url Optional[str]

Websocket url for quote API

None
trade_ws_url Optional[str]

Websocket url for trade API

None
language Optional[Type[Language]]

Language identifier

None
enable_overnight bool

Enable overnight quote

False
push_candlestick_mode Type[PushCandlestickMode]

Push candlestick mode

Realtime
enable_print_quote_packages

Enable printing the opened quote packages when connected to the server

required

from_env() classmethod

Create a new Config from the given environment variables

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

Variables

  • LONGPORT_APP_KEY - App key
  • LONGPORT_APP_SECRET - App secret
  • LONGPORT_ACCESS_TOKEN - Access token
  • LONGPORT_HTTP_URL - HTTP endpoint url
  • LONGPORT_QUOTE_WS_URL - Quote websocket endpoint url
  • LONGPORT_TRADE_WS_URL - Trade websocket endpoint url
  • LONGPORT_ENABLE_OVERNIGHT - Enable overnight quote, true or false (Default: false)

refresh_access_token(expired_at=None)

Gets a new access_token

Parameters:

Name Type Description Default
expired_at Optional[datetime]

The expiration time of the access token, defaults to 90 days.

None

Returns:

Type Description
str

Access token