class Darwinex::Api::TradingApi
Constants
- BASE_URI
Attributes
config[R]
Public Class Methods
new(config:, logger:)
click to toggle source
Calls superclass method
Darwinex::Api::Api::new
# File lib/darwinex/api/trading_api.rb, line 14 def initialize(config:, logger:) super(logger) @config = config end
Public Instance Methods
create_buy_order(account_id, buy_order)
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 51 def create_buy_order(account_id, buy_order) body = { body: buy_order.to_json } send('post', "/investoraccounts/#{account_id}/orders/buy", options.merge(body), max_retries: config.max_retries) end
create_conditional_order(account_id, conditional_order_dto)
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 19 def create_conditional_order(account_id, conditional_order_dto) body = { body: conditional_order_dto.to_json } send('post', "/investoraccounts/#{account_id}/conditionalorders", options.merge(body), max_retries: config.max_retries) end
create_product_stopout(account_id, product_name)
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 71 def create_product_stopout(account_id, product_name) send('post', "/investoraccounts/#{account_id}/stopout/#{product_name}", options, max_retries: config.max_retries) end
create_sell_order(account_id, sell_order)
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 59 def create_sell_order(account_id, sell_order) body = { body: sell_order.to_json } send('post', "/investoraccounts/#{account_id}/orders/sell", options.merge(body), max_retries: config.max_retries) end
create_stopout(account_id)
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 67 def create_stopout(account_id) send('post', "/investoraccounts/#{account_id}/stopout", options, max_retries: config.max_retries) end
delete_conditional_order(account_id, conditional_order_id)
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 35 def delete_conditional_order(account_id, conditional_order_id) send('delete', "/investoraccounts/#{account_id}/conditionalorders/#{conditional_order_id}", options, max_retries: config.max_retries) end
get_leverage(account_id)
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 39 def get_leverage(account_id) send('get', "/investoraccounts/#{account_id}/leverage", options, max_retries: config.max_retries) end
get_product_market_status()
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 75 def get_product_market_status send('get', '/productmarket/status', options, max_retries: config.max_retries) end
update_conditional_order(account_id, conditional_order_id, conditional_order_dto)
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 27 def update_conditional_order(account_id, conditional_order_id, conditional_order_dto) body = { body: conditional_order_dto.to_json } send('put', "/investoraccounts/#{account_id}/conditionalorders/#{conditional_order_id}", options.merge(body), max_retries: config.max_retries) end
update_leverage(account_id, leverage)
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 43 def update_leverage(account_id, leverage) body = { body: { leverage: leverage }.to_json } send('put', "/investoraccounts/#{account_id}/leverage", options.merge(body), max_retries: config.max_retries) end
Private Instance Methods
options()
click to toggle source
# File lib/darwinex/api/trading_api.rb, line 83 def options { headers: { Authorization: "Bearer #{config.access_token}", 'Content-Type' => 'application/json' } } end