Push Client and Connection
connect
connectSignature
pub async fn connect(client: &Arc<PushClient>) -> Result<(), String>
Description
Opens TCP/TLS, authenticates with an RSA signature, starts read/write tasks, waits for server CONNECTED, then starts heartbeats.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| client | &Arc<PushClient> | Required | None |
Return
PushClient:Result<(), String>.
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_connect(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = connect(push).await.map_err(|e| TigerError::Config(e))?;
Ok(())
}
Response example
disconnect
disconnectSignature
pub fn disconnect(&self)
Description
Best-effort sends DISCONNECT, marks the client disconnected, stops background tasks, and invokes on_disconnect.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| none | - | Required by Rust type | None |
Return
PushClient:(). No response fields on success..
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_disconnect(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = push.disconnect();
Ok(())
}
Response example
state
stateSignature
pub fn state(&self) -> ConnectionState
Description
Reads a connection-state snapshot: Disconnected, Connecting, or Connected.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| none | - | Required by Rust type | None |
Return
PushClient:ConnectionState.
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_state(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = push.state();
Ok(())
}
Response example
set_callbacks
set_callbacksSignature
pub fn set_callbacks(&self, cb: Callbacks)
Description
Atomically replaces the complete set of market, account, and connection callbacks; unset fields remain None.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| cb | Callbacks | Required by Rust type | None |
Return
()
Callbacks struct fields
| Callback field | Type signature | Description |
|---|---|---|
| on_quote | Option<fn(QuoteData)> | Stock quote changes |
| on_quote_bbo | Option<fn(QuoteData)> | Best bid/offer quote |
| on_option | Option<fn(QuoteData)> | Option quote changes |
| on_future | Option<fn(QuoteData)> | Futures quote changes |
| on_depth | Option<fn(QuoteDepthData)> | Depth of book data |
| on_tick | Option<fn(TradeTickData)> | Trade ticks |
| on_full_tick | Option<fn(TickData)> | Full tick data |
| on_kline | Option<fn(KlineData)> | Minute kline push |
| on_stock_top | Option<fn(StockTopData)> | Stock rankings push |
| on_option_top | Option<fn(OptionTopData)> | Option rankings push |
| on_asset | Option<fn(AssetData)> | Asset changes (full snapshot every 5s) |
| on_position | Option<fn(PositionData)> | Position changes (full snapshot every 5s) |
| on_order | Option<fn(OrderStatusData)> | Order status changes |
| on_transaction | Option<fn(OrderTransactionData)> | Order transaction details |
| on_connect | Option<fn()> | Connection established |
| on_disconnect | Option<fn()> | Disconnected |
| on_error | Option<fn(String)> | Error notification |
| on_kickout | Option<fn(String)> | Kicked out by server |
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_set_callbacks(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let cb = Callbacks {
on_quote: Some(|data| {
println!("Quote change: symbol={}, latest_price={}", data.symbol, data.latest_price);
}),
on_order: Some(|data| {
println!("Order change: id={}, status={}", data.id, data.status);
}),
on_asset: Some(|data| {
println!("Asset change: account={}, net_liquidation={}", data.account, data.net_liquidation);
}),
on_position: Some(|data| {
println!("Position change: symbol={}, quantity={}", data.symbol, data.position_qty);
}),
on_connect: Some(|| {
println!("Connected");
}),
on_disconnect: Some(|| {
println!("Disconnected");
}),
..Callbacks::default()
};
push.set_callbacks(cb);
Ok(())
}
Response example
send_heartbeat
send_heartbeatSignature
pub fn send_heartbeat(&self) -> bool
Description
Builds and queues a Protobuf heartbeat request; success only means the local write channel accepted the frame.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| none | - | Required by Rust type | None |
Return
PushClient:bool. Returnsbool: whether the protocol frame entered the local send channel, not server acceptance..
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_send_heartbeat(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = push.send_heartbeat();
Ok(())
}
Response example
handle_message
handle_messageSignature
pub fn handle_message(&self, data: &[u8])
Description
Decodes one varint32-length-prefixed Protobuf response and dispatches it by command and data type; intended mainly for tests or custom transports.
Parameters
| Parameter | Rust type | Requirement | SDK default |
|---|---|---|---|
| data | &[u8] | Required by Rust type | None |
Return
PushClient:(). No response fields on success..
Example
use std::sync::Arc;
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::error::TigerError;
use tigeropen::model::order::*;
use tigeropen::model::quote::*;
use tigeropen::model::quote_requests::*;
use tigeropen::model::trade_requests::*;
use tigeropen::push::*;
use tigeropen::quote::QuoteClient;
use tigeropen::trade::TradeClient;
async fn example_handle_message(config: ClientConfig, quote: &QuoteClient, trade: &TradeClient, push: &Arc<PushClient>) -> Result<(), TigerError> {
let result_0 = push.handle_message(&[]);
Ok(())
}
Response example
Updated about 17 hours ago
