pub struct PredictExecutionClient {
pub api: PredictApiClient,
pub signer: PredictOrderSigner,
pub config: PredictExecConfig,
pub market_cache: Arc<RwLock<HashMap<i64, MarketMeta>>>,
}Expand description
Execution client with market metadata cache and JWT management.
The market cache avoids redundant GET /markets/{id} calls — token IDs,
fee rates, and flags don’t change during a market’s lifetime.
Fields§
§api: PredictApiClient§signer: PredictOrderSigner§config: PredictExecConfig§market_cache: Arc<RwLock<HashMap<i64, MarketMeta>>>Market metadata cache — public for testing. Use market_meta() for normal access.
Implementations§
Source§impl PredictExecutionClient
impl PredictExecutionClient
pub async fn new(config: PredictExecConfig) -> Result<Self>
pub async fn from_env() -> Result<Self>
Sourcepub async fn refresh_jwt(&mut self) -> Result<()>
pub async fn refresh_jwt(&mut self) -> Result<()>
Re-authenticate and refresh the JWT token.
pub async fn authenticate_jwt( api: &PredictApiClient, signer: &PredictOrderSigner, ) -> Result<String>
Sourcepub async fn market_meta(&self, market_id: i64) -> Result<MarketMeta>
pub async fn market_meta(&self, market_id: i64) -> Result<MarketMeta>
Get cached market metadata, fetching from API if not cached.
Sourcepub async fn refresh_market_meta(&self, market_id: i64) -> Result<MarketMeta>
pub async fn refresh_market_meta(&self, market_id: i64) -> Result<MarketMeta>
Force-refresh market metadata from API.
Sourcepub async fn preload_markets(&self, market_ids: &[i64]) -> Result<()>
pub async fn preload_markets(&self, market_ids: &[i64]) -> Result<()>
Pre-warm the cache for multiple markets in parallel.
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Clear the market metadata cache.
Sourcepub async fn prepare_limit_order(
&self,
req: &PredictLimitOrderRequest,
) -> Result<PredictPreparedOrder>
pub async fn prepare_limit_order( &self, req: &PredictLimitOrderRequest, ) -> Result<PredictPreparedOrder>
Prepare a signed order using cached market metadata. First call for a market fetches from API; subsequent calls use cache.
Sourcepub fn prepare_limit_order_with_meta(
&self,
req: &PredictLimitOrderRequest,
meta: &MarketMeta,
) -> Result<PredictPreparedOrder>
pub fn prepare_limit_order_with_meta( &self, req: &PredictLimitOrderRequest, meta: &MarketMeta, ) -> Result<PredictPreparedOrder>
Prepare a signed order with pre-fetched market metadata (zero network calls).
Sourcepub async fn submit_prepared_order(
&self,
prepared: PredictPreparedOrder,
) -> Result<PredictSubmitResult>
pub async fn submit_prepared_order( &self, prepared: PredictPreparedOrder, ) -> Result<PredictSubmitResult>
Submit a prepared order.
live_execution=false: dry-run, no POST.live_execution=true: sends POST /orders.
Sourcepub async fn place_limit_order(
&self,
req: &PredictLimitOrderRequest,
) -> Result<PredictSubmitResult>
pub async fn place_limit_order( &self, req: &PredictLimitOrderRequest, ) -> Result<PredictSubmitResult>
Prepare + submit in one call (uses cached market metadata).
Sourcepub async fn remove_order_ids(&self, ids: &[String]) -> Result<RawApiResponse>
pub async fn remove_order_ids(&self, ids: &[String]) -> Result<RawApiResponse>
Remove orders from orderbook via POST /orders/remove.
Trait Implementations§
Source§impl Clone for PredictExecutionClient
impl Clone for PredictExecutionClient
Source§fn clone(&self) -> PredictExecutionClient
fn clone(&self) -> PredictExecutionClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PredictExecutionClient
impl !RefUnwindSafe for PredictExecutionClient
impl Send for PredictExecutionClient
impl Sync for PredictExecutionClient
impl Unpin for PredictExecutionClient
impl UnsafeUnpin for PredictExecutionClient
impl !UnwindSafe for PredictExecutionClient
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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