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
)LONGPORT_ENABLE_OVERNIGHT
- Enable overnight quote,true
orfalse
(Default:false
)LONGPORT_PUSH_CANDLESTICK_MODE
-realtime
orconfirmed
(Default:realtime
)LONGPORT_PRINT_QUOTE_PACKAGES
- Print quote packages when connected,true
orfalse
(Default:true
)
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 fn enable_overnight(self) -> Self
pub fn enable_overnight(self) -> Self
Enable overnight quote
Default: false
sourcepub fn push_candlestick_mode(self, mode: PushCandlestickMode) -> Self
pub fn push_candlestick_mode(self, mode: PushCandlestickMode) -> Self
Specifies the push candlestick mode
Default: PushCandlestickMode::Realtime
sourcepub fn dont_print_quote_packages(self) -> Self
pub fn dont_print_quote_packages(self) -> Self
Disable printing the opened quote packages when connected to the server.
sourcepub fn create_metadata(&self) -> HashMap<String, String>
pub fn create_metadata(&self) -> HashMap<String, String>
Create metadata for auth/reconnect request
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
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more