dtn 0.0.0 → 0.1.0

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.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +21 -5
  3. data/.env.example +5 -0
  4. data/.gitignore +2 -0
  5. data/.rubocop.yml +7 -0
  6. data/CHANGELOG.md +5 -1
  7. data/Gemfile +3 -1
  8. data/README.md +288 -9
  9. data/Rakefile +2 -0
  10. data/docker-compose.yml +34 -0
  11. data/dtn.gemspec +1 -1
  12. data/lib/dtn.rb +18 -1
  13. data/lib/dtn/concerns/id.rb +36 -0
  14. data/lib/dtn/concerns/validation.rb +71 -0
  15. data/lib/dtn/helpers/catalog.rb +32 -0
  16. data/lib/dtn/lookups/catalog/listed_markets.rb +12 -0
  17. data/lib/dtn/lookups/catalog/naic_codes.rb +12 -0
  18. data/lib/dtn/lookups/catalog/security_types.rb +12 -0
  19. data/lib/dtn/lookups/catalog/sic_codes.rb +12 -0
  20. data/lib/dtn/lookups/catalog/trade_conditions.rb +12 -0
  21. data/lib/dtn/lookups/historical/base.rb +43 -0
  22. data/lib/dtn/lookups/historical/daily_datapoint.rb +13 -0
  23. data/lib/dtn/lookups/historical/daily_timeframe.rb +34 -0
  24. data/lib/dtn/lookups/historical/datapoint.rb +27 -0
  25. data/lib/dtn/lookups/historical/interval.rb +14 -0
  26. data/lib/dtn/lookups/historical/interval_datapoint.rb +31 -0
  27. data/lib/dtn/lookups/historical/interval_day.rb +32 -0
  28. data/lib/dtn/lookups/historical/interval_timeframe.rb +37 -0
  29. data/lib/dtn/lookups/historical/monthly_datapoint.rb +13 -0
  30. data/lib/dtn/lookups/historical/tick.rb +14 -0
  31. data/lib/dtn/lookups/historical/tick_datapoint.rb +24 -0
  32. data/lib/dtn/lookups/historical/tick_day.rb +34 -0
  33. data/lib/dtn/lookups/historical/tick_timeframe.rb +31 -0
  34. data/lib/dtn/lookups/historical/weekly_datapoint.rb +13 -0
  35. data/lib/dtn/lookups/news/base.rb +85 -0
  36. data/lib/dtn/lookups/news/config.rb +25 -0
  37. data/lib/dtn/lookups/news/headline.rb +40 -0
  38. data/lib/dtn/lookups/news/story.rb +40 -0
  39. data/lib/dtn/lookups/news/story_count.rb +36 -0
  40. data/lib/dtn/lookups/request.rb +92 -0
  41. data/lib/dtn/lookups/symbol/base.rb +11 -0
  42. data/lib/dtn/lookups/symbol/by_filter.rb +58 -0
  43. data/lib/dtn/lookups/symbol/by_naic.rb +26 -0
  44. data/lib/dtn/lookups/symbol/by_sic.rb +26 -0
  45. data/lib/dtn/message.rb +29 -0
  46. data/lib/dtn/messages/bar/base.rb +30 -0
  47. data/lib/dtn/messages/bar/current_bar.rb +11 -0
  48. data/lib/dtn/messages/bar/historical_bar.rb +11 -0
  49. data/lib/dtn/messages/bar/update_bar.rb +11 -0
  50. data/lib/dtn/messages/catalog/code.rb +22 -0
  51. data/lib/dtn/messages/catalog/listed_markets.rb +20 -0
  52. data/lib/dtn/messages/catalog/naic_codes.rb +10 -0
  53. data/lib/dtn/messages/catalog/security_types.rb +20 -0
  54. data/lib/dtn/messages/catalog/sic_codes.rb +10 -0
  55. data/lib/dtn/messages/catalog/trade_conditions.rb +20 -0
  56. data/lib/dtn/messages/historical/daily_weekly_monthly.rb +25 -0
  57. data/lib/dtn/messages/historical/interval.rb +28 -0
  58. data/lib/dtn/messages/historical/tick.rb +31 -0
  59. data/lib/dtn/messages/level2/level2_update.rb +38 -0
  60. data/lib/dtn/messages/level2/market_maker_name.rb +20 -0
  61. data/lib/dtn/messages/message_with_simple_parser.rb +38 -0
  62. data/lib/dtn/messages/news/base.rb +34 -0
  63. data/lib/dtn/messages/news/config.rb +24 -0
  64. data/lib/dtn/messages/news/headline.rb +25 -0
  65. data/lib/dtn/messages/news/story.rb +20 -0
  66. data/lib/dtn/messages/news/story_count.rb +21 -0
  67. data/lib/dtn/messages/quote/level1.rb +150 -0
  68. data/lib/dtn/messages/quote/level1_fundamental.rb +17 -0
  69. data/lib/dtn/messages/quote/level1_news.rb +27 -0
  70. data/lib/dtn/messages/quote/level1_regional.rb +31 -0
  71. data/lib/dtn/messages/quote/level1_summary.rb +19 -0
  72. data/lib/dtn/messages/quote/level1_update.rb +21 -0
  73. data/lib/dtn/messages/symbol/base.rb +35 -0
  74. data/lib/dtn/messages/symbol/by_filter.rb +11 -0
  75. data/lib/dtn/messages/symbol/by_naic.rb +22 -0
  76. data/lib/dtn/messages/symbol/by_sic.rb +22 -0
  77. data/lib/dtn/messages/system/client_stats.rb +46 -0
  78. data/lib/dtn/messages/system/customer_info.rb +30 -0
  79. data/lib/dtn/messages/system/end_of_message_characters.rb +22 -0
  80. data/lib/dtn/messages/system/error.rb +20 -0
  81. data/lib/dtn/messages/system/generic.rb +98 -0
  82. data/lib/dtn/messages/system/no_data_characters.rb +22 -0
  83. data/lib/dtn/messages/system/stats.rb +38 -0
  84. data/lib/dtn/messages/system/symbol_not_found.rb +19 -0
  85. data/lib/dtn/messages/system/timestamp.rb +16 -0
  86. data/lib/dtn/messages/unknown.rb +15 -0
  87. data/lib/dtn/registry.rb +57 -0
  88. data/lib/dtn/streaming/client.rb +105 -0
  89. data/lib/dtn/streaming/clients/admin.rb +20 -0
  90. data/lib/dtn/streaming/clients/bar.rb +49 -0
  91. data/lib/dtn/streaming/clients/level2.rb +25 -0
  92. data/lib/dtn/streaming/clients/quote.rb +57 -0
  93. data/lib/dtn/streaming/messages_recorder_observer.rb +26 -0
  94. data/lib/dtn/streaming/request.rb +27 -0
  95. data/lib/dtn/streaming/request_builder.rb +57 -0
  96. data/lib/dtn/streaming/requests/admin/register_client_app.rb +24 -0
  97. data/lib/dtn/streaming/requests/admin/remove_client_app.rb +22 -0
  98. data/lib/dtn/streaming/requests/admin/save_login_info.rb +18 -0
  99. data/lib/dtn/streaming/requests/admin/set_autoconnect.rb +18 -0
  100. data/lib/dtn/streaming/requests/admin/set_client_stats.rb +20 -0
  101. data/lib/dtn/streaming/requests/admin/set_loginid.rb +21 -0
  102. data/lib/dtn/streaming/requests/admin/set_password.rb +21 -0
  103. data/lib/dtn/streaming/requests/bar/unwatch.rb +18 -0
  104. data/lib/dtn/streaming/requests/bar/unwatch_all.rb +16 -0
  105. data/lib/dtn/streaming/requests/bar/watch.rb +81 -0
  106. data/lib/dtn/streaming/requests/bar/watches.rb +21 -0
  107. data/lib/dtn/streaming/requests/level2/connect.rb +16 -0
  108. data/lib/dtn/streaming/requests/level2/disconnect.rb +16 -0
  109. data/lib/dtn/streaming/requests/level2/market_maker_by_id.rb +18 -0
  110. data/lib/dtn/streaming/requests/level2/unwatch.rb +18 -0
  111. data/lib/dtn/streaming/requests/level2/watch.rb +18 -0
  112. data/lib/dtn/streaming/requests/quote/all_update_fieldnames.rb +16 -0
  113. data/lib/dtn/streaming/requests/quote/connect.rb +16 -0
  114. data/lib/dtn/streaming/requests/quote/current_update_fieldnames.rb +16 -0
  115. data/lib/dtn/streaming/requests/quote/fundamental_fieldnames.rb +16 -0
  116. data/lib/dtn/streaming/requests/quote/news_switch.rb +18 -0
  117. data/lib/dtn/streaming/requests/quote/refresh.rb +29 -0
  118. data/lib/dtn/streaming/requests/quote/regional_switch.rb +26 -0
  119. data/lib/dtn/streaming/requests/quote/set_client_name.rb +16 -0
  120. data/lib/dtn/streaming/requests/quote/set_protocol.rb +16 -0
  121. data/lib/dtn/streaming/requests/quote/timestamp.rb +21 -0
  122. data/lib/dtn/streaming/requests/quote/timestamp_switch.rb +18 -0
  123. data/lib/dtn/streaming/requests/quote/trades.rb +21 -0
  124. data/lib/dtn/streaming/requests/quote/unwatch.rb +22 -0
  125. data/lib/dtn/streaming/requests/quote/unwatch_all.rb +16 -0
  126. data/lib/dtn/streaming/requests/quote/update_fields.rb +40 -0
  127. data/lib/dtn/streaming/requests/quote/watch.rb +22 -0
  128. data/lib/dtn/streaming/requests/quote/watches.rb +21 -0
  129. data/lib/dtn/version.rb +1 -1
  130. data/lib/ext/business_day.rb +15 -0
  131. data/lib/tasks/spec_date.rake +13 -0
  132. metadata +126 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ecf42958179827da17828e2916186eaee7ed1415b2a1799a180bb27d9fe9795
