em-nordnet 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +65 -0
- data/LICENSE +22 -0
- data/README.md +66 -0
- data/Rakefile +2 -0
- data/em-nordnet.gemspec +28 -0
- data/lib/em-nordnet.rb +46 -0
- data/lib/em-nordnet/account.rb +27 -0
- data/lib/em-nordnet/api.rb +234 -0
- data/lib/em-nordnet/config.rb +16 -0
- data/lib/em-nordnet/feed/connection.rb +53 -0
- data/lib/em-nordnet/feed/dsl.rb +56 -0
- data/lib/em-nordnet/feed/private.rb +27 -0
- data/lib/em-nordnet/feed/public.rb +43 -0
- data/lib/em-nordnet/goliath/feed_plugin.rb +25 -0
- data/lib/em-nordnet/goliath/private_feed.rb +8 -0
- data/lib/em-nordnet/goliath/public_feed.rb +18 -0
- data/lib/em-nordnet/instrument.rb +27 -0
- data/lib/em-nordnet/order.rb +48 -0
- data/lib/em-nordnet/version.rb +5 -0
- data/spec/em-nordnet/account_spec.rb +34 -0
- data/spec/em-nordnet/api_spec.rb +179 -0
- data/spec/em-nordnet/config_spec.rb +14 -0
- data/spec/em-nordnet/goliath/public_feed_spec.rb +11 -0
- data/spec/em-nordnet/instrument_spec.rb +35 -0
- data/spec/em-nordnet/order_spec.rb +27 -0
- data/spec/em-nordnet_spec.rb +46 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/support/api/headers.rb +15 -0
- data/spec/support/api/results.rb +205 -0
- data/spec/support/api/stubs.rb +137 -0
- data/spec/support/api/urls.rb +112 -0
- data/spec/support/api_helper.rb +4 -0
- data/spec/support/configure_helper.rb +19 -0
- metadata +208 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
def base_url
|
2
|
+
'https://api.test.nordnet.se/next/1'
|
3
|
+
end
|
4
|
+
|
5
|
+
def query(params)
|
6
|
+
querylizer = Proc.new { |k,v| "#{k}=#{v}" }
|
7
|
+
"\\?#{params.sort.map(&querylizer).join('&')}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def login_url
|
11
|
+
Regexp.new base_url+"\\/login\\?auth=(.+)&service=NEXTAPI"
|
12
|
+
end
|
13
|
+
|
14
|
+
def touch_url(session)
|
15
|
+
Regexp.new base_url+"\\/login\\/#{session}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def realtime_access_url
|
19
|
+
Regexp.new base_url+'/realtime_access'
|
20
|
+
end
|
21
|
+
|
22
|
+
def news_sources_url
|
23
|
+
Regexp.new base_url+'/news_sources'
|
24
|
+
end
|
25
|
+
|
26
|
+
def news_items_url params
|
27
|
+
Regexp.new base_url+"\\/news_items#{query(params)}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def news_item_url news_item_id
|
31
|
+
Regexp.new base_url+"\\/news_items\\/#{news_item_id}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def accounts_url
|
35
|
+
Regexp.new base_url+'/accounts'
|
36
|
+
end
|
37
|
+
|
38
|
+
def account_url account_id
|
39
|
+
Regexp.new base_url+"\\/accounts\\/#{account_id}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def ledgers_url account_id
|
43
|
+
Regexp.new base_url+"\\/accounts\\/#{account_id}\\/ledgers"
|
44
|
+
end
|
45
|
+
|
46
|
+
def positions_url account_id
|
47
|
+
Regexp.new base_url+"\\/accounts\\/#{account_id}\\/positions"
|
48
|
+
end
|
49
|
+
|
50
|
+
def orders_url account_id, params = nil
|
51
|
+
url = base_url+"\\/accounts\\/#{account_id}\\/orders"
|
52
|
+
url += query(params) if params
|
53
|
+
Regexp.new url
|
54
|
+
end
|
55
|
+
|
56
|
+
def trades_url account_id
|
57
|
+
Regexp.new base_url+"\\/accounts\\/#{account_id}\\/trades"
|
58
|
+
end
|
59
|
+
|
60
|
+
def instruments_url params
|
61
|
+
Regexp.new base_url+"\\/instruments#{query(params)}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def chart_data_url params
|
65
|
+
Regexp.new base_url+"\\/chart_data#{query(params)}"
|
66
|
+
end
|
67
|
+
|
68
|
+
def lists_url
|
69
|
+
Regexp.new base_url+"\\/lists"
|
70
|
+
end
|
71
|
+
|
72
|
+
def list_items_url list_item_id
|
73
|
+
Regexp.new base_url+"\\/lists\\/#{list_item_id}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def markets_url
|
77
|
+
Regexp.new base_url+'/markets'
|
78
|
+
end
|
79
|
+
|
80
|
+
def trading_days_url market_id
|
81
|
+
Regexp.new base_url+"\\/markets\\/#{market_id}\\/trading_days"
|
82
|
+
end
|
83
|
+
|
84
|
+
def indices_url
|
85
|
+
Regexp.new base_url+'/indices'
|
86
|
+
end
|
87
|
+
|
88
|
+
def ticksizes_url instrument_id
|
89
|
+
Regexp.new base_url+"\\/ticksizes\\/#{instrument_id}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def countries_url derivative_type
|
93
|
+
Regexp.new base_url+"\\/derivatives\\/#{derivative_type}"
|
94
|
+
end
|
95
|
+
|
96
|
+
def underlyings_url derivative_type, country
|
97
|
+
url = base_url+"\\/derivatives\\/#{derivative_type}\\/underlyings\\/#{country}"
|
98
|
+
Regexp.new url
|
99
|
+
end
|
100
|
+
|
101
|
+
def derivatives_url derivative_type, params
|
102
|
+
url = base_url+"\\/derivatives\\/#{derivative_type}\\/derivatives#{query(params)}"
|
103
|
+
Regexp.new url
|
104
|
+
end
|
105
|
+
|
106
|
+
def related_markets_url params
|
107
|
+
Regexp.new base_url+"\\/related_markets#{query(params)}"
|
108
|
+
end
|
109
|
+
|
110
|
+
def order_url account_id, order_id
|
111
|
+
Regexp.new base_url+"\\/accounts\\/#{account_id}\\/orders\\/#{order_id}"
|
112
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
def configure_nordnet
|
2
|
+
Em::Nordnet.configure do |config|
|
3
|
+
config.url = 'https://api.test.nordnet.se'
|
4
|
+
config.user = 'test'
|
5
|
+
config.password = 'test'
|
6
|
+
config.service = 'NEXTAPI'
|
7
|
+
config.pem = <<-CERT
|
8
|
+
-----BEGIN PUBLIC KEY-----
|
9
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5td/64fAicX2r8sN6RP3
|
10
|
+
mfHf2bcwvTzmHrLcjJbU85gLROL+IXclrjWsluqyt5xtc/TCwMTfC/NcRVIAvfZd
|
11
|
+
t+OPdDoO0rJYIY3hOGBwLQJeLRfruM8dhVD+/Kpu8yKzKOcRdne2hBb/mpkVtIl5
|
12
|
+
avJPFZ6AQbICpOC8kEfI1DHrfgT18fBswt85deILBTxVUIXsXdG1ljFAQ/lJd/62
|
13
|
+
J74vayQJq6l2DT663QB8nLEILUKEt/hQAJGU3VT4APSfT+5bkClfRb9+kNT7RXT/
|
14
|
+
pNCctbBTKujr3tmkrdUZiQiJZdl/O7LhI99nCe6uyJ+la9jNPOuK5z6v72cXenmK
|
15
|
+
ZwIDAQAB
|
16
|
+
-----END PUBLIC KEY-----
|
17
|
+
CERT
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: em-nordnet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dennis Rogenius
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: eventmachine
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: em-http-request
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: em-synchrony
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: faraday_middleware-multi_json
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: debugger
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: webmock
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: REST API and Socket Wrapper for Nordnet using Eventmachine
|
127
|
+
email:
|
128
|
+
- denro03@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- .rspec
|
135
|
+
- .rvmrc
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
138
|
+
- LICENSE
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- em-nordnet.gemspec
|
142
|
+
- lib/em-nordnet.rb
|
143
|
+
- lib/em-nordnet/account.rb
|
144
|
+
- lib/em-nordnet/api.rb
|
145
|
+
- lib/em-nordnet/config.rb
|
146
|
+
- lib/em-nordnet/feed/connection.rb
|
147
|
+
- lib/em-nordnet/feed/dsl.rb
|
148
|
+
- lib/em-nordnet/feed/private.rb
|
149
|
+
- lib/em-nordnet/feed/public.rb
|
150
|
+
- lib/em-nordnet/goliath/feed_plugin.rb
|
151
|
+
- lib/em-nordnet/goliath/private_feed.rb
|
152
|
+
- lib/em-nordnet/goliath/public_feed.rb
|
153
|
+
- lib/em-nordnet/instrument.rb
|
154
|
+
- lib/em-nordnet/order.rb
|
155
|
+
- lib/em-nordnet/version.rb
|
156
|
+
- spec/em-nordnet/account_spec.rb
|
157
|
+
- spec/em-nordnet/api_spec.rb
|
158
|
+
- spec/em-nordnet/config_spec.rb
|
159
|
+
- spec/em-nordnet/goliath/public_feed_spec.rb
|
160
|
+
- spec/em-nordnet/instrument_spec.rb
|
161
|
+
- spec/em-nordnet/order_spec.rb
|
162
|
+
- spec/em-nordnet_spec.rb
|
163
|
+
- spec/spec_helper.rb
|
164
|
+
- spec/support/api/headers.rb
|
165
|
+
- spec/support/api/results.rb
|
166
|
+
- spec/support/api/stubs.rb
|
167
|
+
- spec/support/api/urls.rb
|
168
|
+
- spec/support/api_helper.rb
|
169
|
+
- spec/support/configure_helper.rb
|
170
|
+
homepage: https://github.com/denro/em-nordnet
|
171
|
+
licenses: []
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: 1.9.3
|
182
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
|
+
none: false
|
184
|
+
requirements:
|
185
|
+
- - ! '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
requirements: []
|
189
|
+
rubyforge_project:
|
190
|
+
rubygems_version: 1.8.24
|
191
|
+
signing_key:
|
192
|
+
specification_version: 3
|
193
|
+
summary: Nordnet API wrapper using EventMachine
|
194
|
+
test_files:
|
195
|
+
- spec/em-nordnet/account_spec.rb
|
196
|
+
- spec/em-nordnet/api_spec.rb
|
197
|
+
- spec/em-nordnet/config_spec.rb
|
198
|
+
- spec/em-nordnet/goliath/public_feed_spec.rb
|
199
|
+
- spec/em-nordnet/instrument_spec.rb
|
200
|
+
- spec/em-nordnet/order_spec.rb
|
201
|
+
- spec/em-nordnet_spec.rb
|
202
|
+
- spec/spec_helper.rb
|
203
|
+
- spec/support/api/headers.rb
|
204
|
+
- spec/support/api/results.rb
|
205
|
+
- spec/support/api/stubs.rb
|
206
|
+
- spec/support/api/urls.rb
|
207
|
+
- spec/support/api_helper.rb
|
208
|
+
- spec/support/configure_helper.rb
|