diff --git a/fixture/vcr_cassettes/order_limit_buy_immediate_or_cancel_success.json b/fixture/vcr_cassettes/order_limit_buy_immediate_or_cancel_success.json new file mode 100644 index 0000000..244cdb3 --- /dev/null +++ b/fixture/vcr_cassettes/order_limit_buy_immediate_or_cancel_success.json @@ -0,0 +1,41 @@ +[ + { + "request": { + "body": "price=0.01&quantity=0.1&recvWindow=1000&side=BUY&symbol=LTCBTC&timeInForce=IOC×tamp=1527291300666&type=LIMIT&signature=***", + "headers": { + "X-MBX-APIKEY": "***" + }, + "method": "post", + "options": [], + "request_body": "", + "url": "https://api.binance.com/api/v3/order" + }, + "response": { + "binary": false, + "body": "{\"symbol\":\"LTCBTC\",\"orderId\":47528830,\"clientOrderId\":\"zyMyhtRENlvFHrl4CitDe0\",\"transactTime\":1527291300912,\"price\":\"0.01000000\",\"origQty\":\"0.10000000\",\"executedQty\":\"0.00000000\",\"status\":\"EXPIRED\",\"timeInForce\":\"IOC\",\"type\":\"LIMIT\",\"side\":\"BUY\"}", + "headers": { + "Content-Type": "application/json", + "Transfer-Encoding": "chunked", + "Connection": "keep-alive", + "Date": "Fri, 25 May 2018 23:35:00 GMT", + "Server": "nginx", + "Vary": "Accept-Encoding", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains", + "X-Frame-Options": "SAMEORIGIN", + "X-Xss-Protection": "1; mode=block", + "X-Content-Type-Options": "nosniff", + "Content-Security-Policy": "default-src 'self'", + "X-Content-Security-Policy": "default-src 'self'", + "X-WebKit-CSP": "default-src 'self'", + "Cache-Control": "no-cache, no-store, must-revalidate", + "Pragma": "no-cache", + "Expires": "0", + "X-Cache": "Miss from cloudfront", + "Via": "1.1 fb1574d5a6ba2d77d2a656aba08aa3c3.cloudfront.net (CloudFront)", + "X-Amz-Cf-Id": "7FpRejCpXjYssWLkFBBSqvrIlcQQUmXaFGh4q1eFUpiWvRc91Ipo2g==" + }, + "status_code": 200, + "type": "ok" + } + } +] \ No newline at end of file diff --git a/fixture/vcr_cassettes/order_limit_sell_immediate_or_cancel_success.json b/fixture/vcr_cassettes/order_limit_sell_immediate_or_cancel_success.json new file mode 100644 index 0000000..0b140b2 --- /dev/null +++ b/fixture/vcr_cassettes/order_limit_sell_immediate_or_cancel_success.json @@ -0,0 +1,41 @@ +[ + { + "request": { + "body": "price=50000&quantity=0.001&recvWindow=1000&side=SELL&symbol=BTCUSDT&timeInForce=IOC×tamp=1527291410866&type=LIMIT&signature=***", + "headers": { + "X-MBX-APIKEY": "***" + }, + "method": "post", + "options": [], + "request_body": "", + "url": "https://api.binance.com/api/v3/order" + }, + "response": { + "binary": false, + "body": "{\"symbol\":\"BTCUSDT\",\"orderId\":108279070,\"clientOrderId\":\"roSkLhwX9KCgYqr4yFPx1V\",\"transactTime\":1527291411088,\"price\":\"50000.00000000\",\"origQty\":\"0.00100000\",\"executedQty\":\"0.00000000\",\"status\":\"EXPIRED\",\"timeInForce\":\"IOC\",\"type\":\"LIMIT\",\"side\":\"SELL\"}", + "headers": { + "Content-Type": "application/json", + "Transfer-Encoding": "chunked", + "Connection": "keep-alive", + "Date": "Fri, 25 May 2018 23:36:51 GMT", + "Server": "nginx", + "Vary": "Accept-Encoding", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains", + "X-Frame-Options": "SAMEORIGIN", + "X-Xss-Protection": "1; mode=block", + "X-Content-Type-Options": "nosniff", + "Content-Security-Policy": "default-src 'self'", + "X-Content-Security-Policy": "default-src 'self'", + "X-WebKit-CSP": "default-src 'self'", + "Cache-Control": "no-cache, no-store, must-revalidate", + "Pragma": "no-cache", + "Expires": "0", + "X-Cache": "Miss from cloudfront", + "Via": "1.1 51f2e50a0d2a5ee1d9c830bf417b2713.cloudfront.net (CloudFront)", + "X-Amz-Cf-Id": "BX8-X-VXYRrjfwPJ8H-Gx4sgVhcoBDZ7WlOiWn-u0SWuW2h0e5Rhpw==" + }, + "status_code": 200, + "type": "ok" + } + } +] \ No newline at end of file diff --git a/test/binance_test.exs b/test/binance_test.exs index 785c382..b95c5a0 100644 --- a/test/binance_test.exs +++ b/test/binance_test.exs @@ -126,6 +126,25 @@ defmodule BinanceTest do assert response.type == "LIMIT" end end + + test "can create an order with am immediate or cancel duration" do + use_cassette "order_limit_buy_immediate_or_cancel_success" do + assert {:ok, %Binance.OrderResponse{} = response} = + Binance.order_limit_buy("LTCBTC", 0.1, 0.01, "IOC") + + assert response.client_order_id == "zyMyhtRENlvFHrl4CitDe0" + assert response.executed_qty == "0.00000000" + assert response.order_id == 47_528_830 + assert response.orig_qty == "0.10000000" + assert response.price == "0.01000000" + assert response.side == "BUY" + assert response.status == "EXPIRED" + assert response.symbol == "LTCBTC" + assert response.time_in_force == "IOC" + assert response.transact_time == 1_527_291_300_912 + assert response.type == "LIMIT" + end + end end describe ".order_limit_sell" do @@ -166,5 +185,24 @@ defmodule BinanceTest do assert response.type == "LIMIT" end end + + test "can create an order with am immediate or cancel duration" do + use_cassette "order_limit_sell_immediate_or_cancel_success" do + assert {:ok, %Binance.OrderResponse{} = response} = + Binance.order_limit_sell("BTCUSDT", 0.001, 50_000, "IOC") + + assert response.client_order_id == "roSkLhwX9KCgYqr4yFPx1V" + assert response.executed_qty == "0.00000000" + assert response.order_id == 108_279_070 + assert response.orig_qty == "0.00100000" + assert response.price == "50000.00000000" + assert response.side == "SELL" + assert response.status == "EXPIRED" + assert response.symbol == "BTCUSDT" + assert response.time_in_force == "IOC" + assert response.transact_time == 1_527_291_411_088 + assert response.type == "LIMIT" + end + end end end