4
- data.tar.gz: e4764a1c0c747f9c85bd28303a77174cb324e4015bc6021f6a28f2d8fa859d60
3
+ metadata.gz: 01144ea75d9a670db11ab1836fff8bc3e650bad5f964aef65511b2ee1669268d
4
+ data.tar.gz: dc9116938d33b14f375c25c5df374be43d4797d5efe0a12a40adbeb2363a67b3
5
5
  SHA512:
6
- metadata.gz: 900df3fb5645938e6395137dd1d478e9504e4d3298fe051868728281a6e2796a2314bcf8a76ea1c59c5d5c28197d1f7f8a0b8b1a3a4083ae46c99057aa84fb33
7
- data.tar.gz: 23a0ed4dc9f2b306f0fe1e63625bb3b4325aa94068211acf52acd2f0e1c46425f4c76d9b7dbde7376ec588590fca123a3f9304440563c553db1e8b39e72961e0
6
+ metadata.gz: ac0e99c1951a85709ba61e3632c1d7c8924fb631e42e450548e83fbf3e4347dd50d2c0eeb83ba1d2a0d30943bfd693adec6c06e96a76d10b6e38e09126e50b05
7
+ data.tar.gz: daa3d7752b364c772c6f6094745a92f2b30f080a7ccc9954aa06fd23b1d2ecb28057792172b32cc02abb843ecb81f1fcde453a8f3d3c157c4a5a755b7e97ae3c
data/.circleci/config.yml CHANGED
@@ -2,10 +2,10 @@ version: 2.1
2
2
  defaults: &defaults
