/*
 * Websocket Subscription Schemas
 *
 * Schema definitions Websocket API subscriptions for Thalex exchange.
 *
 * The version of the OpenAPI document: 1.0.0
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct DHedge {
    /// Equal to \"dhedge\".
    #[serde(rename = "strategy")]
    pub strategy: String,
    /// One of [\"active\", \"stopped\"].
    #[serde(rename = "status")]
    pub status: String,
    /// Name of the instrument the bot will trade.
    #[serde(rename = "instrument_name")]
    pub instrument_name: String,
    /// Name of an instrument. If specified, the bot will only hedge the position in this instrument, not the entire underlying.
    #[serde(rename = "position", skip_serializing_if = "Option::is_none")]
    pub position: Option<String>,
    /// The delta that the bot is targeting.
    #[serde(rename = "target_delta")]
    pub target_delta: f64,
    /// Tolerance threshold.
    #[serde(rename = "threshold")]
    pub threshold: f64,
    /// Number of seconds to let the deltas stay outside of `[target-threshold, target+threshold]`, before hedging them.
    #[serde(rename = "period")]
    pub period: f64,
    /// Maximum slippage per trade, expressed as % of the traded instruments mark price.
    #[serde(rename = "max_slippage", skip_serializing_if = "Option::is_none")]
    pub max_slippage: Option<f64>,
    /// Timestamp when the bot should stop executing. If not specified, the bot will run until it's manually stopped. When `end_time` is reached, the bot will leave all positions intact, it will not open/close any of them.
    #[serde(rename = "end_time", skip_serializing_if = "Option::is_none")]
    pub end_time: Option<f64>,
    /// A label that the bot will add to all orders for easy identification.
    #[serde(rename = "label", skip_serializing_if = "Option::is_none")]
    pub label: Option<String>,
    /// Realized P&L made by this bot since the start.
    #[serde(rename = "realized_pnl")]
    pub realized_pnl: f64,
    /// Trade fees by this bot.
    #[serde(rename = "fee")]
    pub fee: f64,
    /// Average entry price of the position (if any).
    #[serde(rename = "average_price", skip_serializing_if = "Option::is_none")]
    pub average_price: Option<f64>,
    /// Position size (if any).
    #[serde(rename = "position_size", skip_serializing_if = "Option::is_none")]
    pub position_size: Option<f64>,
    /// Mark price of the bot instrument at the moment the bot was stopped.
    #[serde(rename = "mark_price_at_stop", skip_serializing_if = "Option::is_none")]
    pub mark_price_at_stop: Option<f64>,
}

impl DHedge {
    pub fn new(
        strategy: String,
        status: String,
        instrument_name: String,
        target_delta: f64,
        threshold: f64,
        period: f64,
        realized_pnl: f64,
        fee: f64,
    ) -> DHedge {
        DHedge {
            strategy,
            status,
            instrument_name,
            position: None,
            target_delta,
            threshold,
            period,
            max_slippage: None,
            end_time: None,
            label: None,
            realized_pnl,
            fee,
            average_price: None,
            position_size: None,
            mark_price_at_stop: None,
        }
    }
}
