é常注æã®ãã£ã³ã»ã«æ©è½ãå®è£
é常注æã®ãã£ã³ã»ã«æ©è½ãå®è£
ãã¾ããã
âGithub - unageanu / clickclient_scrap
ã¾ãã注æAPIã®æ»ãå¤ã¨ãã¦æ³¨æçªå·ãè¿ãå¦çãå®è£
ãã¾ããã注æâ(è¿ããã注æçªå·ãå¼æ°ã¨ãã¦)注æããã£ã³ã»ã«ããå¯è½ã§ãããªããé常注æ以å¤ã®æ³¨æ(æãè¡ã/OCO注æ..etc..)ã®ãã£ã³ã»ã«ã«ã¯æªå¯¾å¿ã§ãã
ãµã³ãã«
以ä¸ã¯ãæå¤ã»éæå¤ã§æ³¨æãè¡ããå³åº§ã«ãã£ã³ã»ã«ãããµã³ãã«ã§ãã
$: << "../lib" require 'clickclient_scrap' require 'constants' # ãã°ã¤ã³ c = ClickClient::Client.new c.fx_session( USER, PASS ) {|session| # ã¬ã¼ããåå¾ rates = session.list_rates rates.each_pair {|k,v| puts "#{k} : #{v.bid_rate} : #{v.ask_rate} : #{v.sell_swap} : #{v.buy_swap}" } order_ids = [] ## æå¤æ³¨æ order_ids << session.order( ClickClient::FX::EURJPY, ClickClient::FX::BUY, 1, { :rate=>rates[ClickClient::FX::EURJPY].ask_rate - 0.5, # æå¤ã¬ã¼ã :execution_expression=>ClickClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER, # å·è¡æ¡ä»¶: æå¤ :expiration_type=>ClickClient::FX::EXPIRATION_TYPE_TODAY # æå¹æé: å½æ¥éã }) order_ids << session.order( ClickClient::FX::EURJPY, ClickClient::FX::SELL, 1, { :rate=>rates[ClickClient::FX::EURJPY].ask_rate + 0.5, # æå¤ã¬ã¼ã :execution_expression=>ClickClient::FX::EXECUTION_EXPRESSION_LIMIT_ORDER, # å·è¡æ¡ä»¶: æå¤ :expiration_type=>ClickClient::FX::EXPIRATION_TYPE_WEEK_END # æå¹æé: é±æ«ã¾ã§ }) # éæå¤æ³¨æ order_ids << session.order( ClickClient::FX::EURJPY, ClickClient::FX::BUY, 1, { :rate=>rates[ClickClient::FX::EURJPY].ask_rate + 0.5, # éæå¤ã¬ã¼ã :execution_expression=>ClickClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER, # å·è¡æ¡ä»¶: éæå¤ :expiration_type=>ClickClient::FX::EXPIRATION_TYPE_INFINITY # æå¹æé: ç¡é }) order_ids << session.order( ClickClient::FX::EURJPY, ClickClient::FX::SELL, 1, { :rate=>rates[ClickClient::FX::EURJPY].ask_rate - 0.5, # éæå¤ã¬ã¼ã :execution_expression=>ClickClient::FX::EXECUTION_EXPRESSION_REVERSE_LIMIT_ORDER, # å·è¡æ¡ä»¶: éæå¤ :expiration_type=>ClickClient::FX::EXPIRATION_TYPE_SPECIFIED, # æå¹æé: æå® :expiration_date=>Date.today+2 # 2æ¥å¾ }) # 注æä¸è¦§ãåå¾ orders = session.list_orders orders.each_pair {|k,v| puts <<-STR --- order_no : #{v.order_no} trade_type : #{v.trade_type} order_type : #{v.order_type} execution_expression : #{v.execution_expression} sell_or_buy : #{v.sell_or_buy} pair : #{v.pair} count : #{v.count} rate : #{v.rate} order_state : #{v.order_state} STR } # ãã¹ã¦ã®æ³¨æããã£ã³ã»ã« order_ids.each{|id| session.cancel_order(id.order_no) } }
å®è¡çµæã§ãã
EURCHF : 1.5062 : 1.5066 : -7 : 4 CHFJPY : 88.5 : 88.53 : -10 : 7 GBPCHF : 1.6747 : 1.6752 : -8 : 2 USDJPY : 97.98 : 97.99 : -22 : 18 ZARJPY : 11.75 : 11.79 : -270 : 240 USDCHF : 1.1068 : 1.1071 : -6 : 3 GBPJPY : 148.25 : 148.28 : -37 : 31 EURUSD : 1.3608 : 1.361 : -17 : 14 EURJPY : 133.33 : 133.35 : -31 : 27 AUDJPY : 74.96 : 74.98 : -54 : 50 GBPUSD : 1.513 : 1.5133 : 6 : -9 NZDJPY : 59.37 : 59.41 : -31 : 27 AUDUSD : 0.765 : 0.7654 : -46 : 43 CADJPY : 85.12 : 85.15 : -15 : 11 --- order_no : 10047354533 trade_type : æ°è¦ order_type : 21 execution_expression : æå¤ sell_or_buy : 1 pair : EURJPY count : 1 rate : 133.75 order_state : åæ¶æ¸ --- order_no : 10047358010 trade_type : æ°è¦ order_type : 01 execution_expression : éæå¤ sell_or_buy : 0 pair : EURJPY count : 1 rate : 133.85 order_state : åä»æ¸ --- order_no : 10047357993 trade_type : æ°è¦ order_type : 01 execution_expression : æå¤ sell_or_buy : 1 pair : EURJPY count : 1 rate : 133.85 order_state : åä»æ¸ --- order_no : 10047357983 trade_type : æ°è¦ order_type : 01 execution_expression : æå¤ sell_or_buy : 0 pair : EURJPY count : 1 rate : 132.85 order_state : åä»æ¸ --- order_no : 10047358025 trade_type : æ°è¦ order_type : 01 execution_expression : éæå¤ sell_or_buy : 1 pair : EURJPY count : 1 rate : 132.85 order_state : åä»æ¸
ãã¦ãä¹
ã
ã«clickclient_scrapã®ã³ã¼ãã«è§¦ã£ãããã§ãããWWW::Mechanizeã®ä½¿ãæ¹ããã£ããå¿ãã¦ãã¾ã£ã¦ããã»ã»ãorzããªãããªãå¿
è¦ã§ããªã¼ã