stock_fighter_mixin 0.0.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 +7 -0
- data/lib/stock_fighter_mixin.rb +64 -0
- metadata +59 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: cd51ba195762372c11f1fc7083a9c795e2fb5228
|
|
4
|
+
data.tar.gz: 62e2154f127df3676ed9a03698fca46b9276fd50
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: de1c884d80712157ddab4aead7bf6791ce224cfa42da691eedddeea03af2ec47fca17980ad624c6f6b5cd59d4b9e0ecbc435e9ce3dc6bcb35a711498b48943c9
|
|
7
|
+
data.tar.gz: ea5f3264914b4a92ffd185394bd9295bd2833b7d382173417e4f9112d004a513ad3521fbee0511ebeae64c0b30a255dff39ca0383c6fdd00c24c55ae6600b1ea
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
module StockFighterMixin
|
|
5
|
+
def self.included base
|
|
6
|
+
http_delegator = Class.new do
|
|
7
|
+
include HTTParty
|
|
8
|
+
|
|
9
|
+
base_uri 'https://api.stockfighter.io/ob/api'
|
|
10
|
+
format :json
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
base.send :define_method, :http do
|
|
14
|
+
http_delegator
|
|
15
|
+
end
|
|
16
|
+
base.send :private, :http
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def api_key api_key
|
|
20
|
+
http.headers "X-Starfighter-Authorization" => api_key
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def send_heartbeat
|
|
24
|
+
http.get "/heartbeat"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def send_venue_heartbeat venue
|
|
28
|
+
http.get "/venues/#{venue}/heartbeat"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def list_stocks venue
|
|
32
|
+
http.get "/venues/#{venue}/stocks"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def get_orderbook venue, stock
|
|
36
|
+
http.get "/venues/#{venue}/stocks/#{stock}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def place_order venue, stock, account:, price:, qty:, direction: "buy", orderType: "limit"
|
|
40
|
+
params = method(__method__).parameters.map(&:last)
|
|
41
|
+
body = params.map { |p| [p, eval(p.to_s)] }.to_h
|
|
42
|
+
http.post "/venues/#{venue}/stocks/#{stock}/orders", body: JSON.dump(body)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def show_order venue, stock, order
|
|
46
|
+
http.post "/venues/#{venue}/stocks/#{stock}/orders/#{order}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def cancel_order venue, stock, order
|
|
50
|
+
http.delete "/venues/#{venue}/stocks/#{stock}/orders/#{order}"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def get_quote venue, stock
|
|
54
|
+
http.get "/venues/#{venue}/stocks/#{stock}/quote"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def list_account_orders venue, account
|
|
58
|
+
http.get "/venues/#{venue}/accounts/#{account}/orders"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def list_account_stock_orders venue, account, stock
|
|
62
|
+
http.get "get/venues/#{venue}/accounts/#{account}/stocks/#{stock}/orders"
|
|
63
|
+
end
|
|
64
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: stock_fighter_mixin
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jing Yang
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-01-03 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
|
+
description: An Stockfighter API wrapper for scripting.
|
|
28
|
+
email:
|
|
29
|
+
- stock_fighter_mixin@ditsing.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- lib/stock_fighter_mixin.rb
|
|
35
|
+
homepage: https://github.com/ditsign/stock_fighter_mixin
|
|
36
|
+
licenses:
|
|
37
|
+
- MIT
|
|
38
|
+
metadata: {}
|
|
39
|
+
post_install_message:
|
|
40
|
+
rdoc_options: []
|
|
41
|
+
require_paths:
|
|
42
|
+
- lib
|
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '0'
|
|
53
|
+
requirements: []
|
|
54
|
+
rubyforge_project:
|
|
55
|
+
rubygems_version: 2.4.5.1
|
|
56
|
+
signing_key:
|
|
57
|
+
specification_version: 4
|
|
58
|
+
summary: An Stockfighter API wrapper.
|
|
59
|
+
test_files: []
|