Skip to main content

Crate financial_types

Crate financial_types 

Source
Expand description

§Financial Types

Core financial type definitions for trading systems.

This crate provides fundamental enums used across financial applications:

  • UnderlyingAssetType — Classification of asset classes (stocks, crypto, forex, etc.)
  • Action — Trading actions (buy, sell)
  • Side — Position directional exposure (long, short)
  • OptionStyle — Option contract style (call, put)

All enums use #[repr(u8)] for compact memory layout and are designed for high-performance financial systems.

§Features

  • Full serde serialization/deserialization support
  • Optional utoipa support for OpenAPI schema generation (enable the utoipa feature)
  • #[repr(u8)] on all enums for deterministic layout
  • #[must_use] on pure helper methods

§Usage

use financial_types::{Action, Side, OptionStyle, UnderlyingAssetType};

let action = Action::Buy;
let side = Side::Long;
let style = OptionStyle::Call;
let asset = UnderlyingAssetType::Stock;

assert_eq!(format!("{action}"), "Buy");
assert_eq!(format!("{side}"), "Long");
assert_eq!(format!("{style}"), "Call");
assert_eq!(format!("{asset}"), "Stock");

assert!(style.is_call());
assert!(side.is_long());
assert!(action.is_buy());

Modules§

prelude
Prelude module for convenient imports.

Enums§

Action
Represents trading actions in a financial context.
OptionStyle
Specifies the style of an option contract.
Side
Defines the directional exposure of a financial position.
UnderlyingAssetType
Classification of the underlying asset for a financial instrument.