[−][src]Struct alpaca_finance::Order
A unique order in the system.
Each order has a unique identifier provided by the client. This client-side unique order ID will be automatically generated by the system if not provided by the client, and will be returned as part of the order object along with the rest of the fields described below. Once an order is placed, it can be queried using the client-side order ID to check the status.
Fields
id: String
Order ID - a UUID
asset_class: String
Asset class
client_order_id: String
Client unique order id
is_extended_hours: bool
If true, eligible for execution outside regular trading hours.
filled_qty: u32
Filled quantity
filled_avg_price: Option<f64>
Filled average price
limit_price: Option<f64>
Limit price
order_type: OrderType
Type of order
qty: u32
Ordered quantity
side: OrderSide
Direction of trade - buy or sell
status: OrderStatus
The status of the order
stop_price: Option<f64>
symbol: String
Asset symbol
time_in_force: TimeInForce
how long the order is open for
Implementations
impl Order
[src]
pub async fn cancel<'_, '_>(&'_ self, alpaca: &'_ Alpaca) -> Result<()>
[src]
Attempts to cancel this order. If the order is no longer cancelable (example: status=order_filled), an error will be generated.
Example
To cancel an open order:
let alpaca = Alpaca::live("KEY_ID", "SECRET").await.unwrap();
let open_order = ...; // some buy
open_order.cancel().await?;
pub fn update(&self) -> OrderUpdater
[src]
Attempts to replace this open order. Will fail if the order is not open or the user does not have enough buying power to execute it.
Example
To update the limit price of an open order to $100.0:
let alpaca = Alpaca::live("KEY_ID", "SECRET").await.unwrap();
let open_order = ...; // some buy
open_order.update()
.limit_price(100.0)
.place(&alpaca).await.unwrap();
pub async fn get_open<'_>(alpaca: &'_ Alpaca) -> Result<Vec<Order>>
[src]
Gets a list of all open orders - returns an empty vector if there are no open orders
pub fn buy(
symbol: &str,
qty: u32,
order_type: OrderType,
time_in_force: TimeInForce
) -> OrderBuilder
[src]
symbol: &str,
qty: u32,
order_type: OrderType,
time_in_force: TimeInForce
) -> OrderBuilder
Requests a new 'buy' order.
Example
To buy 100 shares of AAPL at a limit price of $100.0 before the end of today:
let alpaca = Alpaca::live("KEY_ID", "SECRET").await.unwrap();
let order = Order::buy("AAPL", 100, OrderType::Limit, TimeInForce::DAY)
.limit_price(100.0)
.place(&alpaca).await.unwrap();
pub fn sell(
symbol: &str,
qty: u32,
order_type: OrderType,
time_in_force: TimeInForce
) -> OrderBuilder
[src]
symbol: &str,
qty: u32,
order_type: OrderType,
time_in_force: TimeInForce
) -> OrderBuilder
Requests a new 'sell' order.
Example
To sell 100 shares of MSFT at market price before the end of today:
let alpaca = Alpaca::live("KEY_ID", "SECRET").await.unwrap();
let order = Order::sell("MSFT", 100, OrderType::Market, TimeInForce::DAY)
.place(&alpaca).await.unwrap();
Trait Implementations
impl Debug for Order
[src]
impl<'de> Deserialize<'de> for Order
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl RefUnwindSafe for Order
impl Send for Order
impl Sync for Order
impl Unpin for Order
impl UnwindSafe for Order
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,