Packages

Type-safe Gleam client library for the Upbit cryptocurrency exchange API

Current section

Files

Jump to
glupbit src glupbit@exchange@order.erl
Raw

src/glupbit@exchange@order.erl

-module(glupbit@exchange@order).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glupbit/exchange/order.gleam").
-export([cancel_orders_by_uuids/2, batch_cancel_orders/3, order_response_decoder/0, create_order/2, test_order/2, cancel_and_new_order/2, order_detail_decoder/0, get_order/2, get_order_by_identifier/2, list_open_orders/3, list_closed_orders/6, list_orders_by_uuids/2, cancel_order/2, cancel_order_by_identifier/2, get_order_chance/2]).
-export_type([new_order/0, cancel_and_new_order/0, order_response/0, cancelled_order/0, order_detail/0, trade_execution/0, order_chance/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(" Order management — create, query, cancel orders.\n").
-type new_order() :: {new_order,
glupbit@types:market(),
glupbit@types:order_side(),
glupbit@types:order_type(),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(glupbit@types:time_in_force()),
gleam@option:option(glupbit@types:smp_type())}.
-type cancel_and_new_order() :: {cancel_and_new_order,
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary())}.
-type order_response() :: {order_response,
binary(),
binary(),
binary(),
binary(),
gleam@option:option(binary()),
binary(),
binary(),
gleam@option:option(binary()),
gleam@option:option(binary()),
binary(),
binary(),
binary(),
binary(),
binary(),
integer(),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(list(trade_execution()))}.
-type cancelled_order() :: {cancelled_order, binary(), binary()}.
-type order_detail() :: {order_detail,
binary(),
binary(),
binary(),
binary(),
gleam@option:option(binary()),
binary(),
binary(),
gleam@option:option(binary()),
gleam@option:option(binary()),
binary(),
integer(),
gleam@option:option(list(trade_execution()))}.
-type trade_execution() :: {trade_execution,
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
gleam@option:option(binary())}.
-type order_chance() :: {order_chance,
binary(),
binary(),
binary(),
binary(),
binary(),
binary(),
binary()}.
-file("src/glupbit/exchange/order.gleam", 299).
-spec batch_cancel_decoder() -> gleam@dynamic@decode:decoder(list(cancelled_order())).
batch_cancel_decoder() ->
gleam@dynamic@decode:subfield(
[<<"success"/utf8>>, <<"orders"/utf8>>],
gleam@dynamic@decode:list(
begin
gleam@dynamic@decode:field(
<<"uuid"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Uuid) ->
gleam@dynamic@decode:field(
<<"market"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Market) ->
gleam@dynamic@decode:success(
{cancelled_order, Uuid, Market}
)
end
)
end
)
end
),
fun(Orders) -> gleam@dynamic@decode:success(Orders) end
).
-file("src/glupbit/exchange/order.gleam", 267).
?DOC(" Cancel multiple orders by UUIDs. `DELETE /orders/uuids`\n").
-spec cancel_orders_by_uuids(glupbit@client:auth_client(), list(binary())) -> {ok,
glupbit@types:api_response(list(cancelled_order()))} |
{error, glupbit@types:api_error()}.
cancel_orders_by_uuids(C, Uuids) ->
glupbit@client:auth_delete(
C,
<<"/orders/uuids"/utf8>>,
glupbit@client:build_array_query(<<"uuids"/utf8>>, Uuids),
batch_cancel_decoder()
).
-file("src/glupbit/exchange/order.gleam", 280).
?DOC(" Batch-cancel open orders. `DELETE /orders/open`\n").
-spec batch_cancel_orders(
glupbit@client:auth_client(),
gleam@option:option(glupbit@types:market()),
gleam@option:option(glupbit@types:order_side())
) -> {ok, glupbit@types:api_response(list(cancelled_order()))} |
{error, glupbit@types:api_error()}.
batch_cancel_orders(C, Market, Side) ->
Query = begin
_pipe@2 = [begin
_pipe = Market,
gleam@option:map(
_pipe,
fun(M) ->
{<<"market"/utf8>>, glupbit@types:market_to_string(M)}
end
)
end,
begin
_pipe@1 = Side,
gleam@option:map(
_pipe@1,
fun(S) ->
{<<"side"/utf8>>, glupbit@types:order_side_to_string(S)}
end
)
end],
gleam@option:values(_pipe@2)
end,
glupbit@client:auth_delete(
C,
<<"/orders/open"/utf8>>,
Query,
batch_cancel_decoder()
).
-file("src/glupbit/exchange/order.gleam", 342).
?DOC(" Map a list of optional key-value pairs into a JSON body + params for auth hashing.\n").
-spec build_body(list(gleam@option:option({binary(), binary()}))) -> {gleam@json:json(),
list({binary(), binary()})}.
build_body(Pairs) ->
Params = gleam@option:values(Pairs),
Body = begin
_pipe = Params,
_pipe@1 = gleam@list:map(
_pipe,
fun(P) ->
{erlang:element(1, P), gleam@json:string(erlang:element(2, P))}
end
),
gleam@json:object(_pipe@1)
end,
{Body, Params}.
-file("src/glupbit/exchange/order.gleam", 351).
-spec optional_pair(binary(), gleam@option:option(binary())) -> gleam@option:option({binary(),
binary()}).
optional_pair(Key, Value) ->
_pipe = Value,
gleam@option:map(_pipe, fun(V) -> {Key, V} end).
-file("src/glupbit/exchange/order.gleam", 358).
-spec encode_order(new_order()) -> {gleam@json:json(),
list({binary(), binary()})}.
encode_order(Order) ->
_pipe@2 = [{some,
{<<"market"/utf8>>,
glupbit@types:market_to_string(erlang:element(2, Order))}},
{some,
{<<"side"/utf8>>,
glupbit@types:order_side_to_string(erlang:element(3, Order))}},
{some,
{<<"ord_type"/utf8>>,
glupbit@types:order_type_to_string(erlang:element(4, Order))}},
optional_pair(<<"volume"/utf8>>, erlang:element(5, Order)),
optional_pair(<<"price"/utf8>>, erlang:element(6, Order)),
optional_pair(<<"identifier"/utf8>>, erlang:element(7, Order)),
begin
_pipe = erlang:element(8, Order),
gleam@option:map(
_pipe,
fun(T) ->
{<<"time_in_force"/utf8>>,
glupbit@types:time_in_force_to_string(T)}
end
)
end,
begin
_pipe@1 = erlang:element(9, Order),
gleam@option:map(
_pipe@1,
fun(S) ->
{<<"smp_type"/utf8>>, glupbit@types:smp_type_to_string(S)}
end
)
end],
build_body(_pipe@2).
-file("src/glupbit/exchange/order.gleam", 376).
-spec encode_cancel_and_new(cancel_and_new_order()) -> {gleam@json:json(),
list({binary(), binary()})}.
encode_cancel_and_new(Order) ->
_pipe = [optional_pair(<<"prev_order_uuid"/utf8>>, erlang:element(2, Order)),
optional_pair(
<<"prev_order_identifier"/utf8>>,
erlang:element(3, Order)
),
optional_pair(<<"new_market"/utf8>>, erlang:element(4, Order)),
optional_pair(<<"new_side"/utf8>>, erlang:element(5, Order)),
optional_pair(<<"new_volume"/utf8>>, erlang:element(6, Order)),
optional_pair(<<"new_price"/utf8>>, erlang:element(7, Order)),
optional_pair(<<"new_ord_type"/utf8>>, erlang:element(8, Order)),
optional_pair(<<"new_identifier"/utf8>>, erlang:element(9, Order)),
optional_pair(<<"new_time_in_force"/utf8>>, erlang:element(10, Order)),
optional_pair(<<"new_smp_type"/utf8>>, erlang:element(11, Order))],
build_body(_pipe).
-file("src/glupbit/exchange/order.gleam", 396).
-spec optional_string() -> gleam@dynamic@decode:decoder(gleam@option:option(binary())).
optional_string() ->
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
).
-file("src/glupbit/exchange/order.gleam", 506).
-spec trade_execution_decoder() -> gleam@dynamic@decode:decoder(trade_execution()).
trade_execution_decoder() ->
gleam@dynamic@decode:field(
<<"market"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Market) ->
gleam@dynamic@decode:field(
<<"uuid"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Uuid) ->
gleam@dynamic@decode:field(
<<"price"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Price) ->
gleam@dynamic@decode:field(
<<"volume"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Volume) ->
gleam@dynamic@decode:field(
<<"funds"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Funds) ->
gleam@dynamic@decode:field(
<<"created_at"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Created_at) ->
gleam@dynamic@decode:field(
<<"side"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Side) ->
gleam@dynamic@decode:optional_field(
<<"trend"/utf8>>,
none,
optional_string(
),
fun(Trend) ->
gleam@dynamic@decode:success(
{trade_execution,
Market,
Uuid,
Price,
Volume,
Funds,
Created_at,
Side,
Trend}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).
-file("src/glupbit/exchange/order.gleam", 401).
?DOC(" Decoder for OrderResponse.\n").
-spec order_response_decoder() -> gleam@dynamic@decode:decoder(order_response()).
order_response_decoder() ->
gleam@dynamic@decode:field(
<<"market"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Market) ->
gleam@dynamic@decode:field(
<<"uuid"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Uuid) ->
gleam@dynamic@decode:field(
<<"side"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Side) ->
gleam@dynamic@decode:field(
<<"ord_type"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Ord_type) ->
gleam@dynamic@decode:optional_field(
<<"price"/utf8>>,
none,
optional_string(),
fun(Price) ->
gleam@dynamic@decode:field(
<<"state"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(State) ->
gleam@dynamic@decode:field(
<<"created_at"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Created_at) ->
gleam@dynamic@decode:optional_field(
<<"volume"/utf8>>,
none,
optional_string(
),
fun(Volume) ->
gleam@dynamic@decode:optional_field(
<<"remaining_volume"/utf8>>,
none,
optional_string(
),
fun(
Remaining_volume
) ->
gleam@dynamic@decode:field(
<<"executed_volume"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(
Executed_volume
) ->
gleam@dynamic@decode:field(
<<"reserved_fee"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(
Reserved_fee
) ->
gleam@dynamic@decode:field(
<<"remaining_fee"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(
Remaining_fee
) ->
gleam@dynamic@decode:field(
<<"paid_fee"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(
Paid_fee
) ->
gleam@dynamic@decode:field(
<<"locked"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(
Locked
) ->
gleam@dynamic@decode:field(
<<"trades_count"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_int/1},
fun(
Trades_count
) ->
gleam@dynamic@decode:optional_field(
<<"time_in_force"/utf8>>,
none,
optional_string(
),
fun(
Time_in_force
) ->
gleam@dynamic@decode:optional_field(
<<"identifier"/utf8>>,
none,
optional_string(
),
fun(
Identifier
) ->
gleam@dynamic@decode:optional_field(
<<"smp_type"/utf8>>,
none,
optional_string(
),
fun(
Smp_type
) ->
gleam@dynamic@decode:optional_field(
<<"prevented_volume"/utf8>>,
none,
optional_string(
),
fun(
Prevented_volume
) ->
gleam@dynamic@decode:optional_field(
<<"prevented_locked"/utf8>>,
none,
optional_string(
),
fun(
Prevented_locked
) ->
gleam@dynamic@decode:optional_field(
<<"trades"/utf8>>,
none,
gleam@dynamic@decode:optional(
gleam@dynamic@decode:list(
trade_execution_decoder(
)
)
),
fun(
Trades
) ->
gleam@dynamic@decode:success(
{order_response,
Market,
Uuid,
Side,
Ord_type,
Price,
State,
Created_at,
Volume,
Remaining_volume,
Executed_volume,
Reserved_fee,
Remaining_fee,
Paid_fee,
Locked,
Trades_count,
Time_in_force,
Identifier,
Smp_type,
Prevented_volume,
Prevented_locked,
Trades}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).
-file("src/glupbit/exchange/order.gleam", 126).
?DOC(" Create a new order. `POST /orders`\n").
-spec create_order(glupbit@client:auth_client(), new_order()) -> {ok,
glupbit@types:api_response(order_response())} |
{error, glupbit@types:api_error()}.
create_order(C, Order) ->
{Body, Params} = encode_order(Order),
glupbit@client:auth_post(
C,
<<"/orders"/utf8>>,
Body,
Params,
order_response_decoder()
).
-file("src/glupbit/exchange/order.gleam", 141).
?DOC(" Create a test order (no execution). `POST /orders/test`\n").
-spec test_order(glupbit@client:auth_client(), new_order()) -> {ok,
glupbit@types:api_response(order_response())} |
{error, glupbit@types:api_error()}.
test_order(C, Order) ->
{Body, Params} = encode_order(Order),
glupbit@client:auth_post(
C,
<<"/orders/test"/utf8>>,
Body,
Params,
order_response_decoder()
).
-file("src/glupbit/exchange/order.gleam", 312).
?DOC(" Cancel an existing order and create a replacement. `POST /orders/cancel_and_new`\n").
-spec cancel_and_new_order(glupbit@client:auth_client(), cancel_and_new_order()) -> {ok,
glupbit@types:api_response(order_response())} |
{error, glupbit@types:api_error()}.
cancel_and_new_order(C, Order) ->
{Body, Params} = encode_cancel_and_new(Order),
glupbit@client:auth_post(
C,
<<"/orders/cancel_and_new"/utf8>>,
Body,
Params,
order_response_decoder()
).
-file("src/glupbit/exchange/order.gleam", 469).
?DOC(" Decoder for OrderDetail.\n").
-spec order_detail_decoder() -> gleam@dynamic@decode:decoder(order_detail()).
order_detail_decoder() ->
gleam@dynamic@decode:field(
<<"market"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Market) ->
gleam@dynamic@decode:field(
<<"uuid"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Uuid) ->
gleam@dynamic@decode:field(
<<"side"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Side) ->
gleam@dynamic@decode:field(
<<"ord_type"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Ord_type) ->
gleam@dynamic@decode:optional_field(
<<"price"/utf8>>,
none,
optional_string(),
fun(Price) ->
gleam@dynamic@decode:field(
<<"state"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(State) ->
gleam@dynamic@decode:field(
<<"created_at"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Created_at) ->
gleam@dynamic@decode:optional_field(
<<"volume"/utf8>>,
none,
optional_string(
),
fun(Volume) ->
gleam@dynamic@decode:optional_field(
<<"remaining_volume"/utf8>>,
none,
optional_string(
),
fun(
Remaining_volume
) ->
gleam@dynamic@decode:field(
<<"executed_volume"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(
Executed_volume
) ->
gleam@dynamic@decode:field(
<<"trades_count"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_int/1},
fun(
Trades_count
) ->
gleam@dynamic@decode:optional_field(
<<"trades"/utf8>>,
none,
gleam@dynamic@decode:optional(
gleam@dynamic@decode:list(
trade_execution_decoder(
)
)
),
fun(
Trades
) ->
gleam@dynamic@decode:success(
{order_detail,
Market,
Uuid,
Side,
Ord_type,
Price,
State,
Created_at,
Volume,
Remaining_volume,
Executed_volume,
Trades_count,
Trades}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).
-file("src/glupbit/exchange/order.gleam", 156).
?DOC(" Get a single order by UUID. `GET /order`\n").
-spec get_order(glupbit@client:auth_client(), binary()) -> {ok,
glupbit@types:api_response(order_detail())} |
{error, glupbit@types:api_error()}.
get_order(C, Uuid) ->
glupbit@client:auth_get(
C,
<<"/order"/utf8>>,
[{<<"uuid"/utf8>>, Uuid}],
order_detail_decoder()
).
-file("src/glupbit/exchange/order.gleam", 169).
?DOC(" Get a single order by client identifier. `GET /order`\n").
-spec get_order_by_identifier(glupbit@client:auth_client(), binary()) -> {ok,
glupbit@types:api_response(order_detail())} |
{error, glupbit@types:api_error()}.
get_order_by_identifier(C, Id) ->
glupbit@client:auth_get(
C,
<<"/order"/utf8>>,
[{<<"identifier"/utf8>>, Id}],
order_detail_decoder()
).
-file("src/glupbit/exchange/order.gleam", 182).
?DOC(" List open orders. `GET /orders/open`\n").
-spec list_open_orders(
glupbit@client:auth_client(),
gleam@option:option(glupbit@types:market()),
gleam@option:option(binary())
) -> {ok, glupbit@types:api_response(list(order_detail()))} |
{error, glupbit@types:api_error()}.
list_open_orders(C, Market, State) ->
Query = begin
_pipe@2 = [begin
_pipe = Market,
gleam@option:map(
_pipe,
fun(M) ->
{<<"market"/utf8>>, glupbit@types:market_to_string(M)}
end
)
end,
begin
_pipe@1 = State,
gleam@option:map(_pipe@1, fun(S) -> {<<"state"/utf8>>, S} end)
end],
gleam@option:values(_pipe@2)
end,
glupbit@client:auth_get(
C,
<<"/orders/open"/utf8>>,
Query,
gleam@dynamic@decode:list(order_detail_decoder())
).
-file("src/glupbit/exchange/order.gleam", 202).
?DOC(" List closed orders. `GET /orders/closed`\n").
-spec list_closed_orders(
glupbit@client:auth_client(),
gleam@option:option(glupbit@types:market()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(integer())
) -> {ok, glupbit@types:api_response(list(order_detail()))} |
{error, glupbit@types:api_error()}.
list_closed_orders(C, Market, State, Start_time, End_time, Limit) ->
Query = begin
_pipe@5 = [begin
_pipe = Market,
gleam@option:map(
_pipe,
fun(M) ->
{<<"market"/utf8>>, glupbit@types:market_to_string(M)}
end
)
end,
begin
_pipe@1 = State,
gleam@option:map(_pipe@1, fun(S) -> {<<"state"/utf8>>, S} end)
end,
begin
_pipe@2 = Start_time,
gleam@option:map(
_pipe@2,
fun(T) -> {<<"start_time"/utf8>>, T} end
)
end,
begin
_pipe@3 = End_time,
gleam@option:map(
_pipe@3,
fun(T@1) -> {<<"end_time"/utf8>>, T@1} end
)
end,
begin
_pipe@4 = Limit,
gleam@option:map(
_pipe@4,
fun(N) ->
{<<"limit"/utf8>>, erlang:integer_to_binary(N)}
end
)
end],
gleam@option:values(_pipe@5)
end,
glupbit@client:auth_get(
C,
<<"/orders/closed"/utf8>>,
Query,
gleam@dynamic@decode:list(order_detail_decoder())
).
-file("src/glupbit/exchange/order.gleam", 228).
?DOC(" List orders by UUIDs. `GET /orders/uuids`\n").
-spec list_orders_by_uuids(glupbit@client:auth_client(), list(binary())) -> {ok,
glupbit@types:api_response(list(order_detail()))} |
{error, glupbit@types:api_error()}.
list_orders_by_uuids(C, Uuids) ->
glupbit@client:auth_get(
C,
<<"/orders/uuids"/utf8>>,
glupbit@client:build_array_query(<<"uuids"/utf8>>, Uuids),
gleam@dynamic@decode:list(order_detail_decoder())
).
-file("src/glupbit/exchange/order.gleam", 241).
?DOC(" Cancel a single order by UUID. `DELETE /order`\n").
-spec cancel_order(glupbit@client:auth_client(), binary()) -> {ok,
glupbit@types:api_response(order_detail())} |
{error, glupbit@types:api_error()}.
cancel_order(C, Uuid) ->
glupbit@client:auth_delete(
C,
<<"/order"/utf8>>,
[{<<"uuid"/utf8>>, Uuid}],
order_detail_decoder()
).
-file("src/glupbit/exchange/order.gleam", 254).
?DOC(" Cancel a single order by identifier. `DELETE /order`\n").
-spec cancel_order_by_identifier(glupbit@client:auth_client(), binary()) -> {ok,
glupbit@types:api_response(order_detail())} |
{error, glupbit@types:api_error()}.
cancel_order_by_identifier(C, Id) ->
glupbit@client:auth_delete(
C,
<<"/order"/utf8>>,
[{<<"identifier"/utf8>>, Id}],
order_detail_decoder()
).
-file("src/glupbit/exchange/order.gleam", 527).
-spec order_chance_decoder() -> gleam@dynamic@decode:decoder(order_chance()).
order_chance_decoder() ->
gleam@dynamic@decode:field(
<<"bid_fee"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Bid_fee) ->
gleam@dynamic@decode:field(
<<"ask_fee"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Ask_fee) ->
gleam@dynamic@decode:subfield(
[<<"market"/utf8>>, <<"id"/utf8>>],
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Market_id) ->
gleam@dynamic@decode:subfield(
[<<"bid_account"/utf8>>, <<"currency"/utf8>>],
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Bid_account_currency) ->
gleam@dynamic@decode:subfield(
[<<"bid_account"/utf8>>,
<<"balance"/utf8>>],
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Bid_account_balance) ->
gleam@dynamic@decode:subfield(
[<<"ask_account"/utf8>>,
<<"currency"/utf8>>],
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Ask_account_currency) ->
gleam@dynamic@decode:subfield(
[<<"ask_account"/utf8>>,
<<"balance"/utf8>>],
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Ask_account_balance) ->
gleam@dynamic@decode:success(
{order_chance,
Bid_fee,
Ask_fee,
Market_id,
Bid_account_currency,
Bid_account_balance,
Ask_account_currency,
Ask_account_balance}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).
-file("src/glupbit/exchange/order.gleam", 327).
?DOC(" Get order constraints for a market. `GET /orders/chance`\n").
-spec get_order_chance(glupbit@client:auth_client(), glupbit@types:market()) -> {ok,
glupbit@types:api_response(order_chance())} |
{error, glupbit@types:api_error()}.
get_order_chance(C, Market) ->
glupbit@client:auth_get(
C,
<<"/orders/chance"/utf8>>,
[{<<"market"/utf8>>, glupbit@types:market_to_string(Market)}],
order_chance_decoder()
).