#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct OrderTradeRequest {
#[prost(enumeration = "order_trade_request::Action", tag = "1")]
pub action: i32,
#[prost(enumeration = "order_trade_request::DataType", tag = "2")]
pub data_type: i32,
#[prost(string, tag = "3")]
pub account_id: ::prost::alloc::string::String,
}
pub mod order_trade_request {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Action {
Subscribe = 0,
Unsubscribe = 1,
}
impl Action {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Subscribe => "ACTION_SUBSCRIBE",
Self::Unsubscribe => "ACTION_UNSUBSCRIBE",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ACTION_SUBSCRIBE" => Some(Self::Subscribe),
"ACTION_UNSUBSCRIBE" => Some(Self::Unsubscribe),
_ => None,
}
}
}
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum DataType {
All = 0,
Orders = 1,
Trades = 2,
}
impl DataType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::All => "DATA_TYPE_ALL",
Self::Orders => "DATA_TYPE_ORDERS",
Self::Trades => "DATA_TYPE_TRADES",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"DATA_TYPE_ALL" => Some(Self::All),
"DATA_TYPE_ORDERS" => Some(Self::Orders),
"DATA_TYPE_TRADES" => Some(Self::Trades),
_ => None,
}
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderTradeResponse {
#[prost(message, repeated, tag = "1")]
pub orders: ::prost::alloc::vec::Vec<OrderState>,
#[prost(message, repeated, tag = "2")]
pub trades: ::prost::alloc::vec::Vec<super::AccountTrade>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetOrderRequest {
#[prost(string, tag = "1")]
pub account_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub order_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Order {
#[prost(string, tag = "1")]
pub account_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub symbol: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub quantity: ::core::option::Option<
super::super::super::super::google::r#type::Decimal,
>,
#[prost(enumeration = "super::Side", tag = "4")]
pub side: i32,
#[prost(enumeration = "OrderType", tag = "5")]
pub r#type: i32,
#[prost(enumeration = "TimeInForce", tag = "6")]
pub time_in_force: i32,
#[prost(message, optional, tag = "7")]
pub limit_price: ::core::option::Option<
super::super::super::super::google::r#type::Decimal,
>,
#[prost(message, optional, tag = "8")]
pub stop_price: ::core::option::Option<
super::super::super::super::google::r#type::Decimal,
>,
#[prost(enumeration = "StopCondition", tag = "9")]
pub stop_condition: i32,
#[prost(message, repeated, tag = "10")]
pub legs: ::prost::alloc::vec::Vec<Leg>,
#[prost(string, tag = "11")]
pub client_order_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Leg {
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub quantity: ::core::option::Option<
super::super::super::super::google::r#type::Decimal,
>,
#[prost(enumeration = "super::Side", tag = "3")]
pub side: i32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderState {
#[prost(string, tag = "1")]
pub order_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub exec_id: ::prost::alloc::string::String,
#[prost(enumeration = "OrderStatus", tag = "3")]
pub status: i32,
#[prost(message, optional, tag = "4")]
pub order: ::core::option::Option<Order>,
#[prost(message, optional, tag = "5")]
pub transact_at: ::core::option::Option<::prost_types::Timestamp>,
#[prost(message, optional, tag = "6")]
pub accept_at: ::core::option::Option<::prost_types::Timestamp>,
#[prost(message, optional, tag = "7")]
pub withdraw_at: ::core::option::Option<::prost_types::Timestamp>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct OrdersRequest {
#[prost(string, tag = "1")]
pub account_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrdersResponse {
#[prost(message, repeated, tag = "1")]
pub orders: ::prost::alloc::vec::Vec<OrderState>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CancelOrderRequest {
#[prost(string, tag = "1")]
pub account_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub order_id: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OrderType {
Unspecified = 0,
Market = 1,
Limit = 2,
Stop = 3,
StopLimit = 4,
MultiLeg = 5,
}
impl OrderType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "ORDER_TYPE_UNSPECIFIED",
Self::Market => "ORDER_TYPE_MARKET",
Self::Limit => "ORDER_TYPE_LIMIT",
Self::Stop => "ORDER_TYPE_STOP",
Self::StopLimit => "ORDER_TYPE_STOP_LIMIT",
Self::MultiLeg => "ORDER_TYPE_MULTI_LEG",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ORDER_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"ORDER_TYPE_MARKET" => Some(Self::Market),
"ORDER_TYPE_LIMIT" => Some(Self::Limit),
"ORDER_TYPE_STOP" => Some(Self::Stop),
"ORDER_TYPE_STOP_LIMIT" => Some(Self::StopLimit),
"ORDER_TYPE_MULTI_LEG" => Some(Self::MultiLeg),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum TimeInForce {
Unspecified = 0,
Day = 1,
GoodTillCancel = 2,
GoodTillCrossing = 3,
Ext = 4,
OnOpen = 5,
OnClose = 6,
Ioc = 7,
Fok = 8,
}
impl TimeInForce {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "TIME_IN_FORCE_UNSPECIFIED",
Self::Day => "TIME_IN_FORCE_DAY",
Self::GoodTillCancel => "TIME_IN_FORCE_GOOD_TILL_CANCEL",
Self::GoodTillCrossing => "TIME_IN_FORCE_GOOD_TILL_CROSSING",
Self::Ext => "TIME_IN_FORCE_EXT",
Self::OnOpen => "TIME_IN_FORCE_ON_OPEN",
Self::OnClose => "TIME_IN_FORCE_ON_CLOSE",
Self::Ioc => "TIME_IN_FORCE_IOC",
Self::Fok => "TIME_IN_FORCE_FOK",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"TIME_IN_FORCE_UNSPECIFIED" => Some(Self::Unspecified),
"TIME_IN_FORCE_DAY" => Some(Self::Day),
"TIME_IN_FORCE_GOOD_TILL_CANCEL" => Some(Self::GoodTillCancel),
"TIME_IN_FORCE_GOOD_TILL_CROSSING" => Some(Self::GoodTillCrossing),
"TIME_IN_FORCE_EXT" => Some(Self::Ext),
"TIME_IN_FORCE_ON_OPEN" => Some(Self::OnOpen),
"TIME_IN_FORCE_ON_CLOSE" => Some(Self::OnClose),
"TIME_IN_FORCE_IOC" => Some(Self::Ioc),
"TIME_IN_FORCE_FOK" => Some(Self::Fok),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum StopCondition {
Unspecified = 0,
LastUp = 1,
LastDown = 2,
}
impl StopCondition {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "STOP_CONDITION_UNSPECIFIED",
Self::LastUp => "STOP_CONDITION_LAST_UP",
Self::LastDown => "STOP_CONDITION_LAST_DOWN",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"STOP_CONDITION_UNSPECIFIED" => Some(Self::Unspecified),
"STOP_CONDITION_LAST_UP" => Some(Self::LastUp),
"STOP_CONDITION_LAST_DOWN" => Some(Self::LastDown),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OrderStatus {
Unspecified = 0,
New = 1,
PartiallyFilled = 2,
Filled = 3,
DoneForDay = 4,
Canceled = 5,
Replaced = 6,
PendingCancel = 7,
Rejected = 9,
Suspended = 10,
PendingNew = 11,
Expired = 13,
Failed = 16,
Forwarding = 17,
Wait = 18,
DeniedByBroker = 19,
RejectedByExchange = 20,
Watching = 21,
Executed = 22,
Disabled = 23,
LinkWait = 24,
SlGuardTime = 27,
SlExecuted = 28,
SlForwarding = 29,
TpGuardTime = 30,
TpExecuted = 31,
TpCorrection = 32,
TpForwarding = 33,
TpCorrGuardTime = 34,
}
impl OrderStatus {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "ORDER_STATUS_UNSPECIFIED",
Self::New => "ORDER_STATUS_NEW",
Self::PartiallyFilled => "ORDER_STATUS_PARTIALLY_FILLED",
Self::Filled => "ORDER_STATUS_FILLED",
Self::DoneForDay => "ORDER_STATUS_DONE_FOR_DAY",
Self::Canceled => "ORDER_STATUS_CANCELED",
Self::Replaced => "ORDER_STATUS_REPLACED",
Self::PendingCancel => "ORDER_STATUS_PENDING_CANCEL",
Self::Rejected => "ORDER_STATUS_REJECTED",
Self::Suspended => "ORDER_STATUS_SUSPENDED",
Self::PendingNew => "ORDER_STATUS_PENDING_NEW",
Self::Expired => "ORDER_STATUS_EXPIRED",
Self::Failed => "ORDER_STATUS_FAILED",
Self::Forwarding => "ORDER_STATUS_FORWARDING",
Self::Wait => "ORDER_STATUS_WAIT",
Self::DeniedByBroker => "ORDER_STATUS_DENIED_BY_BROKER",
Self::RejectedByExchange => "ORDER_STATUS_REJECTED_BY_EXCHANGE",
Self::Watching => "ORDER_STATUS_WATCHING",
Self::Executed => "ORDER_STATUS_EXECUTED",
Self::Disabled => "ORDER_STATUS_DISABLED",
Self::LinkWait => "ORDER_STATUS_LINK_WAIT",
Self::SlGuardTime => "ORDER_STATUS_SL_GUARD_TIME",
Self::SlExecuted => "ORDER_STATUS_SL_EXECUTED",
Self::SlForwarding => "ORDER_STATUS_SL_FORWARDING",
Self::TpGuardTime => "ORDER_STATUS_TP_GUARD_TIME",
Self::TpExecuted => "ORDER_STATUS_TP_EXECUTED",
Self::TpCorrection => "ORDER_STATUS_TP_CORRECTION",
Self::TpForwarding => "ORDER_STATUS_TP_FORWARDING",
Self::TpCorrGuardTime => "ORDER_STATUS_TP_CORR_GUARD_TIME",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ORDER_STATUS_UNSPECIFIED" => Some(Self::Unspecified),
"ORDER_STATUS_NEW" => Some(Self::New),
"ORDER_STATUS_PARTIALLY_FILLED" => Some(Self::PartiallyFilled),
"ORDER_STATUS_FILLED" => Some(Self::Filled),
"ORDER_STATUS_DONE_FOR_DAY" => Some(Self::DoneForDay),
"ORDER_STATUS_CANCELED" => Some(Self::Canceled),
"ORDER_STATUS_REPLACED" => Some(Self::Replaced),
"ORDER_STATUS_PENDING_CANCEL" => Some(Self::PendingCancel),
"ORDER_STATUS_REJECTED" => Some(Self::Rejected),
"ORDER_STATUS_SUSPENDED" => Some(Self::Suspended),
"ORDER_STATUS_PENDING_NEW" => Some(Self::PendingNew),
"ORDER_STATUS_EXPIRED" => Some(Self::Expired),
"ORDER_STATUS_FAILED" => Some(Self::Failed),
"ORDER_STATUS_FORWARDING" => Some(Self::Forwarding),
"ORDER_STATUS_WAIT" => Some(Self::Wait),
"ORDER_STATUS_DENIED_BY_BROKER" => Some(Self::DeniedByBroker),
"ORDER_STATUS_REJECTED_BY_EXCHANGE" => Some(Self::RejectedByExchange),
"ORDER_STATUS_WATCHING" => Some(Self::Watching),
"ORDER_STATUS_EXECUTED" => Some(Self::Executed),
"ORDER_STATUS_DISABLED" => Some(Self::Disabled),
"ORDER_STATUS_LINK_WAIT" => Some(Self::LinkWait),
"ORDER_STATUS_SL_GUARD_TIME" => Some(Self::SlGuardTime),
"ORDER_STATUS_SL_EXECUTED" => Some(Self::SlExecuted),
"ORDER_STATUS_SL_FORWARDING" => Some(Self::SlForwarding),
"ORDER_STATUS_TP_GUARD_TIME" => Some(Self::TpGuardTime),
"ORDER_STATUS_TP_EXECUTED" => Some(Self::TpExecuted),
"ORDER_STATUS_TP_CORRECTION" => Some(Self::TpCorrection),
"ORDER_STATUS_TP_FORWARDING" => Some(Self::TpForwarding),
"ORDER_STATUS_TP_CORR_GUARD_TIME" => Some(Self::TpCorrGuardTime),
_ => None,
}
}
}
pub mod orders_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct OrdersServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl OrdersServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> OrdersServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> OrdersServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
OrdersServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn place_order(
&mut self,
request: impl tonic::IntoRequest<super::Order>,
) -> std::result::Result<tonic::Response<super::OrderState>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/grpc.tradeapi.v1.orders.OrdersService/PlaceOrder",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"grpc.tradeapi.v1.orders.OrdersService",
"PlaceOrder",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn cancel_order(
&mut self,
request: impl tonic::IntoRequest<super::CancelOrderRequest>,
) -> std::result::Result<tonic::Response<super::OrderState>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/grpc.tradeapi.v1.orders.OrdersService/CancelOrder",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"grpc.tradeapi.v1.orders.OrdersService",
"CancelOrder",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn get_orders(
&mut self,
request: impl tonic::IntoRequest<super::OrdersRequest>,
) -> std::result::Result<tonic::Response<super::OrdersResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/grpc.tradeapi.v1.orders.OrdersService/GetOrders",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("grpc.tradeapi.v1.orders.OrdersService", "GetOrders"),
);
self.inner.unary(req, path, codec).await
}
pub async fn get_order(
&mut self,
request: impl tonic::IntoRequest<super::GetOrderRequest>,
) -> std::result::Result<tonic::Response<super::OrderState>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/grpc.tradeapi.v1.orders.OrdersService/GetOrder",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("grpc.tradeapi.v1.orders.OrdersService", "GetOrder"),
);
self.inner.unary(req, path, codec).await
}
pub async fn subscribe_order_trade(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::OrderTradeRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::OrderTradeResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/grpc.tradeapi.v1.orders.OrdersService/SubscribeOrderTrade",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"grpc.tradeapi.v1.orders.OrdersService",
"SubscribeOrderTrade",
),
);
self.inner.streaming(req, path, codec).await
}
}
}