OANDA fx Trade API ã使ã£ã¦ããªã¢ã«ã¿ã¤ã ãªçºæ¿ã¬ã¼ããåå¾ãã¦ã¿ã
ä»ããã§ãããOANDA Japan ãã FXãã¬ã¼ãAPI ãæä¾ããã¦ããã®ãçºè¦ã
- ã¬ã¼ãæ å ±ã®åå¾ãããåå¼ã建çæ å ±ã®åå¾ãªã©ã®FX åå¼ã«å¿ è¦ãªAPIä¸å¼ãæä¾ããã¦ãã¾ãã
- åæè²»ç¨ãæé¡å©ç¨æéã¯ç¡æããã ããå£åº§æ®é«ã25ä¸å以ä¸å¿ è¦ã§ãã
- æ¬ç©ã®å£åº§ã使ãLiveç°å¢ã®ã»ãããã¢å£åº§ã®ã¢ã«ã¦ã³ãã§ä½¿ãã Practiceãã¢ã«ã¦ã³ããªãã§è©¦ããSandboxç°å¢ãæä¾ã
- REST APIã®ä»ãJava/FIXçã®APIãæãã
æ©è½ãããªãå
å®ãã¦ã¾ããæ¬æ ¼çãªãã¬ã¼ãã¢ããªãä½ããããããªãããªã
- REST APIã ãã©ãã¹ããªã¼ãã³ã°ã§ã®ã¬ã¼ããã¼ã¿é
ä¿¡ã«å¯¾å¿
- Transfer-Encoding: chunked ã§é ä¿¡ããä»çµã¿ã§ããã¼ãªã³ã°ãªãã§ãªã¢ã«ã¿ã¤ã ãªã¬ã¼ããã¼ã¿ãåå¾ã§ãã¾ãã
- OAuth 2.0ã§ã®èªè¨¼ã«å¯¾å¿
- ãµã¼ããã¼ãã£ã®ãµã¼ãã¹ã«ãã¢ã«ã¦ã³ã/ãã¹ã¯ã¼ãã渡ããã¨ãªãREST APIã¸ã®ã¢ã¯ã»ã¹ãã¼ã¯ã³ãå®å ¨ã«æ¸¡ããã¨ãå¯è½ã
- ãªã®ã§ãã¯ã©ã¦ãåã®Webãµã¼ãã¹ãä½ã£ãããããããã¨ã
- ãã ããAPIããåå¾ããæ å ±ã®åé ä¿¡ã¯ç¦æ¢ããã¦ããã®ã§ã注æã
- ãã¹ã¦ã®GET APIã ETag ã«å¯¾å¿ãã¦ãããªã©ãç´°ããã¨ããã®å®æ度ãé«ãã
ã¨ãããã¨ã§ãRubyã使ã£ã¦REST APIã«ã¢ã¯ã»ã¹ãããªã¢ã«ã¿ã¤ã ãªçºæ¿ã¬ã¼ããåå¾ãã¦ã¿ããµã³ãã«ãæ¸ãã¦ã¿ã¾ããã(ã¨ãã£ã¦ããå ¬éããã¦ããã¢ã¯ã»ã¹ã©ã¤ãã©ãªã®ãµã³ãã«ãåããã¦ã¿ãã ãã§ããã»ã»ã»)
ã¢ã¯ã»ã¹ã©ã¤ãã©ãªã®ã¤ã³ã¹ãã¼ã«
Rubyã ã¨REST APIã®ã¢ã¯ã»ã¹ã©ã¤ãã©ãªãå ¬éããã¦ããã®ã§ããããå©ç¨ãã¾ãã gemã§ã¤ã³ã¹ãã¼ã«ã
$ gem install oanda_api
ãã¢å£åº§ã®ã¢ã«ã¦ã³ãã使ã£ã¦ãç¾å¨ä¾¡æ ¼ãå¾ããµã³ãã«ã³ã¼ãã§ãã ã<ã¢ã¯ã»ã¹ãã¼ã¯ã³>ãã®ã¨ããã«ã¯ãOANDAã®ãµã¤ãããåå¾ããã¢ã¯ã»ã¹ãã¼ã¯ã³ãæå®ãã¾ããåå¾æ¹æ³ã¯ãã¡ãã
require 'oanda_api' client = OandaAPI::Client::TokenClient.new(:practice, <ã¢ã¯ã»ã¹ãã¼ã¯ã³>) prices = client.prices(instruments: ['EUR_USD','USD_JPY']).get prices.each do |p| puts "#{p.instrument} #{p.ask} #{p.bid} #{p.time}" end
å®è¡çµæã§ãã
$ retrieve_price.rb EUR_USD 1.1201 1.11994 2015-05-11 00:22:16 UTC USD_JPY 119.744 119.728 2015-05-11 00:21:43 UTC
ãã£ãããªã®ã§ãã¹ããªã¼ãã³ã°APIã§ãªã¢ã«ã¿ã¤ã ãªã¬ã¼ãæ å ±ã®åå¾ããã£ã¦ã¿ã¾ãã
require 'oanda_api' access_token = <ã¢ã¯ã»ã¹ãã¼ã¯ã³> # ã¢ã«ã¦ã³ãã®IDãå¿ è¦ãªã®ã§åå¾ãã¦ããã client = OandaAPI::Client::TokenClient.new(:practice, access_token ) account = client.accounts.get.first # ã¹ããªã¼ãã³ã°APIç¨ã®ã¯ã©ã¤ã¢ã³ããå¥éä½æããå®è¡ streaming_client = OandaAPI::Streaming::Client.new(:practice, access_token ) prices = streaming_client.prices(account_id: account.account_id, instruments: ["USD_JPY"]) prices.stream do |p| # â»ç¡éã«ã¼ãããã®ã§ Ctrl+Cã§åæ¢ãããã¨ã puts "#{p.instrument} #{p.ask} #{p.bid} #{p.time}" end
å®è¡ãã¦ã¿ã¾ããæ¾ç½®ããã¨ãã£ã¨æ´æ°ãç¶ããã®ã§ãCtrl+Cã§åæ¢ãããã¨ã
$ ruby retrieve_price_uses_streaming_api.rb USD_JPY 119.747 119.743 2015-05-11 00:37:52 UTC USD_JPY 119.748 119.744 2015-05-11 00:38:12 UTC USD_JPY 119.749 119.745 2015-05-11 00:38:12 UTC USD_JPY 119.75 119.746 2015-05-11 00:38:12 UTC ...
Jiji2ã®ããã¯ã¨ã³ããããã«ç§»è¡ããª
Jiji2絶è³éçºä¸ã§ããã
ããã¯ã¨ã³ã㯠OANDA fx trade API ã«å¤æ´ããªãã¨èãã¦ãã¾ãã æ§ãã¼ã¸ã§ã³ã¨åããã¹ã¯ã¬ã¤ãã³ã°ã使ãæ¹åã§èãã¦ãã¾ãããã次ã®ãããªãªã¹ã¯ã¯ã©ããã¦ãæ®ãã®ã§ã
- (ã¢ã¯ã»ã¹é »åº¦ã¯ãã¡ããæããã«ãã¦ã)ãã¯ã証å¸ä¼ç¤¾ã®ãµã¼ãã¹ã«å¤å°ã¯è² è·ããããã®ã§ãå©ç¨ç¦æ¢ã«ãªãå¯è½æ§ãããã
- ãµã¤ãã®ä»æ§å¤æ´ã§çªç¶åä½ããªããªããªã¹ã¯ãããã
ã¢ããªéçºè ã¨ãã¦ã¯ãç¹å®ã®è¨¼å¸ä¼ç¤¾ã«ããã¯ãªã³ãã¦ãã¾ãã®ã¯é¿ãããã¨ããã§ã¯ããã®ã§ããã®ãããªAPIãæä¾ãã¦ããã証å¸ä¼ç¤¾ããã£ã¨å¢ãã¦ããã¨ãããªã(ã¯ãªãã¯è¨¼å¸ãä½ã§ãããããã»ã»ã»ã)
追è¨(2015-12-01)
OANDA FX trade APIãå©ç¨ãããç¡æã®FXã·ã¹ãã ãã¬ã¼ããã¬ã¼ã ã¯ã¼ã¯ãJijiãããªãªã¼ã¹ãã¾ãã!
使ã£ã¦ã¿ã¦ããæè¦ãªã©é ããã¨ããããã§ãã