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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15075f7de0ea08c8c024ccaa2fdec3e166c8d7d4a514a128b5b09a8fe4312ef4
4
- data.tar.gz: 9df8ad68ffd0a8fbbdee0afb7322a8f544af22135155cbd5517f33cc48b3a49f
3
+ metadata.gz: 00e69167837b73c8cbb7fd0c586c4778779f2a3d94bfe50956f3d96ad65f3d34
4
+ data.tar.gz: 6baf1aca501d384cdf3fc41149ad678deaaaec43fd95bd6e236c802d087757a7
5
5
  SHA512:
6
- metadata.gz: 82eefd3f326f9b8e7d14a8854938c23f805a3305a9afa9bbb6780763656b1d96b82c037436e4039b30ee6ab376a897f6ca236851d2d9887073c289af2675a69b
7
- data.tar.gz: 6424579f75a7504c2a4cab2c646def21ddc2840eeef0d4636474ccd57d56719f3e467a1876c650a481d8e87088b1b43465490e856f8fb499b592a7e8191dd130
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 - sandbox API token
9
- # broker_account_id (опционально) - идентификатор счета
10
- # logger (опиционально) - например: Rails.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
- # Пример currency: :RUB, :USD, :EUR и т.д.
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
- def create_stop_order account_id:, figi:, quantity:, price:, stop_price:, expiration_type: nil
435
- # TODO: Еще остались не проброшенными некоторые аргументы.
436
- # {
437
- # "figi": "string",
438
- # "quantity": "string",
439
- # "price": {
440
- # "nano": 6,
441
- # "units": "units"
442
- # },
443
- # "stopPrice": {
444
- # "nano": 6,
445
- # "units": "units"
446
- # },
447
- # "direction": "STOP_ORDER_DIRECTION_UNSPECIFIED",
448
- # "accountId": "string",
449
- # "expirationType": "STOP_ORDER_EXPIRATION_TYPE_UNSPECIFIED",
450
- # "stopOrderType": "STOP_ORDER_TYPE_UNSPECIFIED",
451
- # "expireDate": "2022-05-15T16:08:27.339Z"
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
- accountId: account_id,
460
- expirationType: expiration_type || StopOrderExpirationType::UNSPECIFIED
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InvestTinkoff
4
- VERSION = '0.9.4'
4
+ VERSION = '0.9.6'
5
5
  end
@@ -8,6 +8,8 @@ module InvestTinkoff
8
8
  end
9
9
  end
10
10
 
11
+ require 'bigdecimal'
12
+ require 'bigdecimal/util'
11
13
  require 'invest_tinkoff/client_base'
12
14
 
13
15
  require 'invest_tinkoff/v1/client'
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
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: alexander.kalinichev@gmail.com
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: