Skip to content

Commit

Permalink
docs: document position (#89)
Browse files Browse the repository at this point in the history
Co-authored-by: Wil Boayue <[email protected]>
  • Loading branch information
wboayue and Wil Boayue authored May 1, 2023
1 parent 44b7ff3 commit cb73f05
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ibapi"
version = "0.2.1"
version = "0.2.2"
edition = "2021"
authors = ["Wil Boayue <[email protected]>"]
description = "A synchronous implementation of the Interactive Brokers TWS API."
Expand Down
6 changes: 5 additions & 1 deletion src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ mod encoders;

#[derive(Debug, Default)]
pub struct Position {
/// Account holding position
pub account: String,
/// Contract
pub contract: Contract,
/// Size of position
pub position: f64,
/// Average cost of position
pub average_cost: f64,
}

Expand All @@ -39,7 +43,7 @@ pub(crate) fn cancel_positions(client: &Client) -> Result<(), Error> {
}

// Supports iteration over [Position].
pub struct PositionIterator<'a> {
pub(crate) struct PositionIterator<'a> {
client: &'a Client,
messages: GlobalResponseIterator,
}
Expand Down
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl Client {

// === Accounts ===

/// Get current positions for all accessible accounts.
/// Get current [Position]s for all accessible accounts.
#[allow(clippy::needless_lifetimes)]
pub fn positions<'a>(&'a self) -> core::result::Result<impl Iterator<Item = Position> + 'a, Error> {
accounts::positions(self)
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@
//! }
//!```
mod accounts;
/// Describes items present in an account.
pub mod accounts;

/// TSW API Client.
///
/// The Client establishes the connection to TWS or the Gateway.
Expand Down

0 comments on commit cb73f05

Please sign in to comment.