Giter Club home page Giter Club logo

scalanda's Introduction

scalanda

Build Status Coverage Status Codacy Badge

Scalanda is a light-weight Scala/Akka/Spray-based wrapper for Oanda's REST and Stream APIs, which supports completely asynchronous non-blocking communication with the API. If you are using (or planning to use) Oanda as a broker for your automated trading needs, this library might be of interest.

Install

If you are using sbt just drop this dependency into your build.sbt:

libraryDependencies += "com.msilb" %% "scalanda" % "0.3.7"

Usage

For the full description of Oanda's REST and Stream APIs please consult their great documentation.

Creating an Instance of the REST Connector

From within your Akka system instantiate the REST connector actor like this:

val restConnector = system.actorOf(RestConnector.props(Practice, Some(authTokenPractice), practiceAccountId))

where:

  • Practice indicates you want to connect to Oanda's fxTrade Practice environment. Other possible values are SandBox and Production.
  • authTokenPractice is your Personal Access Token. For details how to obtain one, please see here. Note: SandBox environment does not require authentication, hence just use None
  • practiceAccountId is your fxTrade Practice account ID.

Sending Requests to the REST Connector

After creating an instance of the REST connector you can use it from within your trading actors to send requests to the API, e.g. to create a market order to buy 10,000 units of EUR/USD send this message to your restConnector:

restConnector ! CreateOrderRequest("EUR_USD", 10000, Buy, Market)

Once the request is completed restConnector will reply with an instance of CreateOrderResponse containing details of the successfully created trade. Check out the full list of possible request and response types.

Subscribing for Price and Event Streams Using the Stream API

Create a new connector actor for the Stream API and send Connect message to it:

val streamingConnector = system.actorOf(StreamingConnector.props)
streamingConnector ! Connect(Practice, Some(authTokenPractice))

then wait until streamingConnector responds with the ConnectionEstablished message. Register listeners that should be notified of price tick or event updates by sending

streamingConnector ! AddListeners(Set(listener1, listener2, listener3))

to the streamingConnector.

Finally, subscribe for the price stream with

streamingConnector ! StartRatesStreaming(accountId, instruments, sessionIdOpt)

or for the events stream with

streamingConnector ! StartEventsStreaming(accountIdsOpt)

For further information on request / response parameters see Oanda Stream API specification.

scalanda's People

Contributors

msilb avatar nvollmar avatar

Watchers

James Cloos avatar Jordan Engbers avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.