Current section
5 Versions
Jump to
Current section
5 Versions
Compare versions
9
files changed
+277
additions
-248
deletions
| @@ -4,12 +4,11 @@ | |
| 4 4 | <<"HTTP Request & Response Server. An incomplete clone of https://api-public.sandbox.pro.coinbase.com for mocking (testing) purposes">>}. |
| 5 5 | {<<"elixir">>,<<"~> 1.11">>}. |
| 6 6 | {<<"files">>, |
| 7 | - [<<"lib">>,<<"lib/accounts_handler.ex">>, |
| 7 | + [<<"lib">>,<<"lib/handlers">>,<<"lib/handlers/accounts.ex">>, |
| 8 | + <<"lib/handlers/products.ex">>,<<"lib/handlers/orders.ex">>, |
| 8 9 | <<"lib/coinbase_pro_http_mock_server">>, |
| 9 10 | <<"lib/coinbase_pro_http_mock_server/router.ex">>, |
| 10 | - <<"lib/coinbase_pro_http_mock_server/products_handler.ex">>, |
| 11 | - <<"lib/coinbase_pro_http_mock_server/application.ex">>, |
| 12 | - <<"lib/coinbase_pro_http_mock_server.ex">>,<<".formatter.exs">>, |
| 11 | + <<"lib/coinbase_pro_http_mock_server/application.ex">>,<<".formatter.exs">>, |
| 13 12 | <<"mix.exs">>,<<"README.md">>]}. |
| 14 13 | {<<"licenses">>,[<<"MIT">>]}. |
| 15 14 | {<<"links">>, |
| @@ -36,4 +35,4 @@ | |
| 36 35 | {<<"optional">>,false}, |
| 37 36 | {<<"repository">>,<<"hexpm">>}, |
| 38 37 | {<<"requirement">>,<<"~> 2.0">>}]]}. |
| 39 | - {<<"version">>,<<"0.1.3">>}. |
| 38 | + {<<"version">>,<<"0.1.4">>}. |
| @@ -1,82 +0,0 @@ | |
| 1 | - defmodule CoinbaseProHttpMockServer.AccountsHandler do |
| 2 | - @moduledoc """ |
| 3 | - /accounts rest endpoints |
| 4 | - """ |
| 5 | - def accounts do |
| 6 | - [ |
| 7 | - %{ |
| 8 | - "available" => "0", |
| 9 | - "balance" => "0.0000000000000000", |
| 10 | - "currency" => "BAT", |
| 11 | - "hold" => "0.0000000000000000", |
| 12 | - "id" => "5e85456a-5114-4081-ae3d-f01806d8d887", |
| 13 | - "profile_id" => "eed226e5-aef2-4825-b3bb-2bfeb2d154d2", |
| 14 | - "trading_enabled" => true |
| 15 | - }, |
| 16 | - %{ |
| 17 | - "available" => "0", |
| 18 | - "balance" => "0.0000000000000000", |
| 19 | - "currency" => "BTC", |
| 20 | - "hold" => "0.0000000000000000", |
| 21 | - "id" => "fccc62c0-2ef1-4a76-80e1-4df10826a4bc", |
| 22 | - "profile_id" => "eed226e5-aef2-4825-b3bb-2bfeb2d154d2", |
| 23 | - "trading_enabled" => true |
| 24 | - }, |
| 25 | - %{ |
| 26 | - "available" => "0", |
| 27 | - "balance" => "0.0000000000000000", |
| 28 | - "currency" => "ETH", |
| 29 | - "hold" => "0.0000000000000000", |
| 30 | - "id" => "de804e2f-e41b-47dd-ad36-e487da861f1d", |
| 31 | - "profile_id" => "eed226e5-aef2-4825-b3bb-2bfeb2d154d2", |
| 32 | - "trading_enabled" => true |
| 33 | - }, |
| 34 | - %{ |
| 35 | - "available" => "0", |
| 36 | - "balance" => "0.0000000000000000", |
| 37 | - "currency" => "EUR", |
| 38 | - "hold" => "0.0000000000000000", |
| 39 | - "id" => "189ea2ef-2800-44b5-8940-ccdd55c22889", |
| 40 | - "profile_id" => "eed226e5-aef2-4825-b3bb-2bfeb2d154d2", |
| 41 | - "trading_enabled" => true |
| 42 | - }, |
| 43 | - %{ |
| 44 | - "available" => "0", |
| 45 | - "balance" => "0.0000000000000000", |
| 46 | - "currency" => "GBP", |
| 47 | - "hold" => "0.0000000000000000", |
| 48 | - "id" => "ad460a02-78b3-46c1-9852-b1ee5c9a6120", |
| 49 | - "profile_id" => "eed226e5-aef2-4825-b3bb-2bfeb2d154d2", |
| 50 | - "trading_enabled" => true |
| 51 | - }, |
| 52 | - %{ |
| 53 | - "available" => "0", |
| 54 | - "balance" => "0.0000000000000000", |
| 55 | - "currency" => "LINK", |
| 56 | - "hold" => "0.0000000000000000", |
| 57 | - "id" => "c43f1ec3-43c8-4c86-8b8a-cb38e8ab697d", |
| 58 | - "profile_id" => "eed226e5-aef2-4825-b3bb-2bfeb2d154d2", |
| 59 | - "trading_enabled" => true |
| 60 | - }, |
| 61 | - %{ |
| 62 | - "available" => "0", |
| 63 | - "balance" => "0.0000000000000000", |
| 64 | - "currency" => "USD", |
| 65 | - "hold" => "0.0000000000000000", |
| 66 | - "id" => "b4ec1757-ff55-4dc8-9f22-dc3e8d2f3894", |
| 67 | - "profile_id" => "eed226e5-aef2-4825-b3bb-2bfeb2d154d2", |
| 68 | - "trading_enabled" => true |
| 69 | - }, |
| 70 | - %{ |
| 71 | - "available" => "0", |
| 72 | - "balance" => "0.0000000000000000", |
| 73 | - "currency" => "USDC", |
| 74 | - "hold" => "0.0000000000000000", |
| 75 | - "id" => "f807caae-c283-4470-8da6-3b785a4984f1", |
| 76 | - "profile_id" => "eed226e5-aef2-4825-b3bb-2bfeb2d154d2", |
| 77 | - "trading_enabled" => true |
| 78 | - } |
| 79 | - ] |
| 80 | - |> JSX.encode!() |
| 81 | - end |
| 82 | - end |
| @@ -1,2 +0,0 @@ | |
| 1 | - defmodule CoinbaseProHttpMockServer do |
| 2 | - end |
| @@ -1,155 +0,0 @@ | |
| 1 | - defmodule CoinbaseProHttpMockServer.ProductsHandler do |
| 2 | - @moduledoc """ |
| 3 | - /products rest endpoints |
| 4 | - """ |
| 5 | - def products do |
| 6 | - [ |
| 7 | - %{ |
| 8 | - id: "LINK-USDC", |
| 9 | - base_currency: "LINK", |
| 10 | - quote_currency: "USDC", |
| 11 | - base_min_size: "1", |
| 12 | - base_max_size: "800000", |
| 13 | - quote_increment: "0.000001", |
| 14 | - base_increment: "1", |
| 15 | - display_name: "LINK/USDC", |
| 16 | - min_market_funds: "10", |
| 17 | - max_market_funds: "100000", |
| 18 | - margin_enabled: false, |
| 19 | - post_only: false, |
| 20 | - limit_only: false, |
| 21 | - cancel_only: false, |
| 22 | - trading_disabled: false, |
| 23 | - status: "online", |
| 24 | - status_message: "" |
| 25 | - }, |
| 26 | - %{ |
| 27 | - id: "BAT-USDC", |
| 28 | - base_currency: "BAT", |
| 29 | - quote_currency: "USDC", |
| 30 | - base_min_size: "1", |
| 31 | - base_max_size: "300000", |
| 32 | - quote_increment: "0.000001", |
| 33 | - base_increment: "0.000001", |
| 34 | - display_name: "BAT/USDC", |
| 35 | - min_market_funds: "1", |
| 36 | - max_market_funds: "100000", |
| 37 | - margin_enabled: false, |
| 38 | - post_only: false, |
| 39 | - limit_only: false, |
| 40 | - cancel_only: false, |
| 41 | - trading_disabled: false, |
| 42 | - status: "online", |
| 43 | - status_message: "" |
| 44 | - }, |
| 45 | - %{ |
| 46 | - id: "LINK-USD", |
| 47 | - base_currency: "LINK", |
| 48 | - quote_currency: "USD", |
| 49 | - base_min_size: "1", |
| 50 | - base_max_size: "800000", |
| 51 | - quote_increment: "0.000001", |
| 52 | - base_increment: "1", |
| 53 | - display_name: "LINK/USD", |
| 54 | - min_market_funds: "10", |
| 55 | - max_market_funds: "100000", |
| 56 | - margin_enabled: false, |
| 57 | - post_only: false, |
| 58 | - limit_only: false, |
| 59 | - cancel_only: false, |
| 60 | - trading_disabled: false, |
| 61 | - status: "online", |
| 62 | - status_message: "" |
| 63 | - }, |
| 64 | - %{ |
| 65 | - id: "BTC-USD", |
| 66 | - base_currency: "BTC", |
| 67 | - quote_currency: "USD", |
| 68 | - base_min_size: "0.001", |
| 69 | - base_max_size: "10000", |
| 70 | - quote_increment: "0.01", |
| 71 | - base_increment: "0.00000001", |
| 72 | - display_name: "BTC/USD", |
| 73 | - min_market_funds: "10", |
| 74 | - max_market_funds: "1000000", |
| 75 | - margin_enabled: true, |
| 76 | - post_only: false, |
| 77 | - limit_only: false, |
| 78 | - cancel_only: false, |
| 79 | - trading_disabled: false, |
| 80 | - status: "online", |
| 81 | - status_message: "" |
| 82 | - }, |
| 83 | - %{ |
| 84 | - id: "BTC-EUR", |
| 85 | - base_currency: "BTC", |
| 86 | - quote_currency: "EUR", |
| 87 | - base_min_size: "0.001", |
| 88 | - base_max_size: "10000", |
| 89 | - quote_increment: "0.01", |
| 90 | - base_increment: "0.00000001", |
| 91 | - display_name: "BTC/EUR", |
| 92 | - min_market_funds: "10", |
| 93 | - max_market_funds: "600000", |
| 94 | - margin_enabled: false, |
| 95 | - post_only: false, |
| 96 | - limit_only: false, |
| 97 | - cancel_only: false, |
| 98 | - trading_disabled: false, |
| 99 | - status: "online", |
| 100 | - status_message: "" |
| 101 | - }, |
| 102 | - %{ |
| 103 | - id: "ETH-BTC", |
| 104 | - base_currency: "ETH", |
| 105 | - quote_currency: "BTC", |
| 106 | - base_min_size: "0.01", |
| 107 | - base_max_size: "1000000", |
| 108 | - quote_increment: "0.00001", |
| 109 | - base_increment: "0.00000001", |
| 110 | - display_name: "ETH/BTC", |
| 111 | - min_market_funds: "0.001", |
| 112 | - max_market_funds: "80", |
| 113 | - margin_enabled: false, |
| 114 | - post_only: false, |
| 115 | - limit_only: false, |
| 116 | - cancel_only: false, |
| 117 | - trading_disabled: false, |
| 118 | - status: "online", |
| 119 | - status_message: "" |
| 120 | - }, |
| 121 | - %{ |
| 122 | - id: "BTC-GBP", |
| 123 | - base_currency: "BTC", |
| 124 | - quote_currency: "GBP", |
| 125 | - base_min_size: "0.001", |
| 126 | - base_max_size: "10000", |
| 127 | - quote_increment: "0.01", |
| 128 | - base_increment: "0.00000001", |
| 129 | - display_name: "BTC/GBP", |
| 130 | - min_market_funds: "10", |
| 131 | - max_market_funds: "200000", |
| 132 | - margin_enabled: false, |
| 133 | - post_only: false, |
| 134 | - limit_only: false, |
| 135 | - cancel_only: false, |
| 136 | - trading_disabled: false, |
| 137 | - status: "online", |
| 138 | - status_message: "" |
| 139 | - } |
| 140 | - ] |
| 141 | - |> JSX.encode!() |
| 142 | - end |
| 143 | - |
| 144 | - def btc_eur_stats do |
| 145 | - %{ |
| 146 | - "high" => "30265.29", |
| 147 | - "last" => "29943.53", |
| 148 | - "low" => "29715.1", |
| 149 | - "open" => "29733.45", |
| 150 | - "volume" => "17.00318652", |
| 151 | - "volume_30day" => "15131.56489343" |
| 152 | - } |
| 153 | - |> JSX.encode!() |
| 154 | - end |
| 155 | - end |
| @@ -1,19 +1,27 @@ | |
| 1 1 | defmodule CoinbaseProHttpMockServer.Router do |
| 2 2 | use Plug.Router |
| 3 3 | |
| 4 | + alias CoinbaseProHttpMockServer.Handlers.Accounts |
| 5 | + alias CoinbaseProHttpMockServer.Handlers.Products |
| 6 | + alias CoinbaseProHttpMockServer.Handlers.Orders |
| 7 | + |
| 4 8 | plug(:match) |
| 5 9 | plug(:dispatch) |
| 6 10 | |
| 7 11 | get "/products" do |
| 8 | - send_resp(conn, 200, CoinbaseProHttpMockServer.ProductsHandler.products()) |
| 12 | + send_resp(conn, 200, Products.products()) |
| 9 13 | end |
| 10 14 | |
| 11 15 | get "/products/BTC-EUR/stats" do |
| 12 | - send_resp(conn, 200, CoinbaseProHttpMockServer.ProductsHandler.btc_eur_stats()) |
| 16 | + send_resp(conn, 200, Products.btc_eur_stats()) |
| 13 17 | end |
| 14 18 | |
| 15 19 | get "/accounts" do |
| 16 | - send_resp(conn, 200, CoinbaseProHttpMockServer.AccountsHandler.accounts()) |
| 20 | + send_resp(conn, 200, Accounts.accounts()) |
| 21 | + end |
| 22 | + |
| 23 | + post "/orders" do |
| 24 | + send_resp(conn, 200, Orders.order()) |
| 17 25 | end |
| 18 26 | |
| 19 27 | match _ do |
Loading more files…