diff --git a/lib/krakex.ex b/lib/krakex.ex index cb598c4..758b1b3 100644 --- a/lib/krakex.ex +++ b/lib/krakex.ex @@ -7,6 +7,7 @@ defmodule Krakex do ## Public market data * `server_time/1` - Get server time. + * `system_status/1` - Get system status. * `assets/2` - Get asset info. * `asset_pairs/2` - Get tradable asset pairs. * `ticker/2` - Get ticker information. @@ -74,6 +75,29 @@ defmodule Krakex do @api.public_request(client, "Time") end + @doc """ + Get system status. + + Returns a map with the fields: + + * `"status"` - one of: + * `"online"` - operational, full trading available. + * `"cancel_only"` - existing orders are cancelable, but new orders cannot be created. + * `"post_only"` - existing orders are cancelable, and only new post limit orders can be submitted. + * `"limit_only"` - existing orders are cancelable, and only new limit orders can be submitted. + * `"maintenance"` - system is offline for maintenance. + * `"timestamp"` - ISO-8601 datetime. + + ## Example response: + + {:ok, %{"status" => "online", "timestamp" => "2021-03-05T16:04:53Z"}} + + """ + @spec system_status(Client.t()) :: Krakex.API.response() + def system_status(client \\ @api.public_client()) do + @api.public_request(client, "SystemStatus") + end + @doc """ Get asset info. diff --git a/test/krakex_test.exs b/test/krakex_test.exs index 6311871..da03d5b 100644 --- a/test/krakex_test.exs +++ b/test/krakex_test.exs @@ -12,6 +12,14 @@ defmodule KrakexTest do assert client() |> Krakex.server_time() == {:ok, :server_time_1} end + test "system_status/0" do + assert Krakex.system_status() == {:ok, :system_status_0} + end + + test "system_status/1" do + assert client() |> Krakex.system_status() == {:ok, :system_status_1} + end + test "assets/0" do assert Krakex.assets() == {:ok, :assets_0} end diff --git a/test/support/test_api.ex b/test/support/test_api.ex index e33a50a..0cc5eea 100644 --- a/test/support/test_api.ex +++ b/test/support/test_api.ex @@ -15,6 +15,8 @@ defmodule Krakex.TestAPI do def public_request(@public_client, "Time", []), do: {:ok, :server_time_0} def public_request(@custom_client, "Time", []), do: {:ok, :server_time_1} + def public_request(@public_client, "SystemStatus", []), do: {:ok, :system_status_0} + def public_request(@custom_client, "SystemStatus", []), do: {:ok, :system_status_1} def public_request(@public_client, "Assets", []), do: {:ok, :assets_0} def public_request(@custom_client, "Assets", []), do: {:ok, :assets_1_client} def public_request(@public_client, "Assets", asset: ["BTC"]), do: {:ok, :assets_1_opts}