/*
 * 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 Sgsl1 {
    /// Equal to \"sgsl\"
    #[serde(rename = "strategy")]
    pub strategy: String,
    /// Name of the instrument to run SGSL on.
    #[serde(rename = "instrument_name")]
    pub instrument_name: String,
    #[serde(rename = "signal")]
    pub signal: Signal,
    /// Price to compare `signal` price to, to determine necessary adjustments to the portfolio. See [the bot strategies section](#tag/bot_strategies) for more explanation. Must be greater or equal to `exit_price + 5 * price tick of the instrument`.
    #[serde(rename = "entry_price")]
    pub entry_price: f64,
    /// The target position to maintain in the subaccount if `signal` price is above `entry_price`. See [the bot strategies section](#tag/bot_strategies) for more explanation. Can be maximum `500 * volume tick of the instrument` away from `exit_position`.
    #[serde(rename = "target_position")]
    pub target_position: f64,
    /// Price to compare `signal` price to, to determine necessary adjustments to the portfolio. See [the bot strategies section](#tag/bot_strategies) for more explanation. Must be lower or equal to `entry_price - 5 * price tick of the instrument`.
    #[serde(rename = "exit_price")]
    pub exit_price: f64,
    /// The target position to maintain in the subaccount if `signal` price is below `exit_price`. See [the bot strategies section](#tag/bot_strategies) for more explanation. Can be maximum `500 * volume tick of the instrument` away from `target_position`.
    #[serde(rename = "exit_position")]
    pub exit_position: 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. Must not be further away than a week. 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: 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 Sgsl1 {
    pub fn new(
        strategy: String,
        instrument_name: String,
        signal: Signal,
        entry_price: f64,
        target_position: f64,
        exit_price: f64,
        exit_position: f64,
        end_time: f64,
    ) -> Sgsl1 {
        Sgsl1 {
            strategy,
            instrument_name,
            signal,
            entry_price,
            target_position,
            exit_price,
            exit_position,
            max_slippage: None,
            end_time,
            label: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Signal {
    #[serde(rename = "last")]
    Last,
    #[serde(rename = "index")]
    Index,
    #[serde(rename = "mark")]
    Mark,
}

impl Default for Signal {
    fn default() -> Signal {
        Self::Last
    }
}
