stockfighter 0.0.1 → 0.0.2

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: d2415edd3367b4bd4a7aaee2be6c976f258e19b6
4
- data.tar.gz: bac5606e0f110665800cce19238e514707ada46c
3
+ metadata.gz: 4bdefa6e0159b52f4476baedc42858dd71702d5e
4
+ data.tar.gz: ef6409e0478881f99d93a0ff0b8682dec4e0127f
5
5
  SHA512:
6
- metadata.gz: be8405a6810b219119b72a66dfc6d256b02c926a4078828dce3b96411b57d7e30ccec46d983b35dbc64f4941a623aa154d5a049c004de6993afe9cfec71b0cd7
7
- data.tar.gz: 50ecccfd0332ec27b79455efb4ebcf66047a7bac5a88c729c8262b5cad57a82d17e42fc4e99ae8a79da9190001cc4a49765eccdb1bec5dc06594e27edca46451
6
+ metadata.gz: 9aa733983e97db7249013f080f079f35f2ef53fb3a1f447c6d750be0b666e7acd11a59298964971a9b1a1049d21b229ddb37600d06f6acb421b7d2f5adec11c3
7
+ data.tar.gz: 025ec520598bada4e9e57f83794d18937eaf94c2abb94d189bc44f85aac2df3819436fd2dc442d99a4a3c070780d6db88492f9ec363d6b3c4706cb0fd02fde1a
data/README.md CHANGED
@@ -20,11 +20,66 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ ### Example
24
+ ```ruby
25
+ require 'stockfighter'
26
+
27
+ # Use the GM to fetch the info automatically
28
+
29
+ gm = Stockfighter::GM.new("supersecretapikey1234567")
30
+ first_steps_config = gm.fetch_info_for(level: "first_steps")
31
+
32
+ api = Stockfighter::Api.new(first_steps_config)
33
+
34
+ # Or initialize manually
35
+
36
+ key = "supersecretapikey1234567"
37
+ account = "ACT123456789"
38
+ symbol = "ABC"
39
+ venue = "DEFGHEX"
40
+
41
+ api = Stockfighter::Api.new(key: key, account: account, symbol: symbol, venue: venue)
42
+
43
+ # Print the order book
44
+ puts api.order_book
45
+
46
+ # Check if the venue is up
47
+ puts api.venue_up?
48
+
49
+ # Print a quote
50
+ puts api.get_quote
51
+
52
+ # Print the whole order book
53
+ puts api.order_book
54
+
55
+ # Place an order
56
+ order = api.place_order(price: 4250, quantity: 100, direction: "buy", order_type: "limit")
57
+
58
+ # Check the status of an order
59
+ order_id = order["id"]
60
+ order_status = api.order_status(order_id)
61
+ puts order_status["open"]
62
+ puts order_status["fills"]
63
+ puts order_status["totalFilled"]
64
+
65
+ # Cancel an order
66
+ cancellation = api.cancel_order(order_id)
67
+ puts cancellation["totalFilled"]
68
+
69
+ # Print the status of all your orders for the stock on the venue
70
+ puts api.status_all
71
+
72
+ ```
73
+
74
+ ## Todo
75
+
76
+ * ~~TODO: Usage instructions!~~
77
+ * ~~TODO: Game master integration~~
78
+ * TODO: Tests
24
79
 
25
80
  ## Contributing
26
81
 
27
- 1. Fork it ( https://github.com/[my-github-username]/stockfighter/fork )
82
+ 1. Fork it ( https://github.com/rjsamson/stockfighter/fork )
28
83
  2. Create your feature branch (`git checkout -b my-new-feature`)
29
84
  3. Commit your changes (`git commit -am 'Add some feature'`)
30
85
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/stockfighter.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  require "stockfighter/version"
2
2
  require "stockfighter/api"
3
+ require "stockfighter/gm"
@@ -0,0 +1,25 @@
1
+ require 'httparty'
2
+
3
+ module Stockfighter
4
+ class GM
5
+ def initialize(key)
6
+ @api_key = key
7
+ end
8
+
9
+ def config_for(level:)
10
+ resp = HTTParty.post("https://www.stockfighter.io/gm/levels/#{level}", :headers => {"X-Starfighter-Authorization" => @api_key})
11
+
12
+ config = {}
13
+ config[:account] = resp["account"]
14
+ config[:venue] = resp["venues"][0]
15
+ config[:symbol] = resp["tickers"][0]
16
+ config[:key] = @api_key
17
+
18
+ if config[:account] && config[:venue] && config[:symbol]
19
+ config
20
+ else
21
+ nil
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Stockfighter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  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.0.1
4
+ version: 0.0.2
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 00:00:00.000000000 Z
11
+ date: 2015-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -66,6 +66,7 @@ files:
66
66
  - Rakefile
67
67
  - lib/stockfighter.rb
68
68
  - lib/stockfighter/api.rb
69
+ - lib/stockfighter/gm.rb
69
70
  - lib/stockfighter/version.rb
70
71
  - stockfighter.gemspec
71
72
  homepage: https://github.com/rjsamson/stockfighter