Skip to content

Refactor Time In Force (TIF) to an Enum #169

@isSerge

Description

@isSerge

Problem

Currently, the Time In Force (TIF) parameter in Limit and ClientLimit structs is represented as a String. This approach is error-prone as it allows for invalid TIF values to be passed at compile time, leading to runtime errors or unexpected behavior. It also requires manual string management and lacks the type safety that Rust's enum system provides.

Solution

Refactor the tif: String field into a tif: Tif field, where Tif is a new enum. The Tif enum should include the supported Time In Force values, such as Gtc (Good 'Til Cancelled) and Ioc (Immediate Or Cancel).

Proposed enum:

#[derive(Deserialize, Serialize, Clone, Debug)]
  #[serde(rename_all = "PascalCase")]
  pub enum Tif {
      Gtc,
      Ioc,
      // Add other TIF types as needed
  }

This change will improve type safety, code readability, and maintainability.

Happy to submit PR if this makes sense

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions