pub struct Config { /* private fields */ }
Expand description
Configuration options for LongPort sdk
Implementations§
source§impl Config
impl Config
sourcepub fn new(
app_key: impl Into<String>,
app_secret: impl Into<String>,
access_token: impl Into<String>
) -> Self
pub fn new( app_key: impl Into<String>, app_secret: impl Into<String>, access_token: impl Into<String> ) -> Self
Create a new Config
sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
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 keyLONGPORT_APP_SECRET
- App secretLONGPORT_ACCESS_TOKEN
- Access tokenLONGPORT_HTTP_URL
- HTTP endpoint url (Default:https://openapi.longportapp.com
)LONGPORT_QUOTE_WS_URL
- Quote websocket endpoint url (Default:wss://openapi-quote.longportapp.com/v2
)LONGPORT_TRADE_WS_URL
- Trade websocket endpoint url (Default:wss://openapi-trade.longportapp.com/v2
)
sourcepub fn http_url(self, url: impl Into<String>) -> Self
pub fn http_url(self, url: impl Into<String>) -> Self
Specifies the url of the OpenAPI server.
Default: https://openapi.longportapp.com
NOTE: Usually you don’t need to change it.
sourcepub fn quote_ws_url(self, url: impl Into<String>) -> Self
pub fn quote_ws_url(self, url: impl Into<String>) -> Self
Specifies the url of the OpenAPI quote websocket server.
Default: wss://openapi-quote.longportapp.com
NOTE: Usually you don’t need to change it.
sourcepub fn trade_ws_url(self, url: impl Into<String>) -> Self
pub fn trade_ws_url(self, url: impl Into<String>) -> Self
Specifies the url of the OpenAPI trade websocket server.
Default: wss://openapi-trade.longportapp.com/v2
NOTE: Usually you don’t need to change it.
sourcepub async fn refresh_access_token(
&self,
expired_at: Option<OffsetDateTime>
) -> Result<String>
pub async fn refresh_access_token( &self, expired_at: Option<OffsetDateTime> ) -> Result<String>
Gets a new access_token
expired_at
- The expiration time of the access token, defaults to 90
days.
Reference: https://open.longportapp.com/en/docs/refresh-token-api