pub struct GetPositionBookRequest { /* private fields */ }
Expand description

Get Position Book Fetch a position book for an instrument.

Implementations§

source§

impl GetPositionBookRequest

source

pub fn new() -> GetPositionBookRequest

Examples found in repository?
examples/endpoints.rs (lines 33-34)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
async fn main() {
    let api_key = env::var("OANDA_KEY").expect("expected OANDA_KEY environment variable to be set");
    let api_host = env
        ::var("OANDA_HOST")
        .expect("expected OANDA_HOST environment variable to be set");

    // only run example program against demo account!!
    assert_eq!(api_host, "api-fxpractice.oanda.com");

    let client = fxoanda::Client {
        host: String::from(api_host),
        reqwest: reqwest::Client::new(),
        authentication: String::from(api_key),
    };

    match
        fxoanda::GetInstrumentCandlesRequest
            ::new()
            .with_instrument("EUR_USD".to_string())
            .with_granularity(CandlestickGranularity::H4)
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => eprintln!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetPositionBookRequest
            ::new()
            .with_instrument("EUR_USD".to_string())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetOrderBookRequest
            ::new()
            .with_instrument("EUR_USD".to_string())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match fxoanda::ListAccountsRequest::new().remote(&client).await {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    let response = fxoanda::ListAccountsRequest::new().remote(&client).await.unwrap();
    let accounts = response.accounts.expect("Did not find 'accounts' field in response");
    let account = accounts.get(0).expect("Did not find an 'account' in the 'accounts' field");
    let account_id = account.id
        .as_ref()
        .expect("Did not find an 'id' field in the 'account'")
        .to_string();

    match
        fxoanda::GetAccountSummaryRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetAccountRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetAccountInstrumentsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListOrdersRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListPendingOrdersRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListTradesRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListOpenTradesRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListPositionsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListOpenPositionsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListTransactionsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }
}
source

pub fn with_uri(self, x: String) -> Self

source

pub fn with_instrument(self, x: String) -> Self

Name of the Instrument format: A string containing the base currency and quote currency delimited by a “_”.

  • param String
  • return GetPositionBookRequest
Examples found in repository?
examples/endpoints.rs (line 35)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
async fn main() {
    let api_key = env::var("OANDA_KEY").expect("expected OANDA_KEY environment variable to be set");
    let api_host = env
        ::var("OANDA_HOST")
        .expect("expected OANDA_HOST environment variable to be set");

    // only run example program against demo account!!
    assert_eq!(api_host, "api-fxpractice.oanda.com");

    let client = fxoanda::Client {
        host: String::from(api_host),
        reqwest: reqwest::Client::new(),
        authentication: String::from(api_key),
    };

    match
        fxoanda::GetInstrumentCandlesRequest
            ::new()
            .with_instrument("EUR_USD".to_string())
            .with_granularity(CandlestickGranularity::H4)
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => eprintln!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetPositionBookRequest
            ::new()
            .with_instrument("EUR_USD".to_string())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetOrderBookRequest
            ::new()
            .with_instrument("EUR_USD".to_string())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match fxoanda::ListAccountsRequest::new().remote(&client).await {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    let response = fxoanda::ListAccountsRequest::new().remote(&client).await.unwrap();
    let accounts = response.accounts.expect("Did not find 'accounts' field in response");
    let account = accounts.get(0).expect("Did not find an 'account' in the 'accounts' field");
    let account_id = account.id
        .as_ref()
        .expect("Did not find an 'id' field in the 'account'")
        .to_string();

    match
        fxoanda::GetAccountSummaryRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetAccountRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetAccountInstrumentsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListOrdersRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListPendingOrdersRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListTradesRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListOpenTradesRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListPositionsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListOpenPositionsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListTransactionsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }
}
source

pub fn with_authorization(self, x: String) -> Self

The authorization bearer token previously obtained by the client format: The string ’Bearer ’ followed by the token.

  • param String
  • return GetPositionBookRequest
source

pub fn with_accept_datetime_format(self, x: String) -> Self

Format of DateTime fields in the request and response.

  • param String
  • return GetPositionBookRequest
source

pub fn with_time(self, x: DateTime<Utc>) -> Self

The time of the snapshot to fetch. If not specified, then the most recent snapshot is fetched. format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).

  • param DateTime
  • return GetPositionBookRequest
source

pub async fn remote( self, client: &Client ) -> Result<GetPositionBookResponse, Box<dyn Error>>

Examples found in repository?
examples/endpoints.rs (line 36)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
async fn main() {
    let api_key = env::var("OANDA_KEY").expect("expected OANDA_KEY environment variable to be set");
    let api_host = env
        ::var("OANDA_HOST")
        .expect("expected OANDA_HOST environment variable to be set");

    // only run example program against demo account!!
    assert_eq!(api_host, "api-fxpractice.oanda.com");

    let client = fxoanda::Client {
        host: String::from(api_host),
        reqwest: reqwest::Client::new(),
        authentication: String::from(api_key),
    };

    match
        fxoanda::GetInstrumentCandlesRequest
            ::new()
            .with_instrument("EUR_USD".to_string())
            .with_granularity(CandlestickGranularity::H4)
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => eprintln!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetPositionBookRequest
            ::new()
            .with_instrument("EUR_USD".to_string())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetOrderBookRequest
            ::new()
            .with_instrument("EUR_USD".to_string())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match fxoanda::ListAccountsRequest::new().remote(&client).await {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    let response = fxoanda::ListAccountsRequest::new().remote(&client).await.unwrap();
    let accounts = response.accounts.expect("Did not find 'accounts' field in response");
    let account = accounts.get(0).expect("Did not find an 'account' in the 'accounts' field");
    let account_id = account.id
        .as_ref()
        .expect("Did not find an 'id' field in the 'account'")
        .to_string();

    match
        fxoanda::GetAccountSummaryRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetAccountRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::GetAccountInstrumentsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListOrdersRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListPendingOrdersRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListTradesRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListOpenTradesRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListPositionsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListOpenPositionsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }

    match
        fxoanda::ListTransactionsRequest
            ::new()
            .with_account_id(account_id.to_owned())
            .remote(&client).await
    {
        Ok(x) => println!("OK: {:#?}", x),
        Err(e) => println!("ERR: {:#?}", e),
    }
}

Trait Implementations§

source§

impl Debug for GetPositionBookRequest

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for GetPositionBookRequest

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for GetPositionBookRequest

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,