Skip to content

Commit ce15a74

Browse files
authored
feat: add security endpoints (#105)
1 parent 0d51492 commit ce15a74

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

client/src/routes/markets.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use bpx_api_types::markets::{
2-
Asset, FundingRate, Kline, MarkPrice, Market, OrderBookDepth, OrderBookDepthLimit, Ticker,
2+
Asset, FundingRate, Kline, MarkPrice, Market, OrderBookDepth, OrderBookDepthLimit, Security,
3+
Ticker,
34
};
45

56
use crate::BpxClient;
@@ -13,6 +14,7 @@ const API_DEPTH: &str = "/api/v1/depth";
1314
const API_KLINES: &str = "/api/v1/klines";
1415
const API_FUNDING: &str = "/api/v1/fundingRates";
1516
const API_MARK_PRICES: &str = "/api/v1/markPrices";
17+
const API_SECURITIES: &str = "/api/v1/securities";
1618

1719
impl BpxClient {
1820
/// Fetches available assets and their associated tokens.
@@ -74,6 +76,13 @@ impl BpxClient {
7476
res.json().await.map_err(Into::into)
7577
}
7678

79+
/// Retrieves tradable securities.
80+
pub async fn get_securities(&self) -> Result<Vec<Security>> {
81+
let url = self.base_url.join(API_SECURITIES)?;
82+
let res = self.get(url).await?;
83+
res.json().await.map_err(Into::into)
84+
}
85+
7786
/// Fetches historical K-line (candlestick) data for a given symbol and interval.
7887
pub async fn get_k_lines(
7988
&self,

types/src/markets.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,24 @@ pub struct MarkPriceUpdate {
398398
pub engine_timestamp: i64,
399399
}
400400

401+
/// A tradable equity security.
402+
#[derive(Debug, Clone, Serialize, Deserialize)]
403+
#[serde(rename_all = "camelCase")]
404+
pub struct Security {
405+
/// Asset symbol.
406+
pub asset: String,
407+
/// Name.
408+
pub name: String,
409+
/// Minimum order quantity.
410+
pub min_quantity: Decimal,
411+
/// Maximum order quantity.
412+
pub max_quantity: Option<Decimal>,
413+
/// Minimum quantity increment.
414+
pub step_size: Decimal,
415+
/// CUSIP identifier for the security.
416+
pub cusip: Option<String>,
417+
}
418+
401419
impl TryFrom<u32> for OrderBookDepthLimit {
402420
type Error = &'static str;
403421

0 commit comments

Comments
 (0)