implemented OrderKind <-> bitfinex::OrderKind, returning proper response from submit order
This commit is contained in:
parent
191a21bec9
commit
b5b3455f08
@ -13,6 +13,7 @@ use crate::models::{
|
|||||||
PriceTicker,
|
PriceTicker,
|
||||||
};
|
};
|
||||||
use crate::BoxError;
|
use crate::BoxError;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Hash, Clone, Debug)]
|
#[derive(Eq, PartialEq, Hash, Clone, Debug)]
|
||||||
pub enum ExchangeKind {
|
pub enum ExchangeKind {
|
||||||
@ -169,25 +170,19 @@ impl Connector for BitfinexConnector {
|
|||||||
let response = self.bfx.orders.submit_order(&order_form).await?;
|
let response = self.bfx.orders.submit_order(&order_form).await?;
|
||||||
|
|
||||||
Ok(ActiveOrder {
|
Ok(ActiveOrder {
|
||||||
id: 1,
|
id: response.id(),
|
||||||
group_id: None,
|
group_id: response.gid(),
|
||||||
client_id: 0,
|
client_id: response.cid(),
|
||||||
symbol: "".to_string(),
|
symbol: SymbolPair::from_str(response.symbol())?,
|
||||||
creation_timestamp: 0,
|
creation_timestamp: response.mts_create(),
|
||||||
update_timestamp: 0,
|
update_timestamp: response.mts_update(),
|
||||||
amount: 0.0,
|
amount: response.amount(),
|
||||||
amount_original: 0.0,
|
amount_original: response.amount_orig(),
|
||||||
order_type: "".to_string(),
|
order_type: (&response.order_type()).into(),
|
||||||
previous_order_type: None,
|
previous_order_type: response.prev_order_type().map(|x| (&x).into()),
|
||||||
flags: None,
|
price: response.price(),
|
||||||
order_status: None,
|
price_avg: response.price_avg(),
|
||||||
price: 0.0,
|
hidden: response.hidden(),
|
||||||
price_avg: 0.0,
|
|
||||||
price_trailing: None,
|
|
||||||
price_aux_limit: None,
|
|
||||||
notify: 0,
|
|
||||||
hidden: 0,
|
|
||||||
placed_id: None,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +222,7 @@ impl TryInto<Position> for bitfinex::positions::Position {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Ok(Position::new(
|
Ok(Position::new(
|
||||||
self.symbol().try_into()?,
|
SymbolPair::from_str(self.symbol())?,
|
||||||
state,
|
state,
|
||||||
self.amount(),
|
self.amount(),
|
||||||
self.base_price(),
|
self.base_price(),
|
||||||
@ -261,6 +256,26 @@ impl From<&OrderKind> for bitfinex::orders::OrderKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&bitfinex::orders::OrderKind> for OrderKind {
|
||||||
|
fn from(o: &bitfinex::orders::OrderKind) -> Self {
|
||||||
|
match o {
|
||||||
|
bitfinex::orders::OrderKind::Limit => OrderKind::Limit,
|
||||||
|
bitfinex::orders::OrderKind::ExchangeLimit => OrderKind::ExchangeLimit,
|
||||||
|
bitfinex::orders::OrderKind::Market => OrderKind::Market,
|
||||||
|
bitfinex::orders::OrderKind::ExchangeMarket => OrderKind::ExchangeMarket,
|
||||||
|
bitfinex::orders::OrderKind::Stop => OrderKind::Stop,
|
||||||
|
bitfinex::orders::OrderKind::ExchangeStop => OrderKind::ExchangeStop,
|
||||||
|
bitfinex::orders::OrderKind::StopLimit => OrderKind::StopLimit,
|
||||||
|
bitfinex::orders::OrderKind::ExchangeStopLimit => OrderKind::ExchangeStopLimit,
|
||||||
|
bitfinex::orders::OrderKind::TrailingStop => OrderKind::TrailingStop,
|
||||||
|
bitfinex::orders::OrderKind::Fok => OrderKind::Fok,
|
||||||
|
bitfinex::orders::OrderKind::ExchangeFok => OrderKind::ExchangeFok,
|
||||||
|
bitfinex::orders::OrderKind::Ioc => OrderKind::Ioc,
|
||||||
|
bitfinex::orders::OrderKind::ExchangeIoc => OrderKind::ExchangeIoc,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<OrderKind> for bitfinex::orders::OrderKind {
|
impl From<OrderKind> for bitfinex::orders::OrderKind {
|
||||||
fn from(o: OrderKind) -> Self {
|
fn from(o: OrderKind) -> Self {
|
||||||
match o {
|
match o {
|
||||||
@ -297,29 +312,3 @@ impl From<TradingPairTicker> for PriceTicker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bitfinex::orders::ActiveOrder> for ActiveOrder {
|
|
||||||
fn from(o: bitfinex::orders::ActiveOrder) -> Self {
|
|
||||||
Self {
|
|
||||||
id: o.id,
|
|
||||||
group_id: o.group_id,
|
|
||||||
client_id: o.client_id,
|
|
||||||
symbol: o.symbol,
|
|
||||||
creation_timestamp: o.creation_timestamp,
|
|
||||||
update_timestamp: o.update_timestamp,
|
|
||||||
amount: o.amount,
|
|
||||||
amount_original: o.amount_original,
|
|
||||||
order_type: o.order_type,
|
|
||||||
previous_order_type: o.previous_order_type,
|
|
||||||
flags: o.flags,
|
|
||||||
order_status: o.order_status,
|
|
||||||
price: o.price,
|
|
||||||
price_avg: o.price_avg,
|
|
||||||
price_trailing: o.price_trailing,
|
|
||||||
price_aux_limit: o.price_aux_limit,
|
|
||||||
notify: o.notify,
|
|
||||||
hidden: o.hidden,
|
|
||||||
placed_id: o.placed_id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user