Class: InvestTinkoff::V1::SandboxClient

Inherits:
Client show all
Defined in:
lib/invest_tinkoff/v1/sandbox_client.rb

Constant Summary

Constants inherited from Client

Client::CANDLES_INTERVALS, Client::TIME_FORMAT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Client

#market_bonds, #market_candles, #market_currencies, #market_etfs, #market_orderbook, #market_search_by_figi, #market_search_by_ticker, #market_stocks, #operations, #orders, #orders_cancel, #orders_limit_order, #orders_market_order, #portfolio, #portfolio_currencies, #user_accounts

Constructor Details

#initialize(token:, broker_account_id: nil, logger: nil) ⇒ SandboxClient



11
12
13
14
15
16
17
18
# File 'lib/invest_tinkoff/v1/sandbox_client.rb', line 11

def initialize token:, broker_account_id: nil, logger: nil
  super(
    token: token,
    broker_account_id: ,
    logger: logger
  )
  @is_sandbox_created = false
end

Instance Attribute Details

#broker_account_idObject

Returns the value of attribute broker_account_id.



6
7
8
# File 'lib/invest_tinkoff/v1/sandbox_client.rb', line 6

def 
  
end

Instance Method Details

#clearObject

Удаление всех позиций клиента



52
53
54
55
# File 'lib/invest_tinkoff/v1/sandbox_client.rb', line 52

def clear
  register
  post_api_request '/sandbox/clear'
end

#currencies_balance(currency:, balance:) ⇒ Object

Выставление баланса по валютным позициям



36
37
38
39
40
# File 'lib/invest_tinkoff/v1/sandbox_client.rb', line 36

def currencies_balance currency:, balance:
  register
  body = { currency: currency, balance: balance }
  post_api_request '/sandbox/currencies/balance', body: body
end

#position_balance(figi:, balance:) ⇒ Object

Выставление баланса по инструментным позициям



45
46
47
48
49
# File 'lib/invest_tinkoff/v1/sandbox_client.rb', line 45

def position_balance figi:, balance:
  register
  body = { figi: figi, balance: balance }
  post_api_request '/sandbox/positions/balance', body: body
end

#registerObject

Создание счета и выставление баланса по валютным позициям



25
26
27
28
29
30
31
# File 'lib/invest_tinkoff/v1/sandbox_client.rb', line 25

def register
  return if @is_sandbox_created

  res = post_api_request '/sandbox/register'
  @is_sandbox_created = true
  res
end

#removeObject

Удаление счета клиента



58
59
60
61
# File 'lib/invest_tinkoff/v1/sandbox_client.rb', line 58

def remove
  register
  post_api_request '/sandbox/remove'
end