Skip to content

Commit

Permalink
doc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Boayue committed Nov 4, 2024
1 parent 66a2cd3 commit a8ba72c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/option_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {
let client = Client::connect("127.0.0.1:4002", 100).expect("connection failed");

let symbol = "AAPL";
let exchange = ""; // all exchanges
let exchange = ""; // all exchanges
let security_type = SecurityType::Stock;
let contract_id = 265598;

Expand Down
22 changes: 12 additions & 10 deletions src/contracts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::convert::From;
use std::fmt::Debug;
use std::ops::Sub;
use std::string::ToString;

use log::{error, info};
Expand Down Expand Up @@ -485,7 +484,7 @@ impl DataStream<OptionChain> for OptionChain {
// # Arguments
// * `client` - [Client] with an active connection to gateway.
// * `contract` - The [Contract] used as sample to query the available contracts. Typically, it will contain the [Contract]'s symbol, currency, security_type, and exchange.
pub(crate) fn contract_details(client: &Client, contract: &Contract) -> Result<Vec<ContractDetails>, Error> {
pub(super) fn contract_details(client: &Client, contract: &Contract) -> Result<Vec<ContractDetails>, Error> {
verify_contract(client, contract)?;

let request_id = client.next_request_id();
Expand Down Expand Up @@ -562,7 +561,7 @@ pub struct ContractDescription {
// # Arguments
// * `client` - [Client] with an active connection to gateway.
// * `pattern` - Either start of ticker symbol or (for larger strings) company name.
pub(crate) fn matching_symbols(client: &Client, pattern: &str) -> Result<Vec<ContractDescription>, Error> {
pub(super) fn matching_symbols(client: &Client, pattern: &str) -> Result<Vec<ContractDescription>, Error> {
client.check_server_version(server_versions::REQ_MATCHING_SYMBOLS, "It does not support matching symbols requests.")?;

let request_id = client.next_request_id();
Expand Down Expand Up @@ -590,8 +589,11 @@ pub(crate) fn matching_symbols(client: &Client, pattern: &str) -> Result<Vec<Con
}

#[derive(Debug, Default)]
/// Minimum price increment structure for a particular market rule ID.
pub struct MarketRule {
/// Market Rule ID requested.
pub market_rule_id: i32,
/// Returns the available price increments based on the market rule.
pub price_increments: Vec<PriceIncrement>,
}

Expand All @@ -601,11 +603,11 @@ pub struct PriceIncrement {
pub increment: f64,
}

/// Requests details about a given market rule
///
/// The market rule for an instrument on a particular exchange provides details about how the minimum price increment changes with price.
/// A list of market rule ids can be obtained by invoking [request_contract_details] on a particular contract. The returned market rule ID list will provide the market rule ID for the instrument in the correspond valid exchange list in [ContractDetails].
pub(crate) fn market_rule(client: &Client, market_rule_id: i32) -> Result<MarketRule, Error> {
// Requests details about a given market rule
//
// The market rule for an instrument on a particular exchange provides details about how the minimum price increment changes with price.
// A list of market rule ids can be obtained by invoking [request_contract_details] on a particular contract. The returned market rule ID list will provide the market rule ID for the instrument in the correspond valid exchange list in [ContractDetails].
pub(super) fn market_rule(client: &Client, market_rule_id: i32) -> Result<MarketRule, Error> {
client.check_server_version(server_versions::MARKET_RULES, "It does not support market rule requests.")?;

let request = encoders::encode_request_market_rule(market_rule_id)?;
Expand All @@ -624,7 +626,7 @@ pub(crate) fn market_rule(client: &Client, market_rule_id: i32) -> Result<Market
// * `contract` - The [Contract] object for which the depth is being requested.
// * `volatility` - Hypothetical volatility.
// * `underlying_price` - Hypothetical option’s underlying price.
pub(crate) fn calculate_option_price(
pub(super) fn calculate_option_price(
client: &Client,
contract: &Contract,
volatility: f64,
Expand All @@ -649,7 +651,7 @@ pub(crate) fn calculate_option_price(
// * `contract` - The [Contract] object for which the depth is being requested.
// * `option_price` - Hypothetical option price.
// * `underlying_price` - Hypothetical option’s underlying price.
pub(crate) fn calculate_implied_volatility(
pub(super) fn calculate_implied_volatility(
client: &Client,
contract: &Contract,
option_price: f64,
Expand Down

0 comments on commit a8ba72c

Please sign in to comment.