qc 0.6.4 → 0.6.5
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/Changelog.md +15 -0
- data/Gemfile.lock +3 -3
- data/lib/qc.rb +1 -0
- data/lib/qc/backtest.rb +19 -5
- data/lib/qc/command_runner.rb +21 -17
- data/lib/qc/quant_connect_proxy.rb +2 -3
- data/lib/qc/version.rb +1 -1
- metadata +3 -3
- data/changelog.md +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b3de9ffca9f64dac8e90c931b22dbd2ee65ebbb
|
4
|
+
data.tar.gz: 32cb8921e13c021e4e080d3713ca0575bea8227e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 742b76cb7db38f4c993375e2a6df7976882fa5843fa88c6a1c042d7005ded194c545775393e109c91e6eb75468114720ebc6cd9408b6ac01e7b473d1ab2d0720
|
7
|
+
data.tar.gz: fa133d6dddfe1d70fcd697027cc82081857d82b25f255f6ffe2566fbb20b0f828b8992c6125ba9dbb59467d731c1cb8fb374ae65c99214f8f6eb97b4d0f0d9d9
|
data/Changelog.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Qc Changelog
|
2
|
+
|
3
|
+
## 6.0.4
|
4
|
+
|
5
|
+
- Removes `awesome-print` dependency #2
|
6
|
+
- Adds option to ignore files in `.qc/settings.yml` #4
|
7
|
+
|
8
|
+
## 6.0.5
|
9
|
+
|
10
|
+
- Wait for the backtest to finish when running `qc backtest`
|
11
|
+
- Shows summary of performance statistics after running backtest
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
qc (0.6.
|
4
|
+
qc (0.6.5)
|
5
5
|
rest-client (~> 2.0.2)
|
6
6
|
vcr (~> 3.0.3)
|
7
7
|
webmock (~> 3.1.0)
|
@@ -24,7 +24,7 @@ GEM
|
|
24
24
|
mime-types-data (3.2016.0521)
|
25
25
|
minitest (5.10.3)
|
26
26
|
netrc (0.11.0)
|
27
|
-
public_suffix (3.0.
|
27
|
+
public_suffix (3.0.1)
|
28
28
|
rake (10.5.0)
|
29
29
|
rest-client (2.0.2)
|
30
30
|
http-cookie (>= 1.0.2, < 2.0)
|
@@ -35,7 +35,7 @@ GEM
|
|
35
35
|
unf_ext
|
36
36
|
unf_ext (0.0.7.4)
|
37
37
|
vcr (3.0.3)
|
38
|
-
webmock (3.1.
|
38
|
+
webmock (3.1.1)
|
39
39
|
addressable (>= 2.3.6)
|
40
40
|
crack (>= 0.3.2)
|
41
41
|
hashdiff
|
data/lib/qc.rb
CHANGED
data/lib/qc/backtest.rb
CHANGED
@@ -1,18 +1,32 @@
|
|
1
1
|
module Qc
|
2
2
|
class Backtest < Struct.new(:id, :name, :completed, :progress, :result, :success)
|
3
3
|
alias success? success
|
4
|
-
alias completed? completed
|
5
4
|
|
6
5
|
def error?
|
7
6
|
!success?
|
8
7
|
end
|
9
8
|
|
10
|
-
def progress_in_percentage
|
11
|
-
progress * 100
|
12
|
-
end
|
13
|
-
|
14
9
|
def started?
|
15
10
|
progress > 0
|
16
11
|
end
|
12
|
+
|
13
|
+
def completed?
|
14
|
+
completed && (error? || (success? && result && result['TotalPerformance']))
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
description = "Backtest #{id}"
|
19
|
+
return "Backtest #{id} (not finished)" unless completed?
|
20
|
+
statistics = result['TotalPerformance']['PortfolioStatistics']
|
21
|
+
max_length = statistics.collect {|key, value| key.length}.max
|
22
|
+
|
23
|
+
description << "\n\n"
|
24
|
+
statistics.each do |key, value|
|
25
|
+
formatted_key = "#{key}: #{' ' * (max_length - key.length)}"
|
26
|
+
description << "#{formatted_key}#{value}\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
description
|
30
|
+
end
|
17
31
|
end
|
18
32
|
end
|
data/lib/qc/command_runner.rb
CHANGED
@@ -3,9 +3,9 @@ module Qc
|
|
3
3
|
DEFAULT_FILE_EXTENSIONS = 'cs,py'
|
4
4
|
DEFAULT_IGNORED_FILES = ['AssemblyInfo.cs']
|
5
5
|
|
6
|
-
SUPPORTED_COMMANDS
|
6
|
+
SUPPORTED_COMMANDS = %i(login logout init push compile backtest open)
|
7
7
|
COMPILE_POLLING_DELAY_IN_SECONDS = 2
|
8
|
-
BACKTEST_DELAY_IN_SECONDS =
|
8
|
+
BACKTEST_DELAY_IN_SECONDS = 4
|
9
9
|
|
10
10
|
attr_reader :quant_connect_proxy, :options
|
11
11
|
attr_accessor :project_settings
|
@@ -44,15 +44,14 @@ module Qc
|
|
44
44
|
if ::File.exist?(project_settings_file)
|
45
45
|
YAML.load(::File.open(project_settings_file))
|
46
46
|
else
|
47
|
-
|
47
|
+
create_project_settings
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
51
|
+
def create_project_settings
|
52
52
|
Qc::ProjectSettings.new.tap do |project_settings|
|
53
53
|
project_settings.ignored_files = DEFAULT_IGNORED_FILES
|
54
54
|
end
|
55
|
-
|
56
55
|
end
|
57
56
|
|
58
57
|
def logged_in?
|
@@ -190,19 +189,18 @@ module Qc
|
|
190
189
|
backtest = quant_connect_proxy.create_backtest project_settings.project_id, project_settings.last_compile_id, "backtest-#{project_settings.last_compile_id}"
|
191
190
|
puts "Backtest for compile #{project_settings.last_compile_id} sent to the queue with id #{backtest.id}"
|
192
191
|
open_results_in_quant_connect if options.open_results
|
193
|
-
|
192
|
+
puts "Waiting for backtest to start..."
|
193
|
+
last_completed_percentage = nil
|
194
194
|
begin
|
195
|
-
if backtest.
|
196
|
-
puts "
|
197
|
-
else
|
198
|
-
puts "Waiting for backtest to start..."
|
195
|
+
if last_completed_percentage != backtest.progress
|
196
|
+
puts "Completed: #{backtest.progress}%..."
|
199
197
|
end
|
198
|
+
last_completed_percentage = backtest.progress
|
200
199
|
backtest = quant_connect_proxy.read_backtest project_settings.project_id, backtest.id
|
201
|
-
sleep BACKTEST_DELAY_IN_SECONDS
|
200
|
+
sleep BACKTEST_DELAY_IN_SECONDS unless backtest.completed?
|
202
201
|
end while !backtest.completed?
|
203
202
|
|
204
|
-
|
205
|
-
puts "Backtest failed" if backtest.error?
|
203
|
+
show_backtest_results(backtest)
|
206
204
|
|
207
205
|
project_settings.last_backtest_id = backtest.id
|
208
206
|
save_project_settings
|
@@ -210,6 +208,12 @@ module Qc
|
|
210
208
|
backtest.success?
|
211
209
|
end
|
212
210
|
|
211
|
+
def show_backtest_results(backtest)
|
212
|
+
puts "Backtest finished" if backtest.success?
|
213
|
+
puts "Backtest failed" if backtest.error?
|
214
|
+
puts backtest.to_s
|
215
|
+
end
|
216
|
+
|
213
217
|
def valid_login?
|
214
218
|
quant_connect_proxy.valid_login?
|
215
219
|
end
|
@@ -232,12 +236,12 @@ module Qc
|
|
232
236
|
projects = quant_connect_proxy.list_projects
|
233
237
|
puts "Select the project you want to associate with this directory"
|
234
238
|
projects.each.with_index do |project, index|
|
235
|
-
puts "[#{index+1}] - #{project.name}"
|
239
|
+
puts "[#{index + 1}] - #{project.name}"
|
236
240
|
end
|
237
241
|
index = ask_for_value "Project number?"
|
238
242
|
index = index.to_i
|
239
|
-
if index >=1 && index < projects.length + 1
|
240
|
-
projects[index-1]
|
243
|
+
if index >= 1 && index < projects.length + 1
|
244
|
+
projects[index - 1]
|
241
245
|
else
|
242
246
|
puts "Invalid value (please type a number between #{1} and #{projects.length})"
|
243
247
|
ask_for_project
|
@@ -276,7 +280,7 @@ module Qc
|
|
276
280
|
end
|
277
281
|
|
278
282
|
def fetch_all_files
|
279
|
-
Dir["**/*.{#{project_settings.file_extensions}}"].reject{|file| ignore_file?(file)
|
283
|
+
Dir["**/*.{#{project_settings.file_extensions}}"].reject {|file| ignore_file?(file)}
|
280
284
|
end
|
281
285
|
|
282
286
|
def ignore_file?(file)
|
@@ -72,10 +72,9 @@ module Qc
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def read_backtest(project_id, backtest_id)
|
75
|
-
response = perform_request :get, '/backtests/read', params: {projectId: project_id,
|
75
|
+
response = perform_request :get, '/backtests/read', params: {projectId: project_id, backtestId: backtest_id}
|
76
76
|
validate_response! response
|
77
|
-
|
78
|
-
create_backtest_from_json_response(OpenStruct.new({success: response.success}.merge(found_backtest_json)))
|
77
|
+
create_backtest_from_json_response(response)
|
79
78
|
end
|
80
79
|
|
81
80
|
private
|
data/lib/qc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Manrubia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- ".gitignore"
|
120
120
|
- ".ruby-version"
|
121
121
|
- ".travis.yml"
|
122
|
+
- Changelog.md
|
122
123
|
- Gemfile
|
123
124
|
- Gemfile.lock
|
124
125
|
- LICENSE.txt
|
@@ -130,7 +131,6 @@ files:
|
|
130
131
|
- bin/console
|
131
132
|
- bin/qc
|
132
133
|
- bin/setup
|
133
|
-
- changelog.md
|
134
134
|
- lib/qc.rb
|
135
135
|
- lib/qc/backtest.rb
|
136
136
|
- lib/qc/cli.rb
|