3
3
  working_directory: ~/repo
4
4
  docker:
5
- - image: circleci/ruby:2.6.3-stretch-node
5
+ - image: circleci/ruby:2.6
6
6
  environment:
7
7
  BUNDLE_PATH: vendor/bundle
8
- # executor: ruby/default
8
+
9
9
  commands:
10
10
  prepare:
11
11
  description: "Common preparation steps"
@@ -46,7 +46,14 @@ jobs:
46
46
  paths:
47
47
  - cc-test-reporter
48
48
  rspec:
49
- <<: *defaults
49
+ working_directory: ~/repo
50
+ docker:
51
+ - image: << parameters.image >>
52
+ environment:
53
+ BUNDLE_PATH: vendor/bundle
54
+ parameters:
55
+ image:
56
+ type: string
50
57
  environment:
51
58
  COVERAGE: "1"
52
59
  CI: "1"
@@ -59,11 +66,11 @@ jobs:
59
66
  command: |
60
67
  bundle exec rspec
61
68
 
62
- ./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.json coverage/coverage.json
69
+ ./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.$CIRCLE_BUILD_NUM.json coverage/coverage.json
63
70
  - persist_to_workspace:
64
71
  root: tmp
65
72
  paths:
66
- - codeclimate.json
73
+ - codeclimate.*.json
67
74
  rubocop:
68
75
  <<: *defaults
69
76
  steps:
@@ -80,7 +87,10 @@ jobs:
80
87
  at: ~/repo/tmp
81
88
  - run:
82
89
  name: Upload coverage results to Code Climate
90
+ # --parts flag must match the build matrix size
83
91
  command: |
92
+ ./tmp/cc-test-reporter sum-coverage -o tmp/codeclimate.json --parts 3 tmp/codeclimate.*.json
93
+
84
94
  ./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.json
85
95
 
86
96
  workflows:
@@ -91,6 +101,12 @@ workflows:
91
101
  - rspec:
92
102
  requires:
93
103
  - download_test_reporter
104
+ matrix:
105
+ parameters:
106
+ image:
107
+ - "circleci/ruby:2.6"
108
+ - "circleci/ruby:2.7"
109
+ - "circleci/ruby:3.0"
94
110
  - rubocop
95
111
  - upload-coverage:
96
112
  requires:
data/.env.example ADDED
@@ -0,0 +1,5 @@
1
+ # aka customerID aka acoountNumber. do not overwrite it if you do not have the value!
2
+ IQFEED_PRODUCT_ID=
3
+ # aka userID aka userName
4
+ IQFEED_LOGIN=
5
+ IQFEED_PASSWORD=
data/.gitignore CHANGED
@@ -6,7 +6,9 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /logs/
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
12
13
  Gemfile.lock
14
+ .env
data/.rubocop.yml CHANGED
@@ -16,3 +16,10 @@ Layout/LineLength:
16
16
  Metrics/BlockLength:
17
17
  Exclude:
18
18
  - spec/**/*
19
+
20
+ Metrics/ModuleLength:
21
+ Exclude:
22
+ - spec/**/*
23
+
24
+ Naming/InclusiveLanguage:
25
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -2,4 +2,8 @@
2
2
 
3
3
  ## [0.0.0] - 2021-05-21
4
4
 
5
- - Initial release
5
+ - Initial release (name reserve)
6
+
7
+ ## [0.1.0] - 2021-07-20
8
+
9
+ - First tested version of the gem
data/Gemfile CHANGED
@@ -8,11 +8,13 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
 
10
10
  gem "pry", "~> 0.14.0"
11
- gem "rubocop", "~> 1.15.0", require: false
11
+ gem "rubocop", "~> 1.18.0", require: false
12
12
  gem "rubocop-rake", "~> 0.5.0", require: false
13
13
  gem "rubocop-rspec", "~> 2.3.0", require: false
14
14
 
15
15
  group :test do
16
+ gem "business_time", "~> 0.10.0"
17
+ gem "holidays", "~> 8.4.0"
16
18
  gem "rspec", ">= 3.10.0", "< 4.0"
17
19
  gem "rspec_junit_formatter"
18
20
  gem "simplecov", "~> 0.21.0", require: false
