/*
 * 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 DFollow1 {
    /// Equal to \"dfollow\".
    #[serde(rename = "strategy")]
    pub strategy: String,
    /// Name of the instrument to trade, in order to follow the deltas of the target. Must be an outright instrument with at least 0.25 delta.
    #[serde(rename = "instrument_name")]
    pub instrument_name: String,
    /// Name of the outright option to follow the deltas of.
    #[serde(rename = "target_instrument")]
    pub target_instrument: String,
    /// Amount of `target_instrument` contracts to follow the deltas of.
    #[serde(rename = "target_amount")]
    pub target_amount: rust_decimal::Decimal,
    /// Delta correction threshold. Defaults to 0.
    #[serde(rename = "threshold", skip_serializing_if = "Option::is_none")]
    pub threshold: Option<rust_decimal::Decimal>,
    /// Maximum deviation allowed from target deltas at any time.
    #[serde(rename = "tolerance", skip_serializing_if = "Option::is_none")]
    pub tolerance: Option<rust_decimal::Decimal>,
    /// Number of seconds to let the deltas of the following position stay outside of `[target-threshold, target+threshold]`, before correcting them, where `target = deltas of target_instrument * target_amount`.
    #[serde(rename = "period")]
    pub period: rust_decimal::Decimal,
    /// 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<rust_decimal::Decimal>,
    /// Timestamp when the bot should stop executing. When `end_time` is reached, the bot will leave all positions intact, it will not open/close any of them.
    #[serde(rename = "end_time")]
    pub end_time: rust_decimal::Decimal,
    /// 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>,
    /// Timestamp indicating when the bot was created.
    #[serde(rename = "start_time")]
    pub start_time: rust_decimal::Decimal,
    /// Timestamp indicating when the bot stopped working due to specified `stop_reason`.
    #[serde(rename = "stop_time", skip_serializing_if = "Option::is_none")]
    pub stop_time: Option<rust_decimal::Decimal>,
}

impl DFollow1 {
    pub fn new(
        strategy: String,
        instrument_name: String,
        target_instrument: String,
        target_amount: rust_decimal::Decimal,
        period: rust_decimal::Decimal,
        end_time: rust_decimal::Decimal,
        start_time: rust_decimal::Decimal,
    ) -> DFollow1 {
        DFollow1 {
            strategy,
            instrument_name,
            target_instrument,
            target_amount,
            threshold: None,
            tolerance: None,
            period,
            max_slippage: None,
            end_time,
            label: None,
            start_time,
            stop_time: None,
        }
    }
}
