API/Bitfinex/板情報(注文一覧)を取得する(API v1)(PowerShell)
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* BitfinexのOrderbook APIをPowerShellで取得する(API v1) [...
PowerShellでBitfinexの板情報(注文一覧)を取得する操作例を...
#contents
#htmlinsert(cc-top.html)
* 参考資料 [#uf0624fe]
BitfinexのOrderbook APIドキュメントURL~
Orderbook API仕様は、以下のURLで確認してください。~
https://bitfinex.readme.io/v1/reference#rest-public-order...
* 関連記事 [#l03a6798]
-[[Bitfinexの通貨シンボル一覧の取得(API v1)(PowerShell)>A...
-[[BitfinexのTickerの取得(API v1)(PowerShell)>API/Bitfine...
-[[Bitfinexで指定した通貨ペアの取引量を取得する(API v1)(P...
-[[Bitfinexのファンディング情報を取得する(API v1)(PowerSh...
-[[Bitfinexの板情報(注文一覧)を取得する(API v1)(PowerShel...
* ブラウザでアクセスしてみる [#x6f332db]
以下、URLで板情報(注文一覧)を取得できます。~
-BTC/USD~
https://api.bitfinex.com/v1/book/btcusd~
Firefoxでアクセスした時のスクリーンショットです。~
|''JSON''|
|&ref(01.png);|
|''生データ''|
|&ref(02.png);|
''通貨シンボル一覧(通貨ペア一覧)''については、以下のリン...
-[[Bitfinexの通貨シンボル一覧の取得(API v1)(PowerShell)>A...
* PowerShellによるOrderbook API呼び出しの操作例 [#m9e86ba4]
PowerShellの''Invoke-RestMethod''コマンドレットと、~
''Invoke-WebRequest''+''ConvertFrom-Json''コマンドレット...
Bitfinexの板情報(注文一覧)を取得してみます。
** ''Invoke-RestMethod''コマンドレットでOrderbookを取得し...
''Invoke-RestMethod''コマンドレットを使用して、Bitfinexの...
以下の操作例は、''ETH/BTC''の通貨ペアを取得しています。~
''通貨シンボル一覧(通貨ペア一覧)''については、以下のリン...
-[[Bitfinexの通貨シンボル一覧の取得(API v1)(PowerShell)>A...
+Orderbook APIを呼び出し板情報(注文一覧)を取得する
PS C:\> $v1_orderbook_api = "https://api.bitfinex.com/v1...
PS C:\> $symbol = "ethbtc"
PS C:\> $orderbook = Invoke-RestMethod -UseBasicParsing ...
PS C:\> $orderbook
bids
----
{@{price=0.068902; amount=29.67674981; timestamp=1531439...
+asksの情報数を確認
PS C:\> $orderbook.bids.Count
25
+asksの情報数を確認
PS C:\> $orderbook.asks.Count
25
+bidsの1番目を表示する
PS C:\> $orderbook.bids[0]
price amount timestamp
----- ------ ---------
0.068902 29.67674981 1531439501.0
+asksの1番目を表示する
PS C:\> $orderbook.asks[0]
price amount timestamp
----- ------ ---------
0.068903 0.00000632 1531439501.0
Orderbook APIのパラメータを指定して実行した例を以下に記し...
指定できるパラメータは以下のようになっています。(bitfinex...
|''Key''|''Required''|''Type''|''Default''|''Description''|
|limit_bids|false|[int]|50|Limit the number of bids retur...
|limit_asks|false|[int]|50|Limit the number of asks retur...
|group|false|[0/1]|1|If 1, orders are grouped by price in...
以下の操作例は、''XRP/USD''の通貨ペアを取得しています。~
+limit_bids, limit_asksに2を指定して実行してみます。
PS C:\> $v1_orderbook_api = "https://api.bitfinex.com/v1...
PS C:\> $symbol = "xrpusd"
PS C:\> $limit_bids = 2
PS C:\> $limit_asks = 2
PS C:\> $orderbook = Invoke-RestMethod -UseBasicParsing ...
PS C:\> $orderbook
bids ...
---- ...
{@{price=0.43691; amount=31830.683; timestamp=1531440140...
+bids, asksの取得件数と取得内容を表示しています。
PS C:\> $orderbook.bids.Count
2
PS C:\> $orderbook.asks.Count
2
PS C:\> $orderbook.bids
price amount timestamp
----- ------ ---------
0.43691 31830.683 1531440140.0
0.43678 22 1531440140.0
PS C:\> $orderbook.asks
price amount timestamp
----- ------ ---------
0.43698 10199.9999592 1531440140.0
0.43727 3540.06244959 1531440140.0
+groupを指定してみます。
+group=1を指定した操作例です。
PS C:\> $group = 1
PS C:\> $orderbook = Invoke-RestMethod -UseBasicParsing ...
PS C:\> $orderbook.bids | Select-Object -First 10
price amount timestamp
----- ------ ---------
0.43722 5000 1531440480.0
0.43706 2367.60426413 1531440480.0
0.43694 826.2 1531440480.0
0.43693 142.28 1531440480.0
0.43689 22 1531440480.0
0.43668 5199.87000324 1531440480.0
0.43667 4269.75738489 1531440480.0
0.43666 484 1531440480.0
0.43663 4937.93 1531440480.0
0.4366 1200 1531440480.0
+group=0を指定した操作例です。
PS C:\> $group = 0
PS C:\> $orderbook = Invoke-RestMethod -UseBasicParsing ...
PS C:\> $orderbook.bids | Select-Object -First 10
price amount timestamp
----- ------ ---------
0.43722 5000 1531440491.0
0.43693 826.2 1531440491.0
0.43693 650 1531440491.0
0.4369 5199.87000324 1531440491.0
0.43689 22 1531440491.0
0.43685 142.28 1531440491.0
0.43685 2303.17109746 1531440491.0
0.43676 45674 1531440491.0
0.43674 52858 1531440491.0
0.43668 4269.78165981 1531440491.0
** ''Invoke-WebRequest''+''ConvertFrom-Json''コマンドレッ...
''Invoke-WebRequest''使うことにより、HTTPステータスや、Co...
取得したContent部分を''ConvertFrom-Json''コマンドレットを...
JSON形式でアクセスすることができます。
+ Invoke-WebRequestでOrderbook APIをアクセス
PS C:\> $btcusd_book_url = "https://api.bitfinex.com/v1/...
PS C:\> $response = Invoke-WebRequest -UseBasicParsing $...
+ 取得したレスポンスを表示します。
PS C:\> $response
StatusCode : 200
StatusDescription : OK
Content : {"bids":[{"price":"6229.3","amount":...
,{"price":"6229","amount":"4.56","ti...
RawContent : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN,SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-...
Forms :
Headers : {[Transfer-Encoding, chunked], [Conn...
Images : {}
InputFields : {}
Links : {}
ParsedHtml :
RawContentLength : 3186
+ステータスコード、HTTP Header, Content-Typeなどの値にア...
PS C:\> $response.StatusCode
200
PS C:\> $response.Headers
Key Value
--- -----
Transfer-Encoding chunked
Connection keep-alive
Vary Accept-Encoding
X-Frame-Options SAMEORIGIN,SAMEORIGIN
X-XSS-Protection 1; mode=block
X-Content-Type-Options nosniff
X-Request-Id 6aa3d30a-da97-4d40-8181-bf11e5...
X-Runtime 0.010887
Strict-Transport-Security max-age=31536000
Expect-CT max-age=604800, report-uri="ht...
CF-RAY 4397877f4feb9427-NRT
Cache-Control max-age=0, private, must-reval...
Content-Type application/json; charset=utf-8
Date Fri, 13 Jul 2018 00:10:55 GMT
ETag W/"b788bc4945a619cf64929682034...
Set-Cookie __cfduid=d13699a975ffee3990b7e...
Server cloudflare
PS C:\> $response.Headers.'Content-Type'
application/json; charset=utf-8
+ ConvertFrom-Jsonコマンドレットを使うことにより、JSON形...
PS C:\> $json = ConvertFrom-Json $response.Content
PS C:\> $json
bids
----
{@{price=6229.3; amount=19.62830209; timestamp=153144065...
* Webの応答を読み取っています。(Waiting for response)を非...
上記のコマンドレットを実行すると、APIサーバとのやり取りの...
#ref(51.png)
これを非表示にしたい場合は、以下のようにしてください。
非表示にするには、$ProgressPreferenceにSilentlyContinueを...
変更前は以下のように Continue が設定されています。
PS C:\> $ProgressPreference
Continue
非表示にするには、以下のように変更します。
PS C:\> $ProgressPreference = "SilentlyContinue"
以上、PowerShellを使って、BitfinexのOrderbook APIを呼び出...
#htmlinsert(cc-btm.html)
終了行:
#navi(../)
* BitfinexのOrderbook APIをPowerShellで取得する(API v1) [...
PowerShellでBitfinexの板情報(注文一覧)を取得する操作例を...
#contents
#htmlinsert(cc-top.html)
* 参考資料 [#uf0624fe]
BitfinexのOrderbook APIドキュメントURL~
Orderbook API仕様は、以下のURLで確認してください。~
https://bitfinex.readme.io/v1/reference#rest-public-order...
* 関連記事 [#l03a6798]
-[[Bitfinexの通貨シンボル一覧の取得(API v1)(PowerShell)>A...
-[[BitfinexのTickerの取得(API v1)(PowerShell)>API/Bitfine...
-[[Bitfinexで指定した通貨ペアの取引量を取得する(API v1)(P...
-[[Bitfinexのファンディング情報を取得する(API v1)(PowerSh...
-[[Bitfinexの板情報(注文一覧)を取得する(API v1)(PowerShel...
* ブラウザでアクセスしてみる [#x6f332db]
以下、URLで板情報(注文一覧)を取得できます。~
-BTC/USD~
https://api.bitfinex.com/v1/book/btcusd~
Firefoxでアクセスした時のスクリーンショットです。~
|''JSON''|
|&ref(01.png);|
|''生データ''|
|&ref(02.png);|
''通貨シンボル一覧(通貨ペア一覧)''については、以下のリン...
-[[Bitfinexの通貨シンボル一覧の取得(API v1)(PowerShell)>A...
* PowerShellによるOrderbook API呼び出しの操作例 [#m9e86ba4]
PowerShellの''Invoke-RestMethod''コマンドレットと、~
''Invoke-WebRequest''+''ConvertFrom-Json''コマンドレット...
Bitfinexの板情報(注文一覧)を取得してみます。
** ''Invoke-RestMethod''コマンドレットでOrderbookを取得し...
''Invoke-RestMethod''コマンドレットを使用して、Bitfinexの...
以下の操作例は、''ETH/BTC''の通貨ペアを取得しています。~
''通貨シンボル一覧(通貨ペア一覧)''については、以下のリン...
-[[Bitfinexの通貨シンボル一覧の取得(API v1)(PowerShell)>A...
+Orderbook APIを呼び出し板情報(注文一覧)を取得する
PS C:\> $v1_orderbook_api = "https://api.bitfinex.com/v1...
PS C:\> $symbol = "ethbtc"
PS C:\> $orderbook = Invoke-RestMethod -UseBasicParsing ...
PS C:\> $orderbook
bids
----
{@{price=0.068902; amount=29.67674981; timestamp=1531439...
+asksの情報数を確認
PS C:\> $orderbook.bids.Count
25
+asksの情報数を確認
PS C:\> $orderbook.asks.Count
25
+bidsの1番目を表示する
PS C:\> $orderbook.bids[0]
price amount timestamp
----- ------ ---------
0.068902 29.67674981 1531439501.0
+asksの1番目を表示する
PS C:\> $orderbook.asks[0]
price amount timestamp
----- ------ ---------
0.068903 0.00000632 1531439501.0
Orderbook APIのパラメータを指定して実行した例を以下に記し...
指定できるパラメータは以下のようになっています。(bitfinex...
|''Key''|''Required''|''Type''|''Default''|''Description''|
|limit_bids|false|[int]|50|Limit the number of bids retur...
|limit_asks|false|[int]|50|Limit the number of asks retur...
|group|false|[0/1]|1|If 1, orders are grouped by price in...
以下の操作例は、''XRP/USD''の通貨ペアを取得しています。~
+limit_bids, limit_asksに2を指定して実行してみます。
PS C:\> $v1_orderbook_api = "https://api.bitfinex.com/v1...
PS C:\> $symbol = "xrpusd"
PS C:\> $limit_bids = 2
PS C:\> $limit_asks = 2
PS C:\> $orderbook = Invoke-RestMethod -UseBasicParsing ...
PS C:\> $orderbook
bids ...
---- ...
{@{price=0.43691; amount=31830.683; timestamp=1531440140...
+bids, asksの取得件数と取得内容を表示しています。
PS C:\> $orderbook.bids.Count
2
PS C:\> $orderbook.asks.Count
2
PS C:\> $orderbook.bids
price amount timestamp
----- ------ ---------
0.43691 31830.683 1531440140.0
0.43678 22 1531440140.0
PS C:\> $orderbook.asks
price amount timestamp
----- ------ ---------
0.43698 10199.9999592 1531440140.0
0.43727 3540.06244959 1531440140.0
+groupを指定してみます。
+group=1を指定した操作例です。
PS C:\> $group = 1
PS C:\> $orderbook = Invoke-RestMethod -UseBasicParsing ...
PS C:\> $orderbook.bids | Select-Object -First 10
price amount timestamp
----- ------ ---------
0.43722 5000 1531440480.0
0.43706 2367.60426413 1531440480.0
0.43694 826.2 1531440480.0
0.43693 142.28 1531440480.0
0.43689 22 1531440480.0
0.43668 5199.87000324 1531440480.0
0.43667 4269.75738489 1531440480.0
0.43666 484 1531440480.0
0.43663 4937.93 1531440480.0
0.4366 1200 1531440480.0
+group=0を指定した操作例です。
PS C:\> $group = 0
PS C:\> $orderbook = Invoke-RestMethod -UseBasicParsing ...
PS C:\> $orderbook.bids | Select-Object -First 10
price amount timestamp
----- ------ ---------
0.43722 5000 1531440491.0
0.43693 826.2 1531440491.0
0.43693 650 1531440491.0
0.4369 5199.87000324 1531440491.0
0.43689 22 1531440491.0
0.43685 142.28 1531440491.0
0.43685 2303.17109746 1531440491.0
0.43676 45674 1531440491.0
0.43674 52858 1531440491.0
0.43668 4269.78165981 1531440491.0
** ''Invoke-WebRequest''+''ConvertFrom-Json''コマンドレッ...
''Invoke-WebRequest''使うことにより、HTTPステータスや、Co...
取得したContent部分を''ConvertFrom-Json''コマンドレットを...
JSON形式でアクセスすることができます。
+ Invoke-WebRequestでOrderbook APIをアクセス
PS C:\> $btcusd_book_url = "https://api.bitfinex.com/v1/...
PS C:\> $response = Invoke-WebRequest -UseBasicParsing $...
+ 取得したレスポンスを表示します。
PS C:\> $response
StatusCode : 200
StatusDescription : OK
Content : {"bids":[{"price":"6229.3","amount":...
,{"price":"6229","amount":"4.56","ti...
RawContent : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN,SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-...
Forms :
Headers : {[Transfer-Encoding, chunked], [Conn...
Images : {}
InputFields : {}
Links : {}
ParsedHtml :
RawContentLength : 3186
+ステータスコード、HTTP Header, Content-Typeなどの値にア...
PS C:\> $response.StatusCode
200
PS C:\> $response.Headers
Key Value
--- -----
Transfer-Encoding chunked
Connection keep-alive
Vary Accept-Encoding
X-Frame-Options SAMEORIGIN,SAMEORIGIN
X-XSS-Protection 1; mode=block
X-Content-Type-Options nosniff
X-Request-Id 6aa3d30a-da97-4d40-8181-bf11e5...
X-Runtime 0.010887
Strict-Transport-Security max-age=31536000
Expect-CT max-age=604800, report-uri="ht...
CF-RAY 4397877f4feb9427-NRT
Cache-Control max-age=0, private, must-reval...
Content-Type application/json; charset=utf-8
Date Fri, 13 Jul 2018 00:10:55 GMT
ETag W/"b788bc4945a619cf64929682034...
Set-Cookie __cfduid=d13699a975ffee3990b7e...
Server cloudflare
PS C:\> $response.Headers.'Content-Type'
application/json; charset=utf-8
+ ConvertFrom-Jsonコマンドレットを使うことにより、JSON形...
PS C:\> $json = ConvertFrom-Json $response.Content
PS C:\> $json
bids
----
{@{price=6229.3; amount=19.62830209; timestamp=153144065...
* Webの応答を読み取っています。(Waiting for response)を非...
上記のコマンドレットを実行すると、APIサーバとのやり取りの...
#ref(51.png)
これを非表示にしたい場合は、以下のようにしてください。
非表示にするには、$ProgressPreferenceにSilentlyContinueを...
変更前は以下のように Continue が設定されています。
PS C:\> $ProgressPreference
Continue
非表示にするには、以下のように変更します。
PS C:\> $ProgressPreference = "SilentlyContinue"
以上、PowerShellを使って、BitfinexのOrderbook APIを呼び出...
#htmlinsert(cc-btm.html)
ページ名: