Order execution and using decimal
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use hypersdk::Decimal;
|
||||
|
||||
use crate::units::{Direction, Symbol, USD};
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
@@ -20,7 +22,7 @@ pub struct Signal {
|
||||
pub symbol: String,
|
||||
pub kind: Direction,
|
||||
pub confidence: f32,
|
||||
pub size: f64,
|
||||
pub size: Decimal,
|
||||
pub price: USD,
|
||||
pub take_profit: USD,
|
||||
pub stop_loss: USD,
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::{
|
||||
plugin::{RiskManifest, StrategyManifest},
|
||||
units::{Symbol, USD, Volatility},
|
||||
};
|
||||
use hypersdk::hypercore::CandleInterval;
|
||||
use hypersdk::{Decimal, hypercore::CandleInterval};
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub enum TerminalServerMessage {
|
||||
@@ -39,7 +39,7 @@ pub enum TerminalClientMessage {
|
||||
pub struct MarketItem {
|
||||
pub symbol: Symbol,
|
||||
pub price: USD,
|
||||
pub trend: f64,
|
||||
pub trend: Decimal,
|
||||
pub volume_24h: USD,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use hypersdk::Decimal;
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Symbol(pub String);
|
||||
|
||||
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)]
|
||||
pub struct USD(pub f64);
|
||||
pub struct USD(pub Decimal);
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub enum Direction {
|
||||
@@ -25,10 +27,10 @@ impl std::fmt::Display for Symbol {
|
||||
|
||||
impl std::fmt::Display for USD {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
if self.0 > 0.0 {
|
||||
write!(f, "\x1b[32m${}\x1b[0m", format_f64(self.0))
|
||||
if self.0.is_sign_positive() {
|
||||
write!(f, "\x1b[32m${}\x1b[0m", format_f64(self.0.as_f64()))
|
||||
} else {
|
||||
write!(f, "\x1b[31m${}\x1b[0m", format_f64(self.0))
|
||||
write!(f, "\x1b[31m${}\x1b[0m", format_f64(self.0.as_f64()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user