invest_tinkoff 0.9.4 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/invest_tinkoff/v1/sandbox_client.rb +7 -5
- data/lib/invest_tinkoff/v2/client.rb +22 -23
- data/lib/invest_tinkoff/v2/stop_order_type.rb +16 -0
- data/lib/invest_tinkoff/version.rb +1 -1
- data/lib/invest_tinkoff.rb +2 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00e69167837b73c8cbb7fd0c586c4778779f2a3d94bfe50956f3d96ad65f3d34
|
4
|
+
data.tar.gz: 6baf1aca501d384cdf3fc41149ad678deaaaec43fd95bd6e236c802d087757a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbd93d0cd195dc327f665eb01cd26c72fd14882401fc267433178b24deac5a08afb1ec6160e444afe512ca19da9112f43a7e3faf9c0f4318b5bf27c918e73f81
|
7
|
+
data.tar.gz: 60ccfee7c2ce4a2a12775dadf96fdeb4d4297cf38afa5b3a18107e893d6785cd49ecff385aab2d148962266367d0d0db497f0bc4705f1994156f2d7d4bd90724
|
@@ -5,9 +5,9 @@ class InvestTinkoff::V1::SandboxClient < InvestTinkoff::V1::Client
|
|
5
5
|
|
6
6
|
attr_accessor :broker_account_id
|
7
7
|
|
8
|
-
# token
|
9
|
-
# broker_account_id
|
10
|
-
# logger
|
8
|
+
# @param token [String] sandbox API token
|
9
|
+
# @param broker_account_id [String] optional идентификатор счета
|
10
|
+
# @param logger [Object] optional например: Rails.logger
|
11
11
|
def initialize token:, broker_account_id: nil, logger: nil
|
12
12
|
super(
|
13
13
|
token: token,
|
@@ -31,7 +31,8 @@ class InvestTinkoff::V1::SandboxClient < InvestTinkoff::V1::Client
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# Выставление баланса по валютным позициям
|
34
|
-
#
|
34
|
+
# @param currency [String] :RUB, :USD, :EUR и т.д.
|
35
|
+
# @param balance [Float] баланс
|
35
36
|
def currencies_balance currency:, balance:
|
36
37
|
register
|
37
38
|
body = { currency: currency, balance: balance }
|
@@ -39,7 +40,8 @@ class InvestTinkoff::V1::SandboxClient < InvestTinkoff::V1::Client
|
|
39
40
|
end
|
40
41
|
|
41
42
|
# Выставление баланса по инструментным позициям
|
42
|
-
# Пример figi: 'BBG000B9XRY4'
|
43
|
+
# @param figi [String] Пример figi: 'BBG000B9XRY4'
|
44
|
+
# @param balance [Float] баланс
|
43
45
|
def position_balance figi:, balance:
|
44
46
|
register
|
45
47
|
body = { figi: figi, balance: balance }
|
@@ -431,34 +431,33 @@ class InvestTinkoff::V2::Client < InvestTinkoff::ClientBase
|
|
431
431
|
|
432
432
|
# Метод выставления стоп-заявки.
|
433
433
|
# https://tinkoff.github.io/investAPI/stoporders/#poststoporder
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
# }
|
434
|
+
#
|
435
|
+
# @account_id: String
|
436
|
+
# @figi: String, пример: 'BBG000B9XRY4'
|
437
|
+
# @quantity: Integer
|
438
|
+
# @price: Float
|
439
|
+
# @stop_price: Float
|
440
|
+
# @expiration_type: InvestTinkoff::V2::StopOrderExpirationType
|
441
|
+
# @stop_order_type: InvestTinkoff::V2::StopOrderType
|
442
|
+
def create_stop_order(
|
443
|
+
account_id:,
|
444
|
+
figi:,
|
445
|
+
quantity:,
|
446
|
+
price:,
|
447
|
+
stop_price:,
|
448
|
+
expiration_type: InvestTinkoff::V2::StopOrderExpirationType::UNSPECIFIED,
|
449
|
+
stop_order_type: InvestTinkoff::V2::StopOrderType::UNSPECIFIED,
|
450
|
+
expire_date:
|
451
|
+
)
|
453
452
|
body = {
|
453
|
+
accountId: account_id,
|
454
454
|
figi: figi,
|
455
455
|
quantity: quantity,
|
456
456
|
price: InvestTinkoff::V2::Quotation.create(price),
|
457
457
|
stopPrice: InvestTinkoff::V2::Quotation.create(stop_price),
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
# ...
|
458
|
+
expirationType: (expiration_type || StopOrderExpirationType::UNSPECIFIED),
|
459
|
+
stop_order_type: (stop_order_type || InvestTinkoff::V2::StopOrderType::UNSPECIFIED),
|
460
|
+
expire_date: expire_date.strftime(TIME_FORMAT)
|
462
461
|
}
|
463
462
|
stop_order_request '/PostStopOrder', body
|
464
463
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Тип стоп-заявки
|
4
|
+
class InvestTinkoff::V2::StopOrderType
|
5
|
+
# Значение не указано
|
6
|
+
UNSPECIFIED = 0
|
7
|
+
|
8
|
+
# Take-profit заявка
|
9
|
+
TAKE_PROFIT = 1
|
10
|
+
|
11
|
+
# Stop-loss заявка
|
12
|
+
STOP_LOSS = 2
|
13
|
+
|
14
|
+
# Stop-limit заявка
|
15
|
+
STOP_LIMIT = 3
|
16
|
+
end
|
data/lib/invest_tinkoff.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invest_tinkoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Kalinichev
|
@@ -30,8 +30,22 @@ dependencies:
|
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '0.20'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec~>3.10.0
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
33
47
|
description: Tinkoff Invest Ruby Rest API Gem
|
34
|
-
email:
|
48
|
+
email: alex@agileseason.com
|
35
49
|
executables: []
|
36
50
|
extensions: []
|
37
51
|
extra_rdoc_files: []
|
@@ -53,6 +67,7 @@ files:
|
|
53
67
|
- lib/invest_tinkoff/v2/response.rb
|
54
68
|
- lib/invest_tinkoff/v2/sandbox_client.rb
|
55
69
|
- lib/invest_tinkoff/v2/stop_order_expiration_type.rb
|
70
|
+
- lib/invest_tinkoff/v2/stop_order_type.rb
|
56
71
|
- lib/invest_tinkoff/version.rb
|
57
72
|
homepage: https://github.com/blackchestnut/invest_tinkoff
|
58
73
|
licenses:
|