data/README.md CHANGED
@@ -4,14 +4,30 @@
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/7bf62332c4d163460678/maintainability)](https://codeclimate.com/github/kvokka/dtn/maintainability)
5
5
  [![Test Coverage](https://api.codeclimate.com/v1/badges/7bf62332c4d163460678/test_coverage)](https://codeclimate.com/github/kvokka/dtn/test_coverage)
6
6
 
7
-
8
7
  # Dtn
9
8
 
10
- WIP. TODO: upd readme
9
+ Unofficial DTN (IQFeed) client.
10
+
11
+ # Dependencies
12
+
13
+ * IQFeed client ~> 6.1
14
+
15
+ # IQFeed API support status
11
16
 
12
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dtn`. To experiment with that code, run `bin/console` for an interactive prompt.
17
+ ## Streaming clients
13
18
 
14
- TODO: Delete this and the text above, and describe your gem
19
+ - [x] Quote (Level 1) client
20
+ - [x] Level 2 client
21
+ - [x] Bar (Derivative) client
22
+ - [x] Admin client
23
+
24
+ ## Lookup client
25
+
26
+ - [x] Historical data
27
+ - [x] News data
28
+ - [x] Symbol Lookup data
29
+ - [ ] Chains Lookup data
30
+ - [ ] Market Summary Data (new in protocol 6.1)
15
31
 
16
32
  ## Installation
17
33
 
@@ -31,17 +47,275 @@ Or install it yourself as:
31
47
 
32
48
  ## Usage
33
49
 
34
- TODO: Write usage instructions here
50
+ ### Quick start
51
+
52
+ ```ruby
53
+ Dtn::Lookups::Historical::DailyTimeframe.call(
54
+ symbol: :aapl,
55
+ begin_date: Date.new(2021, 5, 1),
56
+ end_date: Date.new(2021, 6, 1)
57
+ )
58
+
59
+ =>
60
+ #<Dtn::Messages::Historical::DailyWeeklyMonthly request_id=1, timestamp=Mon, 03 May 2021 18:06:37 +0000, high=134.07, low=131.83, open=132.04, close=132.54, period_volume=75135100, open_interest=0>
61
+ #<Dtn::Messages::Historical::DailyWeeklyMonthly request_id=1, timestamp=Tue, 04 May 2021 18:06:37 +0000, high=131.4899, low=126.7, open=131.19, close=127.85, period_volume=137564718, open_interest=0>
62
+ #<Dtn::Messages::Historical::DailyWeeklyMonthly request_id=1, timestamp=Wed, 05 May 2021 18:06:37 +0000, high=130.45, low=127.97, open=129.2, close=128.1, period_volume=84000900, open_interest=0>
63
+ #<Dtn::Messages::Historical::DailyWeeklyMonthly request_id=1, timestamp=Thu, 06 May 2021 18:06:37 +0000, high=129.75, low=127.13, open=127.89, close=129.74, period_volume=78128334, open_interest=0>
64
+ ...
65
+
66
+ # if block provided, then each message will be yielded as it is processed
67
+
68
+ Dtn::Lookups::News::Headline.call(limit: 10) do |message|
69
+ # ...
70
+ end
71
+ ```
72
+
73
+ ### Supported requests
74
+
75
+ Keep in mind, that at the time of writing DTN, API has limit of 50
76
+ historical requests per minute.
77
+
78
+ TODO: Attach [limiter](https://github.com/Shopify/limiter) gem after merge
79
+ https://github.com/Shopify/limiter/pull/17 https://github.com/Shopify/limiter/pull/19
80
+ or use own branch of this gem.
81
+
82
+ #### News
83
+
84
+ * [config](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/news/config.rb)
85
+ ```ruby
86
+ Dtn::Lookups::News::Config.call
87
+ ```
88
+ * [headline](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/news/headline.rb)
89
+ ```ruby
90
+ Dtn::Lookups::News::Headline.call limit: 10, symbols: 'aapl;fb'
91
+ ```
92
+ * [story_count](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/news/story_count.rb)
93
+ ```ruby
94
+ Dtn::Lookups::News::StoryCount.call symbols: :aapl, date_range: Date.new(2020,1,1)..Date.new(2020,2,1)
95
+ ```
96
+ * [story](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/news/story.rb)
97
+ ```ruby
98
+ Dtn::Lookups::News::Story.call story_id: '22424363689'
99
+ ```
100
+
101
+
102
+ NOTES:
103
+
104
+ * if XML output option selected, the response will return **unparsed** XML
105
+
106
+ #### Historical
107
+
108
+ * [interval_day](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/historical/interval_day.rb)
109
+ ```ruby
110
+ Dtn::Lookups::Historical::IntervalDay.call(symbol: :aapl, interval: 3600, max_datapoints: 50, days: 2)
111
+ ```
112
+ * [tick_timeframe](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/historical/tick_timeframe.rb)
113
+ ```ruby
114
+ Dtn::Lookups::Historical::TickTimeframe.call(
115
+ symbol: :aapl,
116
+ begin_datetime: begin_datetime,
117
+ end_datetime: end_datetime,
118
+ max_datapoints: 50
119
+ )
120
+ ```
121
+ * [daily_datapoint](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/historical/daily_datapoint.rb)
122
+ ```ruby
123
+ Dtn::Lookups::Historical::DailyDatapoint.call(symbol: :aapl, max_datapoints: 50)
124
+ ```
125
+ * [interval_timeframe](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/historical/interval_timeframe.rb)
126
+ ```ruby
127
+ Dtn::Lookups::Historical::IntervalTimeframe.call(
128
+ symbol: :aapl,
129
+ interval: 15,
130
+ max_datapoints: 50,
131
+ begin_datetime: DateTime.new(2020, 5, 1),
132
+ end_datetime: DateTime.new(2020, 6, 1)
133
+ )
134
+ ```
135
+ * [tick_datapoint](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/historical/tick_datapoint.rb)
136
+ ```ruby
137
+ Dtn::Lookups::Historical::TickDatapoint.call(symbol: :aapl, max_datapoints: 100)
138
+ ```
139
+ * [weekly_datapoint](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/historical/weekly_datapoint.rb)
140
+ ```ruby
141
+ Dtn::Lookups::Historical::WeeklyDatapoint.call(symbol: :aapl, max_datapoints: 10)
142
+ ```
143
+ * [daily_timeframe](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/historical/daily_timeframe.rb)
144
+ ```ruby
145
+ Dtn::Lookups::Historical::DailyTimeframe.call(
146
+ symbol: :aapl,
147
+ begin_date: Date.new(2020, 5, 1),
148
+ end_date: Date.new(2020, 6, 1)
149
+ )
150
+ ```
151
+ * [interval_datapoint](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/historical/interval_datapoint.rb)
152
+ ```ruby
153
+ Dtn::Lookups::Historical::IntervalDatapoint.call(symbol: :aapl, interval: 3600, max_datapoints: 100)
154
+ ```
155
+ * [monthly_datapoint](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/historical/monthly_datapoint.rb)
156
+ ```ruby
157
+ Dtn::Lookups::Historical::MonthlyDatapoint.call(symbol: :aapl, max_datapoints: 10)
158
+ ```
159
+ * [tick_day](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/historical/tick_day.rb)
160
+ ```ruby
161
+ Dtn::Lookups::Historical::TickDay.call(symbol: :aapl, days: 2, max_datapoints: 50)
162
+ ```
163
+
164
+ NOTES:
165
+
166
+ * Lookups have extra options from their parents classes. They have appropriate
167
+ defaults and are easy to customize.
168
+
169
+ #### Catalogs
170
+
171
+ For symbol lookup and description API use a few catalogs, which describe each row.
172
+ They very rarely change and we can treat them as constants. To reduce requests to
173
+ API they are requested only once. For easy access to them you can use:
174
+
175
+ * `Dtn.listed_markets_catalog`
176
+ * `Dtn.naic_codes_catalog`
177
+ * `Dtn.security_types_catalog`
178
+ * `Dtn.sic_codes_catalog`
179
+ * `Dtn.trade_conditions_catalog`
180
+
181
+ #### Symbol lookup
182
+
183
+ * [by_sic](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/symbol/by_sic.rb)
184
+ ```ruby
185
+ Dtn::Lookups::Symbol::BySic.call(search_line: '42')
186
+ ```
187
+ * [by_naic](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/symbol/by_naic.rb)
188
+ ```ruby
189
+ Dtn::Lookups::Symbol::ByNaic.call(search_line: '42')
190
+ ```
191
+ * [by_filter](https://github.com/kvokka/dtn/blob/master/lib/dtn/requests/symbol/by_filter.rb)
192
+ ```ruby
193
+ Dtn::Lookups::Symbol::ByFilter.call(field_to_search: "s", search_line: "aap", filter_type: "t", filter_value: "1")
194
+ ```
195
+
196
+ #### Streaming data
197
+
198
+ All streaming data is using Observer pattern, so you can connect a few listeners
199
+ to any client with minimal cost. Below, you will get the examples with simple
200
+ observers, but there is an [Observer](https://github.com/kvokka/dtn/blob/master/lib/dtn/streaming/messages_recorder_observer.rb) for easier development & testing.
201
+
202
+ ##### Quotes (Level1)
203
+
204
+ Streaming data is using Observers to deliver the results.
205
+ Keep in mind, that observers will receive data until you unsubscribe from it
206
+ or stop the client.
207
+
208
+ Summary message always come with all the possible fields, while for Update message
209
+ it is possible to add a filter with `client.request.quote.update_fields list: %w[Bid Ask]`
210
+
211
+ These methods do not allow any historical data access, only real time.
212
+
213
+ ```ruby
214
+ class Observer
215
+ # data callbacks are optional and match message class
216
+ def level1_summary(message:)
217
+ puts message
218
+ end
219
+
220
+ def level1_update(message:)
221
+ puts message
222
+ end
223
+
224
+ # one of system methods callback
225
+ def disconnected(message:)
226
+ puts message
227
+ end
228
+ end
229
+
230
+ client = Dtn::Streaming::Clients::Quote.new
231
+ client.observers << Observer.new
232
+ client.request.quote.watch symbol: :aapl
233
+ sleep 10
234
+ client.stop
235
+ ```
236
+
237
+ [Here](https://github.com/kvokka/dtn/tree/master/lib/dtn/streaming/requests) you
238
+ will find all level1 streaming requests with appropriate documentation.
239
+
240
+ #### Bars data
241
+
242
+ Get live data as interval bar data. It allows to look back and fetch historical
243
+ data and get current (live) data as well,
244
+ [details](https://github.com/kvokka/dtn/tree/master/lib/dtn/streaming/requests/bar)
245
+
246
+ ```ruby
247
+ class Observer
248
+ # this callback will return all historical bars for the symbol
249
+ def historical_bar(message:)
250
+ puts message
251
+ end
252
+
253
+ # Here you get live updates until the current bar is formed
254
+ def update_bar(message:)
255
+ puts message
256
+ end
257
+
258
+ # when the current bar was formed, it will be processed by this callback
259
+ def current_bar(message:)
260
+ puts message
261
+ end
262
+ end
263
+
264
+ client = Dtn::Streaming::Clients::Bar.new
265
+ client.observers << Observer.new
266
+ client.request.bar.watch symbol: :aapl
267
+ sleep 10
268
+ client.stop
269
+ ```
270
+
271
+ #### Admin
272
+
273
+ Admin data management. See other commands in [here](https://github.com/kvokka/dtn/tree/master/lib/dtn/streaming/requests/admin)
274
+
275
+ ```ruby
276
+ client.observers << Observer.new
277
+ client.request.admin.set_client_stats turned_on: false
278
+ ```
279
+
280
+ #### Level2
281
+
282
+ Connection to level2 data. See other commands in [here](https://github.com/kvokka/dtn/tree/master/lib/dtn/streaming/requests/level2)
283
+
284
+ ```ruby
285
+ client.observers << Observer.new
286
+ client.request.level2.watch symbol: :aapl
287
+ ```
288
+
289
+ ## Config
290
+
291
+ In case you are using DTN client running remotely (no questions asked how you
292
+ can do it), you can specify the host with `Dtn.host = 'my_host'` setting
35
293
 
36
294
  ## Development
37
295
 
38
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
296
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
297
+ `bundle exec rake` to run the tests. You can also run `bin/console` for an
298
+ interactive prompt that will allow you to experiment.
299
+
300
+ Test specs are using recorded output from DTN client. The recorded file is set
301
+ by the RSpec option `socket_recorder`, so you can share 1 recording with a few
302
+ specs. If the file is missing, then specs will do real request to the api.
303
+ `socket_recorder` will use the pre-defined Date for the specs from the file
304
+ [current_day](https://github.com/kvokka/dtn/blob/master/spec/current_day) to
305
+ minimise recordings rewrites. To bump the date to the yesterday business day
306
+ you can use
307
+
308
+ ```bash
309
+ $ bundle exec rake spec:set_spec_date
310
+ ```
39
311
 
40
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
312
+ To run windows DTN client you can use the `docker-compose up` (before execution
313
+ pls fill in `.env` file with your credentials following the pattern from
314
+ [.env.example](https://github.com/kvokka/dtn/blob/master/.env.example))
41
315
 
42
316
  ## Contributing
43
317
 
44
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dtn. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/dtn/blob/master/CODE_OF_CONDUCT.md).
318
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kvokka/dtn. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/kvokka/dtn/blob/master/CODE_OF_CONDUCT.md).
45
319
 
46
320
  ## License
47
321
 
@@ -49,4 +323,9 @@ The gem is available as open source under the terms of the [MIT License](https:/
49
323
 
50
324
  ## Code of Conduct
51
325
 
52
- Everyone interacting in the Dtn project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/dtn/blob/master/CODE_OF_CONDUCT.md).
326
+ Everyone interacting in the Dtn project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kvokka/dtn/blob/master/CODE_OF_CONDUCT.md).
327
+
328
+ ## References
329
+
330
+ * https://github.com/mathpaquette/IQFeed.CSharpApiClient
331
+ * https://github.com/akapur/pyiqfeed