typed Syntax and improved formatting
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use pulse_wire::general::Position;
|
||||
use pulse_wire::{
|
||||
general::Position,
|
||||
units::{Symbol, USD},
|
||||
};
|
||||
use tokio::{sync::Mutex, task::JoinHandle};
|
||||
|
||||
use crate::{
|
||||
@@ -91,14 +94,14 @@ impl Engine {
|
||||
.asset_positions
|
||||
.into_iter()
|
||||
.map(|position| Position {
|
||||
symbol: position.position.coin,
|
||||
symbol: Symbol(position.position.coin),
|
||||
size: position.position.szi.as_f64(),
|
||||
entry_price: position
|
||||
entry_price: USD(position
|
||||
.position
|
||||
.entry_px
|
||||
.map(|px| px.as_f64())
|
||||
.unwrap_or(0.0),
|
||||
profit: position.position.unrealized_pnl.as_f64(),
|
||||
.unwrap_or(0.0)),
|
||||
profit: USD(position.position.unrealized_pnl.as_f64()),
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
|
||||
+7
-4
@@ -1,6 +1,9 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use pulse_wire::terminal::MarketItem;
|
||||
use pulse_wire::{
|
||||
terminal::MarketItem,
|
||||
units::{Symbol, USD},
|
||||
};
|
||||
use serde_json::Value;
|
||||
|
||||
fn number(value: &Value, field: &str) -> Result<f64, String> {
|
||||
@@ -64,10 +67,10 @@ pub async fn fetch_watch_list(
|
||||
by_symbol.insert(
|
||||
symbol,
|
||||
MarketItem {
|
||||
symbol: symbol.to_owned(),
|
||||
price,
|
||||
symbol: Symbol(symbol.to_owned()),
|
||||
price: USD(price),
|
||||
volume_24h: USD(volume_24h),
|
||||
trend: ((price / previous_day_price) - 1.0) * 100.0,
|
||||
volume_24h,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user