LongPort OpenAPI C++ SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions | List of all members
longport::Config Class Reference

#include <config.hpp>

Public Member Functions

 Config ()
 
 Config (lb_config_t *config)
 
 Config (const Config &)=delete
 
 Config (Config &&other)
 
 Config (const std::string &app_key, const std::string &app_secret, const std::string &access_token, const std::optional< std::string > &http_url=std::nullopt, const std::optional< std::string > &quote_ws_url=std::nullopt, const std::optional< std::string > &trade_ws_url=std::nullopt, const std::optional< Language > &language=std::nullopt, bool enable_overnight=false, const std::optional< PushCandlestickMode > &push_candlestick_mode=std::nullopt, bool enable_print_quote_packages=true, const std::optional< std::string > &log_path=std::nullopt)
 
 ~Config ()
 
 operator const lb_config_t * () const
 
void refresh_access_token (int64_t expired_at, AsyncCallback< void *, std::string > callback)
 Gets a new access_token More...
 

Static Public Member Functions

static Status from_env (Config &config)
 

Constructor & Destructor Documentation

◆ Config() [1/5]

longport::Config::Config ( )

◆ Config() [2/5]

longport::Config::Config ( lb_config_t config)

◆ Config() [3/5]

longport::Config::Config ( const Config )
delete

◆ Config() [4/5]

longport::Config::Config ( Config &&  other)

◆ Config() [5/5]

longport::Config::Config ( const std::string &  app_key,
const std::string &  app_secret,
const std::string &  access_token,
const std::optional< std::string > &  http_url = std::nullopt,
const std::optional< std::string > &  quote_ws_url = std::nullopt,
const std::optional< std::string > &  trade_ws_url = std::nullopt,
const std::optional< Language > &  language = std::nullopt,
bool  enable_overnight = false,
const std::optional< PushCandlestickMode > &  push_candlestick_mode = std::nullopt,
bool  enable_print_quote_packages = true,
const std::optional< std::string > &  log_path = std::nullopt 
)

Config

Parameters
app_keyApp key
app_secretApp secret
access_tokenAccess token
http_urlHTTP endpoint url (Default: https://openapi.portbridgeapp.com)
quote_ws_urlQuote websocket endpoint url (Default: wss://openapi-quote.longportapp.com/v2)
trade_ws_urlTrade websocket endpoint url (Default: wss://openapi-trade.longportapp.com/v2)
languageLanguage identifer (Default: Language::EN)
push_candlestick_modePush candlestick mode (Default: PushCandlestickMode::Realtime)
enable_print_quote_packagesPrint quote packages when connected (Default: true)

◆ ~Config()

longport::Config::~Config ( )

Member Function Documentation

◆ from_env()

static Status longport::Config::from_env ( Config config)
static

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 (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 or false (Default: false)
  • LONGPORT_PUSH_CANDLESTICK_MODE - realtime or confirmed (Default: realtime)
  • LONGPORT_PRINT_QUOTE_PACKAGES - Print quote packages when connected, true or false (Default: true)
  • LONGPORT_LOG_PATH - Set the path of the log files (Default: no logs)

◆ operator const lb_config_t *()

longport::Config::operator const lb_config_t * ( ) const

◆ refresh_access_token()

void longport::Config::refresh_access_token ( int64_t  expired_at,
AsyncCallback< void *, std::string >  callback 
)

Gets a new access_token


The documentation for this class was generated from the following file: