unageanu / jiji2

Forex algorithmic trading framework using OANDA REST API.
http://jiji2.unageanu.net/
241 stars 53 forks source link

MARKET_IF_TOUCHED_ORDER_REJECT #507

Open pr0ndisk opened 5 years ago

pr0ndisk commented 5 years ago

下記のようなエラーメッセージが表示され、注文が通りません。

E, [2019-03-07T12:02:47.552307 #1] ERROR -- : An error as occured while processing response. Status 400 {"orderRejectTransaction":{"type":"MARKET_IF_TOUCHED_ORDER_REJECT","instrument":"USD_JPY","units":"300","price":"110.79999999999999","timeInForce":"GTC","triggerCondition":"DEFAULT","partialFill":"DEFAULT","positionFill":"DEFAULT","reason":"CLIENT_ORDER","rejectReason":"PRICE_PRECISION_EXCEEDED","id":"6864","accountID":"001-009-1939778-001","userID":1939778,"batchID":"6864","requestID":"78566986778195099","time":"2019-03-07T12:02:47.539716401Z"},"relatedTransactionIDs":["6864"],"lastTransactionID":"6864","errorMessage":"The price specified contains more precision than is allowed for the instrument","errorCode":"PRICE_PRECISION_EXCEEDED"} (OandaApiV20::RequestError) /usr/local/bundle/gems/oanda_api_v20-2.0.0/lib/oanda_api_v20/api.rb:59:in rescue in method_missing' /usr/local/bundle/gems/oanda_api_v20-2.0.0/lib/oanda_api_v20/api.rb:54:inmethod_missing' /app/jiji2/src/jiji/model/securities/internal/oanda/ordering.rb:21:in order' /app/jiji2/src/jiji/model/trading/brokers/abstract_broker.rb:190:inorder' /app/jiji2/src/jiji/model/trading/brokers/abstract_broker.rb:75:in buy' /app/jiji2/src/jiji/model/trading/brokers/broker_proxy.rb:33:inbuy' agent/USD.rb:229:in register_order' agent/USD.rb:122:inregister_order' agent/USD.rb:82:in block in register_orders' agent/USD.rb:102:inblock in each_traps' agent/USD.rb:99:in times' agent/USD.rb:99:ineach_traps' agent/USD.rb:80:in register_orders' agent/USD.rb:29:innext_tick' /app/jiji2/src/jiji/model/agents/agents.rb:35:in block in next_tick' /app/jiji2/src/jiji/model/agents/agents.rb:33:ineach' /app/jiji2/src/jiji/model/agents/agents.rb:33:in next_tick' /app/jiji2/src/jiji/model/trading/jobs/notify_next_tick_job.rb:15:inexec' /app/jiji2/src/jiji/model/trading/process.rb:35:in do_next_job' /app/jiji2/src/jiji/model/trading/process.rb:28:inrun' /app/jiji2/src/jiji/model/trading/process.rb:22:in block in start' /usr/local/bundle/gems/thread-0.2.2/lib/thread/pool.rb:67:inexecute' /usr/local/bundle/gems/thread-0.2.2/lib/thread/pool.rb:405:in block (2 levels) in spawn_thread' /usr/local/bundle/gems/thread-0.2.2/lib/thread/pool.rb:372:inloop' /usr/local/bundle/gems/thread-0.2.2/lib/thread/pool.rb:372:in `block in spawn_thread'

unageanu commented 5 years ago

PRICE_PRECISION_EXCEEDED ですので指値( "price":"110.79999999999999" )の桁数が多すぎるためエラーになっていると思われます。round 等を使用して桁数を調整してみてください。

pr0ndisk commented 5 years ago

http://jiji2.unageanu.net/usage/030400_trap_repeat_if_done_agent.html を特に触らずに使っています。 しばらく放置してたら、注文は通るようになりました。

pr0ndisk commented 5 years ago

注文は通るのですが、take profitの値が反映されないようです。

unageanu commented 5 years ago

なるほど、、、ご報告ありがとうございます。 OANDA API v20への移行の影響で take profit の指定方法が変わったのでその影響で動作しなくなっているようです。時間を見て修正しておきます。