/*
 * 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 Ocq1 {
    /// Equal to \"ocq\".
    #[serde(rename = "strategy")]
    pub strategy: String,
    /// Name of the instrument to run the One Click Quoter on.
    #[serde(rename = "instrument_name")]
    pub instrument_name: String,
    #[serde(rename = "signal")]
    pub signal: Signal,
    /// The offset of the price of the bid quote from the signal price. Must be smaller than `ask_offset`. See [the bot strategies section](#tag/bot_strategies) for more explanation.
    #[serde(rename = "bid_offset")]
    pub bid_offset: rust_decimal::Decimal,
    /// The offset of the price of the ask quote from the signal price. Must be greater than `bid_offset`. See [the bot strategies section](#tag/bot_strategies) for more explanation.
    #[serde(rename = "ask_offset")]
    pub ask_offset: rust_decimal::Decimal,
    /// Optional offset of the price of the exit quote from the signal price. Must be between `bid_offset` and `ask_offset`. See [the bot strategies section](#tag/bot_strategies) for more explanation.
    #[serde(rename = "exit_offset", skip_serializing_if = "Option::is_none")]
    pub exit_offset: Option<rust_decimal::Decimal>,
    /// The default size of both the bid and ask quote. See [the bot strategies section](#tag/bot_strategies) for more explanation.
    #[serde(rename = "quote_size")]
    pub quote_size: rust_decimal::Decimal,
    /// The minimum portfolio position to maintain in the subaccount. Must be smaller than `max_position`. See [the bot strategies section](#tag/bot_strategies) for more explanation.
    #[serde(rename = "min_position")]
    pub min_position: rust_decimal::Decimal,
    /// The maximum portfolio position to maintain in the subaccount. Must be greater than `min_position`. See [the bot strategies section](#tag/bot_strategies) for more explanation.
    #[serde(rename = "max_position")]
    pub max_position: rust_decimal::Decimal,
    /// Optional portfolio position to maintain in the subaccount. Must be between `min_position` and `max_position`. See [the bot strategies section](#tag/bot_strategies) for more explanation.
    #[serde(rename = "target_position", skip_serializing_if = "Option::is_none")]
    pub target_position: 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 Ocq1 {
    pub fn new(
        strategy: String,
        instrument_name: String,
        signal: Signal,
        bid_offset: rust_decimal::Decimal,
        ask_offset: rust_decimal::Decimal,
        quote_size: rust_decimal::Decimal,
        min_position: rust_decimal::Decimal,
        max_position: rust_decimal::Decimal,
        end_time: rust_decimal::Decimal,
        start_time: rust_decimal::Decimal,
    ) -> Ocq1 {
        Ocq1 {
            strategy,
            instrument_name,
            signal,
            bid_offset,
            ask_offset,
            exit_offset: None,
            quote_size,
            min_position,
            max_position,
            target_position: None,
            end_time,
            label: None,
            start_time,
            stop_time: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Signal {
    #[serde(rename = "index")]
    Index,
    #[serde(rename = "mark")]
    Mark,
}

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