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,
|
||||
};
|
||||
use crate::BoxError;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Eq, PartialEq, Hash, Clone, Debug)]
|
||||
pub enum ExchangeKind {
|
||||
@ -169,25 +170,19 @@ impl Connector for BitfinexConnector {
|
||||
let response = self.bfx.orders.submit_order(&order_form).await?;
|
||||
|
||||
Ok(ActiveOrder {
|
||||
id: 1,
|
||||
group_id: None,
|
||||
client_id: 0,
|
||||
symbol: "".to_string(),
|
||||
creation_timestamp: 0,
|
||||
update_timestamp: 0,
|
||||
amount: 0.0,
|
||||
amount_original: 0.0,
|
||||
order_type: "".to_string(),
|
||||
previous_order_type: None,
|
||||
flags: None,
|
||||
order_status: None,
|
||||
price: 0.0,
|
||||
price_avg: 0.0,
|
||||
price_trailing: None,
|
||||
price_aux_limit: None,
|
||||
notify: 0,
|
||||
hidden: 0,
|
||||
placed_id: None,
|
||||
id: response.id(),
|
||||
group_id: response.gid(),
|
||||
client_id: response.cid(),
|
||||
symbol: SymbolPair::from_str(response.symbol())?,
|
||||
creation_timestamp: response.mts_create(),
|
||||
update_timestamp: response.mts_update(),
|
||||
amount: response.amount(),
|
||||
amount_original: response.amount_orig(),
|
||||
order_type: (&response.order_type()).into(),
|
||||
previous_order_type: response.prev_order_type().map(|x| (&x).into()),
|
||||
price: response.price(),
|
||||
price_avg: response.price_avg(),
|
||||
hidden: response.hidden(),
|
||||
})
|
||||
}
|
||||
|
||||
@ -227,7 +222,7 @@ impl TryInto<Position> for bitfinex::positions::Position {
|
||||
};
|
||||
|
||||
Ok(Position::new(
|
||||
self.symbol().try_into()?,
|
||||
SymbolPair::from_str(self.symbol())?,
|
||||
state,
|
||||
self.amount(),
|
||||
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 {
|
||||
fn from(o: OrderKind) -> Self {
|
||||
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