Class: Em::Nordnet::Api
- Inherits:
-
Object
show all
- Defined in:
- lib/em-nordnet/api.rb
Defined Under Namespace
Classes: AuthorizationFailureError, InstrumentNotFoundError, InternalServerError, SessionExpiredError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Api
Returns a new instance of Api.
13
14
15
16
|
# File 'lib/em-nordnet/api.rb', line 13
def initialize
@credentials = Nordnet.config.credentials
login
end
|
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
9
10
11
|
# File 'lib/em-nordnet/api.rb', line 9
def credentials
@credentials
end
|
#expires_in ⇒ Object
Returns the value of attribute expires_in.
9
10
11
|
# File 'lib/em-nordnet/api.rb', line 9
def expires_in
@expires_in
end
|
#last_usage_at ⇒ Object
Returns the value of attribute last_usage_at.
9
10
11
|
# File 'lib/em-nordnet/api.rb', line 9
def last_usage_at
@last_usage_at
end
|
#private_feed ⇒ Object
Returns the value of attribute private_feed.
9
10
11
|
# File 'lib/em-nordnet/api.rb', line 9
def private_feed
@private_feed
end
|
#public_feed ⇒ Object
Returns the value of attribute public_feed.
9
10
11
|
# File 'lib/em-nordnet/api.rb', line 9
def public_feed
@public_feed
end
|
#session ⇒ Object
Returns the value of attribute session.
9
10
11
|
# File 'lib/em-nordnet/api.rb', line 9
def session
@session
end
|
Instance Method Details
#account(account_id) ⇒ Object
67
68
69
70
|
# File 'lib/em-nordnet/api.rb', line 67
def account account_id
account_path = path "accounts/#{account_id}"
perform { |conn| conn.get account_path }
end
|
#accounts ⇒ Object
62
63
64
65
|
# File 'lib/em-nordnet/api.rb', line 62
def accounts
accounts_path = path 'accounts'
perform { |conn| conn.get accounts_path }
end
|
#chart_data(params = {}) ⇒ Object
107
108
109
110
|
# File 'lib/em-nordnet/api.rb', line 107
def chart_data params = {}
chart_data_path = path 'chart_data'
perform { |conn| conn.get chart_data_path, params }
end
|
#countries(derivative_type) ⇒ Object
142
143
144
145
|
# File 'lib/em-nordnet/api.rb', line 142
def countries derivative_type
countries_path = path "derivatives/#{derivative_type}"
perform { |conn| conn.get countries_path }
end
|
#create_order(account_id, params = {}) ⇒ Object
162
163
164
165
|
# File 'lib/em-nordnet/api.rb', line 162
def create_order account_id, params = {}
orders_path = path "accounts/#{account_id}/orders"
perform { |conn| conn.post(orders_path) { |req| req.params = params } }
end
|
#derivatives(derivative_type, params = {}) ⇒ Object
152
153
154
155
|
# File 'lib/em-nordnet/api.rb', line 152
def derivatives derivative_type, params = {}
derivatives_path = path "derivatives/#{derivative_type}/derivatives"
perform { |conn| conn.get derivatives_path, params }
end
|
#destroy_order(account_id, order_id) ⇒ Object
172
173
174
175
|
# File 'lib/em-nordnet/api.rb', line 172
def destroy_order account_id, order_id
order_path = path "accounts/#{account_id}/orders/#{order_id}"
perform { |conn| conn.delete(order_path) }
end
|
#indices ⇒ Object
132
133
134
135
|
# File 'lib/em-nordnet/api.rb', line 132
def indices
indices_path = path 'indices'
perform { |conn| conn.get indices_path }
end
|
#instrument_lookup(params = {}) ⇒ Object
97
98
99
100
|
# File 'lib/em-nordnet/api.rb', line 97
def instrument_lookup params = {}
instruments_path = path 'instruments'
perform { |conn| conn.get instruments_path, params }
end
|
#instrument_search(params = {}) ⇒ Object
92
93
94
95
|
# File 'lib/em-nordnet/api.rb', line 92
def instrument_search params = {}
instruments_path = path 'instruments'
perform { |conn| conn.get instruments_path, params }
end
|
#ledgers(account_id) ⇒ Object
72
73
74
75
|
# File 'lib/em-nordnet/api.rb', line 72
def ledgers account_id
ledgers_path = path "accounts/#{account_id}/ledgers"
perform { |conn| conn.get ledgers_path }
end
|
#list_items(list_id) ⇒ Object
117
118
119
120
|
# File 'lib/em-nordnet/api.rb', line 117
def list_items list_id
list_items_path = path "lists/#{list_id}"
perform { |conn| conn.get list_items_path }
end
|
#lists ⇒ Object
112
113
114
115
|
# File 'lib/em-nordnet/api.rb', line 112
def lists
lists_path = path 'lists'
perform { |conn| conn.get lists_path }
end
|
#login ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/em-nordnet/api.rb', line 18
def login
login_path = path 'login'
res = perform! do |conn|
conn.post login_path do |req|
req.params = {service: Nordnet.config.service, auth: credentials}
end
end
if res
@session = res[:session_key]
@expires_in = res[:expires_in]
@public_feed = res[:public_feed]
@private_feed = res[:private_feed]
end
res
end
|
#markets ⇒ Object
122
123
124
125
|
# File 'lib/em-nordnet/api.rb', line 122
def markets
markets_path = path 'markets'
perform { |conn| conn.get markets_path }
end
|
#modify_order(account_id, order_id, params = {}) ⇒ Object
167
168
169
170
|
# File 'lib/em-nordnet/api.rb', line 167
def modify_order account_id, order_id, params = {}
modify_order_path = path "accounts/#{account_id}/orders/#{order_id}"
perform { |conn| conn.put(modify_order_path) { |req| req.params = params } }
end
|
#multiple_instrument_lookup(list) ⇒ Object
102
103
104
105
|
# File 'lib/em-nordnet/api.rb', line 102
def multiple_instrument_lookup list
instruments_path = path 'instruments'
perform { |conn| conn.get instruments_path, list: list}
end
|
#news_item(news_item_id) ⇒ Object
57
58
59
60
|
# File 'lib/em-nordnet/api.rb', line 57
def news_item news_item_id
news_item_path = path "news_items/#{news_item_id}"
perform { |conn| conn.get news_item_path }
end
|
#news_items(params = {}) ⇒ Object
52
53
54
55
|
# File 'lib/em-nordnet/api.rb', line 52
def news_items params = {}
news_items_path = path 'news_items'
perform { |conn| conn.get news_items_path, params }
end
|
#news_sources ⇒ Object
47
48
49
50
|
# File 'lib/em-nordnet/api.rb', line 47
def news_sources
news_sources_path = path 'news_sources'
perform { |conn| conn.get news_sources_path }
end
|
#orders(account_id) ⇒ Object
82
83
84
85
|
# File 'lib/em-nordnet/api.rb', line 82
def orders account_id
orders_path = path "accounts/#{account_id}/orders"
perform { |conn| conn.get orders_path }
end
|
#positions(account_id) ⇒ Object
77
78
79
80
|
# File 'lib/em-nordnet/api.rb', line 77
def positions account_id
positions_path = path "accounts/#{account_id}/positions"
perform { |conn| conn.get positions_path }
end
|
#realtime_access ⇒ Object
42
43
44
45
|
# File 'lib/em-nordnet/api.rb', line 42
def realtime_access
realtime_path = path 'realtime_access'
perform { |conn| conn.get realtime_path }
end
|
157
158
159
160
|
# File 'lib/em-nordnet/api.rb', line 157
def related_markets params = {}
related_markets_path = path "related_markets"
perform { |conn| conn.get related_markets_path, params }
end
|
#ticksizes(instrument_id) ⇒ Object
137
138
139
140
|
# File 'lib/em-nordnet/api.rb', line 137
def ticksizes instrument_id
ticksize_path = path "ticksizes/#{instrument_id}"
perform { |conn| conn.get ticksize_path }
end
|
#touch ⇒ Object
37
38
39
40
|
# File 'lib/em-nordnet/api.rb', line 37
def touch
touch_path = path "login/#{session}"
perform { |conn| conn.put touch_path }
end
|
#trades(account_id) ⇒ Object
87
88
89
90
|
# File 'lib/em-nordnet/api.rb', line 87
def trades account_id
trades_path = path "accounts/#{account_id}/trades"
perform { |conn| conn.get trades_path }
end
|
#trading_days(market_id) ⇒ Object
127
128
129
130
|
# File 'lib/em-nordnet/api.rb', line 127
def trading_days market_id
trading_days_path = path "markets/#{market_id}/trading_days"
perform { |conn| conn.get trading_days_path }
end
|
#underlyings(derivative_type, country) ⇒ Object
147
148
149
150
|
# File 'lib/em-nordnet/api.rb', line 147
def underlyings derivative_type, country
underlyings_path = path "derivatives/#{derivative_type}/underlyings/#{country}"
perform { |conn| conn.get underlyings_path }
end
|