Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/futures/account.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::BTreeMap;
use std::fmt::Display;


use crate::util::{build_signed_request, uuid_futures};
use crate::errors::Result;
use crate::client::Client;
Expand Down Expand Up @@ -248,6 +247,7 @@ impl FuturesAccount {
pub fn limit_buy(
&self, symbol: impl Into<String>, qty: impl Into<f64>, price: f64,
time_in_force: TimeInForce,
reduce_only: Option<bool>,
) -> Result<Transaction> {
Comment thread
DevWonder01 marked this conversation as resolved.
let buy = OrderRequest {
symbol: symbol.into(),
Expand All @@ -256,7 +256,7 @@ impl FuturesAccount {
order_type: OrderType::Limit,
time_in_force: Some(time_in_force),
qty: Some(qty.into()),
reduce_only: None,
reduce_only: reduce_only,
price: Some(price),
stop_price: None,
close_position: None,
Expand All @@ -278,6 +278,7 @@ impl FuturesAccount {
pub fn limit_sell(
&self, symbol: impl Into<String>, qty: impl Into<f64>, price: f64,
time_in_force: TimeInForce,
reduce_only : Option<bool>
) -> Result<Transaction> {
let sell = OrderRequest {
symbol: symbol.into(),
Expand All @@ -286,7 +287,7 @@ impl FuturesAccount {
order_type: OrderType::Limit,
time_in_force: Some(time_in_force),
qty: Some(qty.into()),
reduce_only: None,
reduce_only: reduce_only,
price: Some(price),
stop_price: None,
close_position: None,
Expand Down Expand Up @@ -613,7 +614,7 @@ impl FuturesAccount {
if let Some(API::Futures(Futures::AlgoOrder)) = api_type {
parameters.insert("algoType".into(), "Conditional".into());
parameters.insert("clientAlgoId".into(), "Conditional".into());

if let Some(client_algo_id) = order.client_algo_id {
parameters.insert("clientAlgoId".into(), client_algo_id.to_string());
}
Expand Down
34 changes: 17 additions & 17 deletions src/futures/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ pub struct Order {
pub client_order_id: String,
#[serde(with = "string_or_float", default = "default_stop_price")]
pub cum_qty: f64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub cum_quote: f64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub executed_qty: f64,
pub order_id: u64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub avg_price: f64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub orig_qty: f64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub price: f64,
pub side: String,
pub reduce_only: bool,
Expand All @@ -248,22 +248,22 @@ pub struct Order {
#[serde(rename_all = "camelCase")]
pub struct Transaction {
pub client_order_id: String,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub cum_qty: f64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub cum_quote: f64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub executed_qty: f64,
pub order_id: u64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub avg_price: f64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub orig_qty: f64,
pub reduce_only: bool,
pub side: String,
pub position_side: String,
pub status: String,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub stop_price: f64,
pub close_position: bool,
pub symbol: String,
Expand All @@ -286,23 +286,23 @@ pub struct Transaction {
#[serde(rename_all = "camelCase")]
pub struct CanceledOrder {
pub client_order_id: String,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub cum_qty: f64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub cum_quote: f64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub executed_qty: f64,
pub order_id: u64,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub orig_qty: f64,
pub orig_type: String,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub price: f64,
pub reduce_only: bool,
pub side: String,
pub position_side: String,
pub status: String,
#[serde(with = "string_or_float")]
#[serde(with = "string_or_float", default = "default_stop_price")]
pub stop_price: f64,
pub close_position: bool,
pub symbol: String,
Expand Down
Loading