architect_api/marketdata/
options_marketdata.rs

1use super::Ticker;
2use crate::symbology::{PutOrCall, TradableProduct};
3use chrono::NaiveDate;
4use derive::grpc;
5use rust_decimal::Decimal;
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9#[grpc(package = "json.architect")]
10#[grpc(
11    service = "Marketdata",
12    name = "options_expirations",
13    response = "OptionsExpirations"
14)]
15#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, JsonSchema)]
16pub struct OptionsExpirationsRequest {
17    pub underlying: String,
18    pub wrap: Option<String>,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, JsonSchema)]
22pub struct OptionsExpirations {
23    pub underlying: String,
24    pub wrap: String,
25    pub expirations: Vec<NaiveDate>,
26}
27
28#[grpc(package = "json.architect")]
29#[grpc(service = "Marketdata", name = "options_wraps", response = "OptionsWraps")]
30#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, JsonSchema)]
31pub struct OptionsWrapsRequest {
32    pub underlying: String,
33}
34
35/// used for disambiguation of underlying symbols that have multiple series
36/// e.g. TSLA vs 2TSLA
37#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, JsonSchema)]
38pub struct OptionsWraps {
39    pub underlying: String,
40    pub wraps: Vec<String>,
41}
42
43#[grpc(package = "json.architect")]
44#[grpc(service = "Marketdata", name = "options_contract", response = "OptionsContract")]
45#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
46pub struct OptionsContractRequest {
47    pub tradable_product: TradableProduct,
48}
49
50#[grpc(package = "json.architect")]
51#[grpc(service = "Marketdata", name = "options_chain", response = "OptionsChain")]
52#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
53pub struct OptionsChainRequest {
54    pub underlying: String,
55    pub wrap: Option<String>,
56    pub expiration: NaiveDate,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
60pub struct OptionsChain {
61    pub calls: Vec<OptionsContract>,
62    pub puts: Vec<OptionsContract>,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
66pub struct OptionsContract {
67    pub ticker: Ticker,
68    pub underlying: String,
69    pub strike: Decimal,
70    pub expiration: NaiveDate,
71    pub put_or_call: PutOrCall,
72    pub in_the_money: Option<bool>,
73}
74
75#[grpc(package = "json.architect")]
76#[grpc(
77    service = "Marketdata",
78    name = "options_contract_greeks",
79    response = "OptionsGreeks"
80)]
81#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
82pub struct OptionsContractGreeksRequest {
83    pub tradable_product: TradableProduct,
84}
85
86#[grpc(package = "json.architect")]
87#[grpc(
88    service = "Marketdata",
89    name = "options_chain_greeks",
90    response = "OptionsChainGreeks"
91)]
92#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
93pub struct OptionsChainGreeksRequest {
94    pub underlying: String,
95    pub wrap: Option<String>,
96    pub expiration: NaiveDate,
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
100pub struct OptionsChainGreeks {
101    pub calls: Vec<OptionsGreeks>,
102    pub puts: Vec<OptionsGreeks>,
103}
104
105#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
106pub struct OptionsGreeks {
107    pub symbol: String,
108    pub underlying: String,
109    pub strike: Decimal,
110    pub expiration: NaiveDate,
111    pub put_or_call: PutOrCall,
112    pub delta: Decimal,
113    pub gamma: Decimal,
114    pub theta: Decimal,
115    pub vega: Decimal,
116    pub rho: Decimal,
117    pub implied_volatility: Decimal,
118}