Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Eventmachine wrapper for the Nordnet API

branch: master

fixes specs

latest commit 6086357e2f
Dennis Rogenius authored
lib fixes specs
spec fixes specs
.gitignore Initial commit
.rspec Initial import
.rvmrc bundle init
Gemfile bundle init
Gemfile.lock minors
LICENSE bundle init
README.md Update README.md
Rakefile bundle init
em-nordnet.gemspec Restructured feeds and added Private feed,
README.md

Em::Nordnet

Eventmachine driven wrapper for the Nordnet REST and Feed API. Comes with a golith plugin for connecting to the feed sockets.

Installation

Add this line to your application's Gemfile:

gem 'em-nordnet'

And then execute:

$ bundle

Or install it yourself as:

$ gem install em-nordnet

Usage

Configuration

After installing the gem you can configure it with your own credentials

Em::Nordnet.configure do |config|
  config.url = 'https://api.test.nordnet.se'
  config.user = 'john'
  config.password = 'doe'
  config.service = 'NEXTAPI'
  config.pem = <<-CERT
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkq...
-----END PUBLIC KEY-----
  CERT
end

The configuration may be accessed by Em::Nordnet.config

Models

Em::Nordnet comes with a few models to make actions more Object-oriented

Em::Nordnet::Instrument
Em::Nordnet::Account
Em::Nordnet::Order

REST API

Private Feed

Public Feed

Goliath Plugins

The Gem comes with two plugins to use with Goliath, one for the PublicFeed and one for the PrivateFeed.

require 'goliath'
require 'em-nordnet'
require 'oj'

Em::Nordnet.configure do |config|
...
end

class PriceSubscribe < Goliath::API
  plugin Em::Nordnet::Goliath::PublicFeed
  use Goliath::Rack::Params

  def response(env)
    instrument = Em::Nordnet::Instrument.search(params[:symbol]).first
    Em::Nordnet::Goliath::PublicFeed.subscribe :price, instrument do |data|
      puts "do something with the #{data}"
    end
  end
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.