ExGdax (ExGdax v0.2.0) View Source
GDAX API client.
Link to this section Summary
Functions
Cancel a previously placed order.
Cancel all open orders.
Close your position.
Place a new order.
Create a report.
Deposit funds from a coinbase account.
Deposit funds from a payment method.
Get an account.
Get an order.
Get a list of open orders for a product.
An overview of your profile.
Get report status.
Get 24 hr stats for a product.
Snapshot information about the last trade (tick), best bid/ask and 24h volume.
Get the API server time.
List activity for an account.
List accounts.
List your coinbase accounts.
List known currencies.
Get a list of recent fills.
List funding records.
Historic rates for a product.
Lists holds on an account for active orders or withdraw requests.
List open orders.
List your payment methods.
Get a list of available currency pairs for trading.
List the latest trades for a product.
List your 30-day trailing volume for all products.
Transfer funds between your standard/default profile and a margin profile.
Repay funding. Repays the older funding records first.
Get your current fee rate based on the 30-day trailing USD volume
Withdraw funds to a coinbase account.
Withdraw funds to a crypto address.
Withdraw funds to a payment method.
Link to this section Functions
Cancel a previously placed order.
Examples
iex> ExGdax.cancel_order("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
{:ok, ["XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"]}
Cancel all open orders.
Examples
iex> ExGdax.cancel_orders()
{:ok, ["XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"]}
Close your position.
Parameters
Name | Description |
---|---|
repay_only | Either true or false |
Place a new order.
Refer to params listed in GDAX API docs
Examples
iex> ExGdax.create_order(%{type: "limit", side: "buy", product_id: "ETH-USD", price: "0.50", size: "1.0"})
{:ok,
%{"created_at" => "2017-08-20T23:29:17.752637Z",
"executed_value" => "0.0000000000000000",
"fill_fees" => "0.0000000000000000", "filled_size" => "0.00000000",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "post_only" => false,
"price" => "0.50000000", "product_id" => "ETH-USD",
"settled" => false, "side" => "buy", "size" => "1.00000000",
"status" => "pending", "stp" => "dc", "time_in_force" => "GTC",
"type" => "limit"}}
Create a report.
Parameters
Name | Description |
---|---|
type | fills or account . |
start_date | Starting date for the report (inclusive). |
end_date | Ending date for the report (inclusive). |
product_id | ID of the product to generate a fills report for. E.g. BTC-USD. Required if type is fills . |
account_id | ID of the account to generate an account report for. Required if type is account . |
format | pdf or csv (defualt is pdf ). |
email | Email address to send the report to (optional). |
Deposit funds from a coinbase account.
Parameters
Name | Description |
---|---|
amount | The amount to deposit. |
currency | The type of currency. |
coinbase_account_id | ID of the coinbase account. |
Examples
iex> ExGdax.deposit_from_coinbase(%{amount: "0.1", currency: "ETH", coinbase_account_id: "XXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"})
{:ok,
%{"amount" => "0.10000000", "currency" => "ETH",
"id" => "XXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}}
Deposit funds from a payment method.
Parameters
Name | Description |
---|---|
amount | The amount to deposit. |
currency | The type of currency. |
payment_method_id | ID of the payment method. |
Get an account.
Examples
iex> ExGdax.get_account(account["id"])
{:ok,
%{"available" => "0.0000000000000000", "balance" => "0.0000000000000000",
"currency" => "USD", "hold" => "0.0000000000000000",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"profile_id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}}
Get an order.
Examples
iex> ExGdax.get_order(order["id"])
{:ok,
%{"created_at" => "2017-08-20T23:31:49.235409Z",
"executed_value" => "0.0000000000000000",
"fill_fees" => "0.0000000000000000", "filled_size" => "0.00000000",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "post_only" => true,
"price" => "0.75000000", "product_id" => "ETH-USD",
"settled" => false, "side" => "buy", "size" => "1.00000000",
"status" => "open", "stp" => "dc", "time_in_force" => "GTC",
"type" => "limit"}}
Get a list of open orders for a product.
Parameters
Name | Description |
---|---|
level | Response detail. Valid options are 1, 2, or 3. |
Examples
iex> ExGdax.get_order_book("ETH-USD")
{:ok,
%{"asks" => [["200.42", "28.447359", 4]],
"bids" => [["200.41", "11.35615248", 3]], "sequence" => 873754533}}
iex> ExGdax.order_book("ETH-USD", %{level: 2})
{:ok,
%{"asks" => [["200.49", "73.898254", 6], ["200.5", "1.017412", 2],
["200.51", "0.017366", 1], ["200.52", "0.017387", 1], ...],
"bids" => [["200.48", "0.7", 2], ["200.47", "0.01", 1],
["200.42", "0.76212582", 1], ["200.32", "0.2", 1], ...]}
An overview of your profile.
Examples
iex> ExGdax.get_position()
{:ok,
%{"accounts" => %{"BTC" => %{"balance" => "0.0000000000000000",
"default_amount" => "0", "funded_amount" => "0",
"hold" => "0.0000000000000000",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"},
"ETH" => %{"balance" => "0.0000000000000000", "default_amount" => "0",
"funded_amount" => "0", "hold" => "0.0000000000000000",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"},
"LTC" => %{"balance" => "0.0000000000000000", "default_amount" => "0",
"funded_amount" => "0", "hold" => "0.0000000000000000",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"},
"USD" => %{"balance" => "0.0000000000000000", "default_amount" => "0",
"funded_amount" => "0", "hold" => "0.0000000000000000",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}},
"profile_id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "status" => "active",
"user_id" => "XXXXXXXXXXXXXXXXXXXXXXXX"}}
Get report status.
Get 24 hr stats for a product.
Examples
iex> ExGdax.get_stats("ETH-USD")
{:ok,
%{"high" => "205.80000000", "last" => "201.68000000", "low" => "194.42000000",
"open" => "197.97000000", "volume" => "143965.79255890",
"volume_30day" => "9270459.77394214"}}
Snapshot information about the last trade (tick), best bid/ask and 24h volume.
Examples
iex> ExGdax.get_ticker("ETH-USD")
{:ok,
%{"ask" => "200.47", "bid" => "200.46", "price" => "200.47000000",
"size" => "2.65064800", "time" => "2017-07-27T08:00:43.697000Z",
"trade_id" => 8430635, "volume" => "144080.88916080"}}
Get the API server time.
Examples
iex> EcGdax.get_time()
{:ok, %{"epoch" => 1501141821.835, "iso" => "2017-07-27T07:50:21.835Z"}}
List activity for an account.
Parameters
Name | Description |
---|---|
before | Request page before (newer) this pagination id. |
after | Request page after (older) this pagination id. |
limit | Number of results per request. Maximum 100. (default 100) |
Examples
iex> ExGdax.list_account_history(account["id"], %{limit: 5})
{:ok,
[%{"amount" => "0.0000000000000000", "balance" => "0.0000000000000000",
"created_at" => "2017-07-08T15:26:17.04917Z",
"details" => %{"transfer_id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"transfer_type" => "withdraw"}, "id" => XXXXXXXX, "type" => "transfer"}, ...]}
List accounts.
Examples
iex> ExGdax.list_accounts()
{:ok,
[%{"available" => "0.0000000000000000", "balance" => "0.0000000000000000",
"currency" => "USD", "hold" => "0.0000000000000000",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"profile_id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}, ...]}
List your coinbase accounts.
Examples
iex> ExGdax.list_coinbase_accounts()
{:ok,
[%{"active" => true, "balance" => "0.00000000", "currency" => "ETH",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "name" => "ETH Wallet",
"primary" => false, "type" => "wallet"}, ...]}
List known currencies.
Examples
iex> ExGdax.list_currencies()
{:ok,
[%{"id" => "BTC", "min_size" => "0.00000001", "name" => "Bitcoin"},
%{"id" => "ETH", "min_size" => "0.00000001", "name" => "Ether"}, ...]}
Get a list of recent fills.
Parameters
Name | Description |
---|---|
order_id | Limit list of fills to this order_id. |
product_id | Limit list of fills to this product_id. |
before | Request page before (newer) this pagination id. |
after | Request page after (older) this pagination id. |
limit | Number of results per request. Maximum 100. (default 100) |
Examples
iex> ExGdax.list_fills(%{product_id: "ETH-USD", limit: 1})
{:ok,
[%{"created_at" => "2017-08-12T21:25:43.453Z",
"fee" => "0.0000000000000000", "liquidity" => "M",
"order_id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"price" => "305.00000000", "product_id" => "ETH-USD",
"profile_id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"settled" => true, "side" => "buy", "size" => "0.29000000",
"trade_id" => XXXXXXX, "user_id" => "XXXXXXXXXXXXXXXXXXXXXXX"}]}
List funding records.
Parameters
Name | Options | Description |
---|---|---|
status | outstanding, settled, or rejected | Limit list of funding records to these statuses. |
before | Request page before (newer) this pagination id. | |
after | Request page after (older) this pagination id. | |
limit | Number of results per request. Maximum 100. (default 100) |
Historic rates for a product.
Parameters
Name | Description |
---|---|
start | Start time in ISO 8601. |
end | End time in ISO 8601. |
granularity | Desired timeslice in seconds. |
Examples
iex> ExGdax.list_historic_rates("ETH-USD")
{:ok,
[[1501142880, 200.43, 200.43, 200.43, 200.43, 5.6956], ...]}
Lists holds on an account for active orders or withdraw requests.
Parameters
Name | Description |
---|---|
before | Request page before (newer) this pagination id. |
after | Request page after (older) this pagination id. |
limit | Number of results per request. Maximum 100. (default 100) |
Examples
iex> ExGdax.list_holds(account["id"])
{:ok, []}
List open orders.
Parameters
Name | Default | Description |
---|---|---|
status | [open, pending, active] | Limit list of orders to these statuses. |
product_id | Only list orders for a specific product. | |
before | Request page before (newer) this pagination id. | |
after | Request page after (older) this pagination id. | |
limit | Number of results per request. Maximum 100. (default 100) |
Examples
iex> ExGdax.list_orders(%{status: "open"})
{:ok,
[%{"created_at" => "2017-08-20T23:31:49.235409Z",
"executed_value" => "0.0000000000000000",
"fill_fees" => "0.0000000000000000", "filled_size" => "0.00000000",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "post_only" => true,
"price" => "0.75000000", "product_id" => "ETH-USD",
"settled" => false, "side" => "buy", "size" => "1.00000000",
"status" => "open", "stp" => "dc", "time_in_force" => "GTC",
"type" => "limit"}]}
List your payment methods.
Examples
iex> ExGdax.list_payment_methods()
{:ok,
[%{"allow_buy" => false, "allow_deposit" => true, "allow_sell" => true,
"allow_withdraw" => false, "created_at" => "2015-11-03T00:32:02Z",
"currency" => "USD",
"fiat_account" => %{"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"resource" => "account",
"resource_path" => "/v2/accounts/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}, ...]}
Get a list of available currency pairs for trading.
Examples
iex> ExGdax.list_products()
{:ok,
[%{"base_currency" => "ETH", "base_max_size" => "5000",
"base_min_size" => "0.01", "display_name" => "ETH/USD", "id" => "ETH-USD",
"margin_enabled" => false, "quote_currency" => "USD",
"quote_increment" => "0.01"}, ...]}
List the latest trades for a product.
Parameters
Name | Description |
---|---|
before | Request page before (newer) this pagination id. |
after | Request page after (older) this pagination id. |
limit | Number of results per request. Maximum 100. (default 100) |
Examples
iex> ExGdax.list_trades("ETH-USD")
{:ok,
[%{"price" => "200.65000000", "side" => "sell", "size" => "1.94831509",
"time" => "2017-07-27T08:01:54.347Z", "trade_id" => 8430778}, ...]
List your 30-day trailing volume for all products.
Examples
iex> ExGdax.list_trailing_volume()
{:ok,
[%{"exchange_volume" => "8704829.60943332", "product_id" => "ETH-USD",
"recorded_at" => "2017-07-31T00:17:16.331884Z", "volume" => "1.00000000"}]}
Transfer funds between your standard/default profile and a margin profile.
Parameters
Name | Description |
---|---|
margin_profile_id | The id of the margin profile you’d like to deposit to or withdraw from. |
type | deposit or withdraw . |
currency | The currency to transfer, ex: BTC or USD . |
amount | The amount to transfer between the default and margin profile. |
Repay funding. Repays the older funding records first.
Parameters
Name | Description |
---|---|
amount | Amount of currency to repay. |
currency | The currency, example USD . |
Get your current fee rate based on the 30-day trailing USD volume
iex> ExGdax.user_fee_rate() {:ok, %{"fee" => "0.0030", "usd_volume" => nil, "fee_usd_total" => nil}}
Withdraw funds to a coinbase account.
Parameters
Name | Description |
---|---|
amount | The amount to withdraw. |
currency | The type of currency. |
coinbase_account_id | ID of the coinbase account. |
Withdraw funds to a crypto address.
Parameters
Name | Description |
---|---|
amount | The amount to withdraw. |
currency | The type of currency. |
crypto_address | A crypto address of the recipient. |
Examples
iex> ExGdax.withdraw_to_crypto(%{amount: "0.01", currency: "ETH", crypto_address: "0x30a9f8b57e2dcb519a4e4982ed6379f9dd6a0bfc"})
{:ok,
%{"amount" => "0.01000000", "currency" => "ETH",
"id" => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}}
Withdraw funds to a payment method.
Parameters
Name | Description |
---|---|
amount | The amount to withdraw. |
currency | The type of currency. |
payment_method_id | ID of the payment method. |