Class: InvestTinkoff::V2::SandboxClient
- Inherits:
-
Client
- Object
- ClientBase
- Client
- InvestTinkoff::V2::SandboxClient
- Defined in:
- lib/invest_tinkoff/v2/sandbox_client.rb
Constant Summary
Constants inherited from Client
Instance Method Summary collapse
-
#cancel_sandbox_order(account_id:, order_id:) ⇒ Object
Метод отмены торгового поручения в песочнице.
-
#close_sandbox_account(account_id:) ⇒ Object
Метод закрытия счёта в песочнице.
-
#create_sandbox_order(account_id:, figi:, quantity:, price:, direction:, order_type:, order_id:) ⇒ Object
Метод выставления торгового поручения в песочнице.
-
#initialize(token:, logger: nil) ⇒ SandboxClient
constructor
A new instance of SandboxClient.
-
#open_sandbox_account ⇒ Object
Метод регистрации счёта в песочнице.
-
#sandbox_accounts ⇒ Object
Метод получения счетов в песочнице.
-
#sandbox_operations(account_id:, figi:, from:, to:, state: InvestTinkoff::V2::OperationState::UNSPECIFIED) ⇒ Object
Метод получения операций в песочнице по номеру счёта.
-
#sandbox_order_state(account_id:, order_id:) ⇒ Object
Метод получения статуса заявки в песочнице.
-
#sandbox_orders(account_id:) ⇒ Object
Метод получения списка активных заявок по счёту в песочнице.
-
#sandbox_pay_in(account_id:, amount:, currency:) ⇒ Object
Метод пополнения счёта в песочнице.
-
#sandbox_portfolio(account_id:) ⇒ Object
Метод получения портфолио в песочнице.
-
#sandbox_positions(account_id:) ⇒ Object
Метод получения позиций по виртуальному счёту песочницы.
Methods inherited from Client
#accounts, #accrued_interests, #asset_by, #assets, #bond_by, #bond_coupons, #bonds, #broker_report, #cancel_order, #cancel_stop_order, #candles, #create_order, #create_stop_order, #currencies, #currency_by, #dividends, #dividends_foreign_issuer, #edit_favorites, #etf_by, #etfs, #favorites, #future_by, #futures, #futures_margin, #info, #instrument_by, #last_prices, #last_trades, #margin_attributes, #operations, #order_book, #order_state, #orders, #portfolio, #positions, #share_by, #shares, #stop_orders, #trading_schedules, #trading_status, #user_tariff, #withdraw_limits
Constructor Details
#initialize(token:, logger: nil) ⇒ SandboxClient
Returns a new instance of SandboxClient.
4 5 6 7 8 9 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 4 def initialize token:, logger: nil super( token: token, logger: logger ) end |
Instance Method Details
#cancel_sandbox_order(account_id:, order_id:) ⇒ Object
Метод отмены торгового поручения в песочнице. tinkoff.github.io/investAPI/sandbox/#cancelsandboxorder
@account_id: String @order_id: String
20 21 22 23 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 20 def cancel_sandbox_order account_id:, order_id: body = { accountId: account_id, orderId: order_id } sandbox_request '/CancelSandboxOrder', body end |
#close_sandbox_account(account_id:) ⇒ Object
Метод закрытия счёта в песочнице. tinkoff.github.io/investAPI/sandbox/#closesandboxaccount
@account_id: String
29 30 31 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 29 def close_sandbox_account account_id: sandbox_request '/CloseSandboxAccount', { accountId: account_id } end |
#create_sandbox_order(account_id:, figi:, quantity:, price:, direction:, order_type:, order_id:) ⇒ Object
Метод выставления торгового поручения в песочнице. tinkoff.github.io/investAPI/sandbox/#postsandboxorder
@account_id: String @figi: String @quantity: Integer @price: Float @direction: InvestTinkoff::V2::OrderDirection @order_type: InvestTinkoff::V2::OrderType @order_id: String (max length 36)
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 108 def create_sandbox_order( # rubocop: disable Metrics/ParameterLists account_id:, figi:, quantity:, price:, direction:, order_type:, order_id: ) body = { accountId: account_id, figi: figi, quantity: quantity, price: InvestTinkoff::V2::Quotation.create(price), direction: direction, orderType: order_type, orderId: order_id } sandbox_request '/PostSandboxOrder', body end |
#open_sandbox_account ⇒ Object
Метод регистрации счёта в песочнице. tinkoff.github.io/investAPI/sandbox/#opensandboxaccount
94 95 96 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 94 def open_sandbox_account sandbox_request '/OpenSandboxAccount' end |
#sandbox_accounts ⇒ Object
Метод получения счетов в песочнице. tinkoff.github.io/investAPI/sandbox/#getsandboxaccounts
35 36 37 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 35 def sandbox_accounts sandbox_request '/GetSandboxAccounts' end |
#sandbox_operations(account_id:, figi:, from:, to:, state: InvestTinkoff::V2::OperationState::UNSPECIFIED) ⇒ Object
Метод получения операций в песочнице по номеру счёта. tinkoff.github.io/investAPI/sandbox/#getsandboxoperations
@account_id: String @figi: String, пример: ‘BBG000B9XRY4’ @from: Time @to: Time
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 47 def sandbox_operations account_id:, figi:, from:, to:, state: InvestTinkoff::V2::OperationState::UNSPECIFIED body = { accountId: account_id, figi: figi, from: from.strftime(TIME_FORMAT), to: to.strftime(TIME_FORMAT), state: state || InvestTinkoff::V2::OperationState::UNSPECIFIED } sandbox_request '/GetSandboxOperations', body end |
#sandbox_order_state(account_id:, order_id:) ⇒ Object
Метод получения статуса заявки в песочнице. tinkoff.github.io/investAPI/sandbox/#getsandboxorderstate
@account_id: String @order_id: String
63 64 65 66 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 63 def sandbox_order_state account_id:, order_id: body = { accountId: account_id, orderId: order_id } sandbox_request '/GetSandboxOrderState', body end |
#sandbox_orders(account_id:) ⇒ Object
Метод получения списка активных заявок по счёту в песочнице. tinkoff.github.io/investAPI/sandbox/#getsandboxorders
@account_id: String
72 73 74 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 72 def sandbox_orders account_id: sandbox_request '/GetSandboxOrders', { accountId: account_id } end |
#sandbox_pay_in(account_id:, amount:, currency:) ⇒ Object
Метод пополнения счёта в песочнице. tinkoff.github.io/investAPI/sandbox/#sandboxpayin
@account_id: String @amount: Float @currency: String, пример ‘RUB’, ‘USD’, ‘EUR’ и т.д.
135 136 137 138 139 140 141 142 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 135 def sandbox_pay_in account_id:, amount:, currency: body = { accountId: account_id, amount: InvestTinkoff::V2::Quotation.create(amount), currency: currency } sandbox_request '/SandboxPayIn', body end |
#sandbox_portfolio(account_id:) ⇒ Object
Метод получения портфолио в песочнице. tinkoff.github.io/investAPI/sandbox/#getsandboxportfolio
@account_id: String
80 81 82 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 80 def sandbox_portfolio account_id: sandbox_request '/GetSandboxPortfolio', { accountId: account_id } end |
#sandbox_positions(account_id:) ⇒ Object
Метод получения позиций по виртуальному счёту песочницы. tinkoff.github.io/investAPI/sandbox/#getsandboxpositions
@account_id: String
88 89 90 |
# File 'lib/invest_tinkoff/v2/sandbox_client.rb', line 88 def sandbox_positions account_id: sandbox_request '/GetSandboxPositions', { accountId: account_id } end |