fighter_base 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.
- checksums.yaml +7 -0
- data/.gitignore +40 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +41 -0
- data/README.md +56 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/fighter_base.gemspec +34 -0
- data/lib/fighter_base/exchange.rb +21 -0
- data/lib/fighter_base/level.rb +20 -0
- data/lib/fighter_base/order.rb +0 -0
- data/lib/fighter_base/version.rb +3 -0
- data/lib/fighter_base.rb +8 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c2cb2ebc74ae084de20a9fe8cee990dad05c5d24
|
4
|
+
data.tar.gz: 8b0cdd25d782ab58e1f74dec128b496ada0e0274
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0c372802c94fe8ee476279494e6d8731b4ed49f3cb3bcf1eff68f0f159c423d98e4687027540d90344b94a2a476bbae7e7da5e6e414fb1afd796ba7a6e5663d4
|
7
|
+
data.tar.gz: b91091078eff40a9e8734237aa21c373ea7450b7e862bcb9e820394e7e1983449204318f66a9a9e2a3bbf5550950516aa51a0333a97b46bae70cae0239610648
|
data/.gitignore
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
# Created by https://www.gitignore.io/api/ruby
|
3
|
+
|
4
|
+
### Ruby ###
|
5
|
+
*.gem
|
6
|
+
*.rbc
|
7
|
+
/.config
|
8
|
+
/coverage/
|
9
|
+
/InstalledFiles
|
10
|
+
/pkg/
|
11
|
+
/spec/reports/
|
12
|
+
/spec/examples.txt
|
13
|
+
/test/tmp/
|
14
|
+
/test/version_tmp/
|
15
|
+
/tmp/
|
16
|
+
|
17
|
+
## Specific to RubyMotion:
|
18
|
+
.dat*
|
19
|
+
.repl_history
|
20
|
+
build/
|
21
|
+
|
22
|
+
## Documentation cache and generated files:
|
23
|
+
/.yardoc/
|
24
|
+
/_yardoc/
|
25
|
+
/doc/
|
26
|
+
/rdoc/
|
27
|
+
|
28
|
+
## Environment normalization:
|
29
|
+
/.bundle/
|
30
|
+
/vendor/bundle
|
31
|
+
/lib/bundler/man/
|
32
|
+
|
33
|
+
# for a library or gem, you might want to ignore these files since the code is
|
34
|
+
# intended to run in multiple environments; otherwise, check them in:
|
35
|
+
# Gemfile.lock
|
36
|
+
# .ruby-version
|
37
|
+
# .ruby-gemset
|
38
|
+
|
39
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
40
|
+
.rvmrc
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fighter_base (0.1.0)
|
5
|
+
httparty (~> 0.13.7)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
httparty (0.13.7)
|
12
|
+
json (~> 1.8)
|
13
|
+
multi_xml (>= 0.5.2)
|
14
|
+
json (1.8.3)
|
15
|
+
multi_xml (0.5.5)
|
16
|
+
rake (10.4.2)
|
17
|
+
rspec (3.4.0)
|
18
|
+
rspec-core (~> 3.4.0)
|
19
|
+
rspec-expectations (~> 3.4.0)
|
20
|
+
rspec-mocks (~> 3.4.0)
|
21
|
+
rspec-core (3.4.1)
|
22
|
+
rspec-support (~> 3.4.0)
|
23
|
+
rspec-expectations (3.4.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.4.0)
|
26
|
+
rspec-mocks (3.4.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.4.0)
|
29
|
+
rspec-support (3.4.1)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
bundler (~> 1.10)
|
36
|
+
fighter_base!
|
37
|
+
rake (~> 10.0)
|
38
|
+
rspec
|
39
|
+
|
40
|
+
BUNDLED WITH
|
41
|
+
1.10.6
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# FighterBase
|
2
|
+
|
3
|
+
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/fighter_base`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'fighter_base'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install fighter_base
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
The main classes are
|
26
|
+
|
27
|
+
### Level
|
28
|
+
|
29
|
+
Stores the `api_key`, and trading account
|
30
|
+
|
31
|
+
### Venue
|
32
|
+
|
33
|
+
Most interaction will be through this class. Quote for a stock, orderbook for a stock, place an order, cancel an order is done here.
|
34
|
+
|
35
|
+
### Order
|
36
|
+
|
37
|
+
Create orders, then place them using Venue#place_order
|
38
|
+
|
39
|
+
## Notes
|
40
|
+
|
41
|
+
There are still some parts that I'm not certain about. If you create an order with `Order#new`, then place it on a venue and it is partially filled. When you look at properties of the order, it won't be updated.
|
42
|
+
|
43
|
+
Maybe the order instances should be able to update themselves, because they know the venue they were placed on?
|
44
|
+
|
45
|
+
Its probably best to think of the Order instance as a cache, and the real data is kept on the server.
|
46
|
+
|
47
|
+
## Development
|
48
|
+
|
49
|
+
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.
|
50
|
+
|
51
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fighter_base.
|
56
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fighter_base"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fighter_base/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fighter_base"
|
8
|
+
spec.version = FighterBase::VERSION
|
9
|
+
spec.authors = ["Brian Broom"]
|
10
|
+
spec.email = ["brian.broom@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Interface for API for stockfighter.io stock simulation}
|
13
|
+
spec.description = %q{FIghter Base gives you access to level, exchange, and order information to
|
14
|
+
use to build market scripts and play the levels of the Stockfighter game.}
|
15
|
+
spec.homepage = "https://github.com/bcbroom/FighterBase"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "httparty", "~> 0.13.7"
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
+
spec.add_development_dependency "rspec"
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "httparty"
|
2
|
+
|
3
|
+
module FighterBase
|
4
|
+
|
5
|
+
class Exchange
|
6
|
+
attr_reader :venue_symbol, :level
|
7
|
+
|
8
|
+
def initialize(venue_symbol, level)
|
9
|
+
@venue_symbol = venue_symbol
|
10
|
+
@level = level
|
11
|
+
end
|
12
|
+
|
13
|
+
def heartbeat
|
14
|
+
response = HTTParty.get("https://api.stockfighter.io/ob/api/venues/#{@venue_symbol}/heartbeat")
|
15
|
+
ok = response.parsed_response["ok"] rescue false
|
16
|
+
|
17
|
+
raise "World is on fire!" unless ok
|
18
|
+
puts "lump lump, lump lump" if ok
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "httparty"
|
2
|
+
|
3
|
+
module FighterBase
|
4
|
+
class Level
|
5
|
+
attr_reader :api_key, :exchange
|
6
|
+
|
7
|
+
def initialize(api_key, venue_symbol)
|
8
|
+
@api_key = api_key
|
9
|
+
@exchange = Exchange.new(venue_symbol, self)
|
10
|
+
end
|
11
|
+
|
12
|
+
def heartbeat
|
13
|
+
response = HTTParty.get("https://api.stockfighter.io/ob/api/heartbeat")
|
14
|
+
ok = response.parsed_response["ok"] rescue false
|
15
|
+
|
16
|
+
raise "World is on fire!" unless ok
|
17
|
+
puts "lump lump, lump lump" if ok
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
File without changes
|
data/lib/fighter_base.rb
ADDED
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fighter_base
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Broom
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: |-
|
70
|
+
FIghter Base gives you access to level, exchange, and order information to
|
71
|
+
use to build market scripts and play the levels of the Stockfighter game.
|
72
|
+
email:
|
73
|
+
- brian.broom@gmail.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
81
|
+
- Gemfile
|
82
|
+
- Gemfile.lock
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- fighter_base.gemspec
|
88
|
+
- lib/fighter_base.rb
|
89
|
+
- lib/fighter_base/exchange.rb
|
90
|
+
- lib/fighter_base/level.rb
|
91
|
+
- lib/fighter_base/order.rb
|
92
|
+
- lib/fighter_base/version.rb
|
93
|
+
homepage: https://github.com/bcbroom/FighterBase
|
94
|
+
licenses: []
|
95
|
+
metadata:
|
96
|
+
allowed_push_host: https://rubygems.org
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.4.6
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Interface for API for stockfighter.io stock simulation
|
117
|
+
test_files: []
|