stockfighter 0.4.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 732fe76a171ed98a78d642e01b24606254ca687b
4
- data.tar.gz: d2798df2beb98d49509180d44196ec8a0ed6d444
3
+ metadata.gz: 70ac34a00c5e8526d8669b719235525295a00843
4
+ data.tar.gz: e8c611e413722b0540895cef2baea001146ff197
5
5
  SHA512:
6
- metadata.gz: 5f44263691227792ed908acc7f9eb009889bcf4b3f2dbe936499cab18ef3ca3632a1cb04f4016ee091da2f763cf316baaf753663d363f303b11608f8d5b56f2d
7
- data.tar.gz: dd09455db5254b0d77438738a3b35cde95f66ffcd8cd7562e8136028706d939bf8626568f29760fbd545f458a0535f7d7c80ab3cac23d039d506a4149effabaf
6
+ metadata.gz: 0eb090b65ec4dd6aeebbf0b43593701b4badc771ac5db429a3ab65620d7175f8f9c677df9dd3d098ae948df40839ae8582a8af8218964962bda8862976f58a0b
7
+ data.tar.gz: 7ed44d6127750fdf82c0246b0f6a2db2931a64b5f5e94279854fd3517d197bfb64349d2e50d8672990f3e7116f1970dd287d0ba25b66f96e9159467d892a814f
@@ -80,6 +80,15 @@ module Stockfighter
80
80
  perform_request("post", "#{GM_URL}/instances/#{@instance_id}/resume")
81
81
  end
82
82
 
83
+ def judge(account:, explanation_link:, executive_summary:)
84
+ evidence = {
85
+ "account" => account,
86
+ "explanation_link" => explanation_link,
87
+ "executive_summary" => executive_summary
88
+ }
89
+ perform_request("post", "#{GM_URL}/instances/#{@instance_id}/judge", body: JSON.dump(evidence))
90
+ end
91
+
83
92
  def active?
84
93
  response = get_instance()
85
94
  response["done"]
@@ -89,11 +98,14 @@ module Stockfighter
89
98
  perform_request("get", "#{GM_URL}/instances/#{@instance_id}")
90
99
  end
91
100
 
92
- def perform_request(action, url)
101
+ def perform_request(action, url, body:nil)
93
102
  options = {
94
103
  :headers => {"X-Starfighter-Authorization" => @api_key},
95
104
  :format => :json
96
105
  }
106
+ if body != nil
107
+ options[:body] = body
108
+ end
97
109
  response = HTTParty.method(action).call(url, options)
98
110
  if response.code != 200
99
111
  raise "HTTP error response received from #{url}: #{response.code}"
@@ -123,9 +135,12 @@ module Stockfighter
123
135
  @config = {}
124
136
  @config[:key] = @api_key
125
137
  @config[:account] = response["account"]
126
- @config[:venue] = response["venues"][0]
127
- @config[:symbol] = response["tickers"][0]
128
-
138
+ if response.key?('venues')
139
+ @config[:venue] = response["venues"][0]
140
+ end
141
+ if response.key?('tickers')
142
+ @config[:symbol] = response["tickers"][0]
143
+ end
129
144
  @instance_id = response["instanceId"]
130
145
  end
131
146
 
@@ -1,3 +1,3 @@
1
1
  module Stockfighter
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -99,7 +99,8 @@ module Stockfighter
99
99
  end
100
100
 
101
101
  executions.onclose do |code, reason|
102
- raise "#{@account} executions websocket: Client disconnected with status code: #{code} and reason: #{reason}"
102
+ puts "#{@account} executions websocket: Client disconnected with status code: #{code} and reason: #{reason}, reconnecting"
103
+ executions = WebSocket::EventMachine::Client.connect(executions_options)
103
104
  end
104
105
  end
105
106
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stockfighter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert J Samson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-09 00:00:00.000000000 Z
11
+ date: 2016-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty