Tidy up
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use hypersdk::hypercore::{self, BatchOrder, OrderRequest, OrderTypePlacement, TimeInForce};
|
||||
use hypersdk::hypercore::{self, BatchOrder, OrderRequest, OrderTypePlacement, Side, TimeInForce};
|
||||
use pulse_sdk::prelude::*;
|
||||
|
||||
use crate::engine::Engine;
|
||||
@@ -34,9 +34,9 @@ impl Engine {
|
||||
orders: vec![
|
||||
OrderRequest {
|
||||
asset: asset_id,
|
||||
is_buy: matches!(signal.kind, Direction::Buy),
|
||||
limit_px: signal.price.0,
|
||||
sz: signal.size,
|
||||
is_buy: matches!(signal.side, Side::Bid),
|
||||
limit_px: signal.price,
|
||||
sz: 0.into(),
|
||||
reduce_only: false,
|
||||
order_type: OrderTypePlacement::Limit {
|
||||
tif: TimeInForce::Gtc,
|
||||
@@ -45,26 +45,26 @@ impl Engine {
|
||||
},
|
||||
OrderRequest {
|
||||
asset: asset_id,
|
||||
is_buy: matches!(signal.kind, Direction::Buy),
|
||||
limit_px: signal.price.0,
|
||||
sz: signal.size,
|
||||
is_buy: matches!(signal.side, Side::Bid),
|
||||
limit_px: signal.price,
|
||||
sz: 0.into(),
|
||||
reduce_only: true,
|
||||
order_type: OrderTypePlacement::Trigger {
|
||||
is_market: true,
|
||||
trigger_px: signal.take_profit.0,
|
||||
trigger_px: signal.take_profit,
|
||||
tpsl: hypercore::TpSl::Tp,
|
||||
},
|
||||
cloid: Default::default(),
|
||||
},
|
||||
OrderRequest {
|
||||
asset: asset_id,
|
||||
is_buy: matches!(signal.kind, Direction::Buy),
|
||||
limit_px: signal.price.0,
|
||||
sz: signal.size,
|
||||
is_buy: matches!(signal.side, Side::Bid),
|
||||
limit_px: signal.price,
|
||||
sz: 0.into(),
|
||||
reduce_only: true,
|
||||
order_type: OrderTypePlacement::Trigger {
|
||||
is_market: true,
|
||||
trigger_px: signal.stop_loss.0,
|
||||
trigger_px: signal.stop_loss,
|
||||
tpsl: hypercore::TpSl::Sl,
|
||||
},
|
||||
cloid: Default::default(),
|
||||
|
||||
@@ -104,13 +104,10 @@ impl Engine {
|
||||
.asset_positions
|
||||
.into_iter()
|
||||
.map(|position| Position {
|
||||
symbol: Symbol(position.position.coin),
|
||||
size: position.position.szi.as_f64(),
|
||||
entry_price: USD(position
|
||||
.position
|
||||
.entry_px
|
||||
.unwrap_or_default()),
|
||||
profit: USD(position.position.unrealized_pnl),
|
||||
symbol: position.position.coin,
|
||||
size: position.position.szi,
|
||||
entry_price: position.position.entry_px.unwrap_or_default(),
|
||||
pnl: position.position.unrealized_pnl,
|
||||
})
|
||||
.collect(),
|
||||
))
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
use rust_decimal::Decimal;
|
||||
use pulse_sdk::prelude::*;
|
||||
use rust_decimal::Decimal;
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -80,9 +80,9 @@ pub async fn fetch_watch_list(
|
||||
}
|
||||
|
||||
items.push(MarketItem {
|
||||
symbol: Symbol(symbol.clone()),
|
||||
price: USD(price),
|
||||
volume_24h: USD(volume_24h),
|
||||
symbol: symbol.clone(),
|
||||
price: price,
|
||||
volume_24h: volume_24h,
|
||||
trend: ((price / previous_day_price) - <Decimal as From<i32>>::from(1))
|
||||
* <Decimal as From<i32>>::from(100),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user