stockfighter 0.1.0 → 0.1.1
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/README.md +25 -9
- data/lib/stockfighter/gm.rb +9 -9
- data/lib/stockfighter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3133a56c01c50225b606c5a027a4450892ad4c19
|
4
|
+
data.tar.gz: d2e02e42f70aff2bacd3b060d782e42f815f77a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1252862680f92e3968c730baaf1e9361548b7f9c7ed99d61685ec66b1a152454f2ef76c4459ac4ab86178bb8ce3e8419c131e5c21ccf66e78717ac423731b9ee
|
7
|
+
data.tar.gz: 8ad9d93e6ae4559e4bce99b632208fa5eb3a5f026aedbcbdd646e8a8c1c604deae64984fd8d1a30e9c2fbe609e1298e1683dbbf48555f15c694570efcf210eed
|
data/README.md
CHANGED
@@ -26,19 +26,25 @@ require 'stockfighter'
|
|
26
26
|
|
27
27
|
# Use the GM to fetch the info automatically
|
28
28
|
|
29
|
-
gm = Stockfighter::GM.new("supersecretapikey1234567")
|
30
|
-
first_steps_config = gm.config_for(level: "first_steps")
|
29
|
+
gm = Stockfighter::GM.new(key: "supersecretapikey1234567", level: "first_steps")
|
31
30
|
|
32
|
-
api = Stockfighter::Api.new(
|
31
|
+
api = Stockfighter::Api.new(gm.config)
|
33
32
|
|
34
|
-
#
|
33
|
+
# Restart the level
|
35
34
|
|
36
|
-
|
37
|
-
account = "ACT123456789"
|
38
|
-
symbol = "ABC"
|
39
|
-
venue = "DEFGHEX"
|
35
|
+
gm.restart
|
40
36
|
|
41
|
-
|
37
|
+
# Resume the level
|
38
|
+
|
39
|
+
gm.resume
|
40
|
+
|
41
|
+
# Stop the level
|
42
|
+
|
43
|
+
gm.stop
|
44
|
+
|
45
|
+
# Check if the level is active
|
46
|
+
|
47
|
+
gm.active?
|
42
48
|
|
43
49
|
# Print the order book
|
44
50
|
puts api.order_book
|
@@ -69,6 +75,15 @@ puts cancellation["totalFilled"]
|
|
69
75
|
# Print the status of all your orders for the stock on the venue
|
70
76
|
puts api.status_all
|
71
77
|
|
78
|
+
# API can also be initialized manually
|
79
|
+
|
80
|
+
key = "supersecretapikey1234567"
|
81
|
+
account = "ACT123456789"
|
82
|
+
symbol = "ABC"
|
83
|
+
venue = "DEFGHEX"
|
84
|
+
|
85
|
+
api = Stockfighter::Api.new(key: key, account: account, symbol: symbol, venue: venue)
|
86
|
+
|
72
87
|
```
|
73
88
|
|
74
89
|
## Todo
|
@@ -76,6 +91,7 @@ puts api.status_all
|
|
76
91
|
* ~~TODO: Usage instructions!~~
|
77
92
|
* ~~TODO: Game master integration~~
|
78
93
|
* TODO: Tests
|
94
|
+
* TODO: Error Handling
|
79
95
|
|
80
96
|
## Contributing
|
81
97
|
|
data/lib/stockfighter/gm.rb
CHANGED
@@ -48,16 +48,16 @@ module Stockfighter
|
|
48
48
|
response = HTTParty.get("#{GM_URL}/instances/#{@instance_id}", :headers => {"X-Starfighter-Authorization" => @api_key})
|
49
49
|
response["done"] && response["ok"]
|
50
50
|
end
|
51
|
-
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
def update_config(resp)
|
53
|
+
@config = {}
|
54
|
+
@config[:key] = @api_key
|
55
|
+
@config[:account] = resp["account"]
|
56
|
+
@config[:venue] = resp["venues"][0]
|
57
|
+
@config[:symbol] = resp["tickers"][0]
|
59
58
|
|
60
|
-
|
59
|
+
@instance_id = resp["instanceId"]
|
60
|
+
end
|
61
|
+
private :update_config
|
61
62
|
end
|
62
|
-
private :update_config
|
63
63
|
end
|
data/lib/stockfighter/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.1
|
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: 2015-12-
|
11
|
+
date: 2015-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|