pub struct IBClientPortal {
pub port: i32,
pub listen_ssl: bool,
pub account: String,
pub client: Client,
pub session_id: Option<String>,
}
Expand description
This is the base class of the library. It is used to communicate with the IB CP Gateway.
https://interactivebrokers.github.io/cpwebapi/endpoints
bin/run.sh root/conf.yaml
Fields§
§port: i32
§listen_ssl: bool
§account: String
§client: Client
§session_id: Option<String>
Implementations§
Source§impl IBClientPortal
impl IBClientPortal
Sourcepub async fn check_auth_status(&self) -> Result<AuthStatus, Error>
pub async fn check_auth_status(&self) -> Result<AuthStatus, Error>
Current Authentication status to the Brokerage system. Market Data and Trading is not possible if not authenticated, e.g. authenticated shows false
Sourcepub async fn tickle(&self) -> Result<Tickle, Error>
pub async fn tickle(&self) -> Result<Tickle, Error>
If the gateway has not received any requests for several minutes an open session will automatically timeout. The tickle endpoint pings the server to prevent the session from ending.
Sourcepub async fn get_positions(&self, page: i32) -> Result<Vec<Position>, Error>
pub async fn get_positions(&self, page: i32) -> Result<Vec<Position>, Error>
Returns a list of positions for the given account.
The endpoint supports paging, page’s default size is 30 positions.
/portfolio/accounts
or /portfolio/subaccounts
must be called prior to this endpoint.
Sourcepub async fn get_session_id(&mut self) -> Result<(), Error>
pub async fn get_session_id(&mut self) -> Result<(), Error>
Convenience method to call tickle and get the session id. It is necessary to auth the websocket connection.
Sourcepub async fn get_security_definition_by_contract_id(
&self,
contract_ids: Vec<i64>,
) -> Result<SecurityDefinitions, Error>
pub async fn get_security_definition_by_contract_id( &self, contract_ids: Vec<i64>, ) -> Result<SecurityDefinitions, Error>
Returns a list of security definitions for the given conids
Sourcepub async fn get_futures_by_symbol(
&self,
symbols: Vec<&str>,
) -> Result<FuturesContracts, Error>
pub async fn get_futures_by_symbol( &self, symbols: Vec<&str>, ) -> Result<FuturesContracts, Error>
Returns a list of non-expired future contracts for given symbol(s)
Sourcepub async fn get_stocks_by_symbol(
&self,
symbols: Vec<&str>,
) -> Result<StockContracts, Error>
pub async fn get_stocks_by_symbol( &self, symbols: Vec<&str>, ) -> Result<StockContracts, Error>
Returns an object contains all stock contracts for given symbol(s)
Sourcepub async fn search_for_security(
&self,
symbol_or_name: &str,
is_name: bool,
sec_type: AssetClass,
) -> Result<Value, Error>
pub async fn search_for_security( &self, symbol_or_name: &str, is_name: bool, sec_type: AssetClass, ) -> Result<Value, Error>
Search by underlying symbol or company name. Relays back what derivative contract(s) it has. This endpoint must be called before using /secdef/info. If company name is specified will only receive limited response: conid, companyName, companyHeader and symbol.
Sourcepub async fn get_options(
&self,
underlying_con_id: i64,
sectype: AssetClass,
month: Option<String>,
exchange: Option<String>,
strike: Option<Decimal>,
) -> Result<Value, Error>
pub async fn get_options( &self, underlying_con_id: i64, sectype: AssetClass, month: Option<String>, exchange: Option<String>, strike: Option<Decimal>, ) -> Result<Value, Error>
Provides Contract Details of Futures, Options, Warrants, Cash and CFDs based on conid. To get the strike price for Options/Warrants use “/iserver/secdef/strikes” endpoint. Must call /secdef/search for the underlying contract first.
Sourcepub async fn logout(&self) -> Result<Value, Error>
pub async fn logout(&self) -> Result<Value, Error>
Logs the user out of the gateway session. Any further activity requires re-authentication.
pub async fn get_account_ledger( &self, ) -> Result<HashMap<String, AccountLedger>, Error>
pub async fn place_order( &self, orders: Vec<OrderTicket>, ) -> Result<Value, Error>
Sourcepub async fn get_contract_detail(
&self,
conid: i64,
) -> Result<ContractDetail, Error>
pub async fn get_contract_detail( &self, conid: i64, ) -> Result<ContractDetail, Error>
Get contracts details. Many fields are optional and do not match the api documentation.
Sourcepub async fn get_market_data_history(
&self,
conid: i64,
exchange: Option<&str>,
period: &str,
bar: &str,
outside_rth: bool,
start_time: Option<NaiveDateTime>,
) -> Result<MarketDataHistory, Error>
pub async fn get_market_data_history( &self, conid: i64, exchange: Option<&str>, period: &str, bar: &str, outside_rth: bool, start_time: Option<NaiveDateTime>, ) -> Result<MarketDataHistory, Error>
Get market data history tradingDayDuration is not always present if period is less than 1 day exchange is optional and will be set to “” if not provided startTime is optional and not documented to retrieve 1min bars the startTime should be 2 minutes after the timestamp expected in the last bar of the response
Source§impl IBClientPortal
impl IBClientPortal
pub async fn connect_to_websocket( &self, subscriptions: Vec<Subscription>, on_message: fn(String), ) -> Result<(), Error>
Trait Implementations§
Source§impl Clone for IBClientPortal
impl Clone for IBClientPortal
Source§fn clone(&self) -> IBClientPortal
fn clone(&self) -> IBClientPortal
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more