/*
 * Thalex RPC API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * 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 DHedge1 {
    /// Equal to \"dhedge\".
    #[serde(rename = "strategy")]
    pub strategy: String,
    /// Name of the instrument the bot will trade. Must be an outright instrument with at least 0.25 delta.
    #[serde(rename = "instrument_name")]
    pub instrument_name: String,
    /// Name of an outright 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>,
    /// Delta to target. Defaults to 0. Must be between -10 and 10.
    #[serde(rename = "target_delta", skip_serializing_if = "Option::is_none")]
    pub target_delta: Option<f64>,
    /// Hedging threshold. Defaults to 0. Must be between 0 and 0.3.
    #[serde(rename = "threshold", skip_serializing_if = "Option::is_none")]
    pub threshold: Option<f64>,
    /// Maximum deviation allowed from target deltas at any time.
    #[serde(rename = "tolerance", skip_serializing_if = "Option::is_none")]
    pub tolerance: Option<f64>,
    /// Number of seconds to let the deltas stay outside of `[target-threshold, target+threshold]`, before hedging them. Must be between 1 and 3600.
    #[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>,
}

impl DHedge1 {
    pub fn new(strategy: String, instrument_name: String, period: f64) -> DHedge1 {
        DHedge1 {
            strategy,
            instrument_name,
            position: None,
            target_delta: None,
            threshold: None,
            tolerance: None,
            period,
            max_slippage: None,
            end_time: None,
            label: None,
        }
    }
}
