glupbit/types

Shared domain types for the Glupbit Upbit API client.

Contains market identifiers, order enums, error types, and the ApiResponse wrapper used by all API call functions.

Types

Unified error type for every API operation.

pub type ApiError {
  HttpError(httpc.HttpError)
  UpbitError(status: Int, name: String, message: String)
  DecodeError(List(decode.DecodeError))
  RateLimited(RateLimit)
  AuthError(String)
}

Constructors

Every successful API call returns data together with optional rate-limit information extracted from the Remaining-Req header.

pub type ApiResponse(a) {
  ApiResponse(data: a, rate_limit: option.Option(RateLimit))
}

Constructors

Price change direction.

pub type Change {
  Rise
  Even
  Fall
}

Constructors

  • Rise
  • Even
  • Fall

Market

opaque

Opaque trading pair identifier (e.g., "KRW-BTC", "BTC-ETH").

Construct via market/1; the raw string is only accessible through market_to_string/1.

pub opaque type Market

Order direction: buy (Bid) or sell (Ask).

pub type OrderSide {
  Bid
  Ask
}

Constructors

  • Bid
  • Ask

Lifecycle state of an order.

pub type OrderState {
  Wait
  Watch
  Done
  Cancel
}

Constructors

  • Wait
  • Watch
  • Done
  • Cancel

Order type determines matching behaviour.

pub type OrderType {
  Limit
  Price
  MarketSell
  Best
}

Constructors

  • Limit
  • Price
  • MarketSell
  • Best

Parsed Remaining-Req response header.

pub type RateLimit {
  RateLimit(
    group: String,
    remaining_min: Int,
    remaining_sec: Int,
  )
}

Constructors

  • RateLimit(group: String, remaining_min: Int, remaining_sec: Int)

Self-Match Prevention mode.

pub type SmpType {
  CancelMaker
  CancelTaker
  Reduce
}

Constructors

  • CancelMaker
  • CancelTaker
  • Reduce

Order execution condition.

pub type TimeInForce {
  Ioc
  Fok
  PostOnly
}

Constructors

  • Ioc
  • Fok
  • PostOnly

Values

pub fn change_from_string(s: String) -> Result(Change, Nil)
pub fn change_to_string(change: Change) -> String
pub fn market(code: String) -> Result(Market, Nil)

Create a Market, validating "QUOTE-BASE" format.

pub fn market_decoder() -> decode.Decoder(Market)

Decode a Market from a JSON string field.

pub fn market_to_string(m: Market) -> String

Convert a Market back to its string code.

pub fn order_side_from_string(
  s: String,
) -> Result(OrderSide, Nil)
pub fn order_side_to_string(side: OrderSide) -> String
pub fn order_state_from_string(
  s: String,
) -> Result(OrderState, Nil)
pub fn order_state_to_string(state: OrderState) -> String
pub fn order_type_from_string(
  s: String,
) -> Result(OrderType, Nil)
pub fn order_type_to_string(ord_type: OrderType) -> String
pub fn smp_type_from_string(s: String) -> Result(SmpType, Nil)
pub fn smp_type_to_string(smp: SmpType) -> String
pub fn time_in_force_from_string(
  s: String,
) -> Result(TimeInForce, Nil)
pub fn time_in_force_to_string(tif: TimeInForce) -> String
Search Document