Code Monkey home page Code Monkey logo

oanda-rest-64bit-cs's Introduction

#Welcome to Rabun wrapper for OANDA REST API

Title img

Hi! We offer you to use our wrapper for the oanda rest api in C#. We tried to implement most of the features of oanda rest api and provide you with a convenient C# interface.

Below you will find a detailed description of working with our wrapper.

#Support tech

This is a portable .NET library. You can use it with: Windows 8/10, Windows Phone, WPF, ASP.NET, Windows Forms.

WARNING! This library doesn't support Windows 10 Universal App now. Windows Universal App support coming soon.

#How to install library

You can build the library or download the package using nuget. You need Visual Studio 2013 or later.

###Build library from source

Get source code from github. You can use release (stable version) or master branch with latest futures, but master sourse may not work.

Open solution at your Visual Studio and run build. All projects must build success.

###Get library from NuGet package

Open NuGet Package Manager console at your Visual Studio and run this command:

PM> Install-Package Rabun.Oanda.Rest.Cs

Tests

You can run Integration and Unit tests. WARNING! You can use own account information: securiry key, accountId. Don't forget change Asserts at tests for your trading.

#How to use it

To start working with services OANDA you need to create an instance of the class xxxEndpoints. Where xxx is the name of the operations you want to perform.

You can use Endpoints class:

OrderEndpoints orderEndpoints = new OrderEndpoints("ec89b162d4a9922c8fa40769c2453d8b-cc1fb522857d46a08a90ef09730343a6", AccountType.practice, 4905675);
List<Order> orders = await orderEndpoints.GetOrders();

or use fabric:

DefaultFactory factory = new DefaultFactory("ec89b162d4a9922c8fa40769c2453d8b-cc1fb522857d46a08a90ef09730343a6", AccountType.practice, 4905675);
RateEndpoints rateEndpoints = factory.GetEndpoint<RateEndpoints>();

List<Price> prices = await rateEndpoints.GetPrices("EUR_USD");

The DefaultFactory provide instances for all xxxEndpoints. Using Factory pattern is the best way to work with this api.

#Implementation

Now implement these services:

  • OrderEndpoints
  • PositionEndpoints
  • RateEndpoints
  • TradeEndpoints
  • TransactionEndpoints

More information about this services you can find at http://developer.oanda.com/rest-live/introduction/

#Examples

##Orders

#####GetOrders

List<Order> orders = await _orderEndpoints.GetOrders();
List<Order> orders = await _orderEndpoints.GetOrders("EUR_USD");
List<Order> orders = await _orderEndpoints.GetOrders("EUR_USD", 5);
List<Order> orders = await _orderEndpoints.GetOrders("EUR_USD", 5, null, null);

#####GetOrder

Order order = await _orderEndpoints.GetOrder(965436841);

#####CreateOrder

OrderOpen order = await _orderEndpoints.CreateOrder("EUR_USD", 777, OandaTypes.Side.buy, OandaTypes.OrderType.marketIfTouched, DateTime.Now.AddDays(1), 1.1630f, null, null, null, null);
OrderOpen order = await _orderEndpoints.CreateMarketOrder("EUR_USD", 999, OandaTypes.Side.buy);
OrderOpen order = await _orderEndpoints.CreateMarketIfTouchedOrder("EUR_USD", 999, OandaTypes.Side.buy, DateTime.Now.AddDays(1), 1.4f);

#####UpdateOrder

OrderMarketIfTouched order = await _orderEndpoints.UpdateOrder(965436841, 333, 1.1f, null, null, null, null, null, null);

#####CloseOrder

OrderClosed order = await _orderEndpoints.CloseOrder(965875303);

##Rates

#####GetInstruments

List<InstrumentModel> instruments = await _rateEndpoints.GetInstruments();
List<InstrumentModel> instruments = await _rateEndpoints.GetInstruments("EUR_USD,CHF_JPY");
List<InstrumentModel> instruments = await _rateEndpoints.GetInstruments("instrument", "EUR_USD");

#####GetPrices

List<Price> prices = await _rateEndpoints.GetPrices("EUR_USD,CHF_JPY");

#####GetCandles

Candle<CandleBidAsk> candle = await _rateEndpoints.GetCandles("EUR_USD");
Candle<CandleBidAsk> candle = await _rateEndpoints.GetCandles("EUR_USD", OandaTypes.GranularityType.D);
Candle<CandleBidAsk> candle = await _rateEndpoints.GetCandles("EUR_USD", OandaTypes.GranularityType.M, 10);
DateTime start = DateTime.UtcNow.AddDays(-1);
DateTime end = DateTime.UtcNow;

Candle<CandleBidAsk> candle = await _rateEndpoints.GetCandles("EUR_USD", OandaTypes.GranularityType.H1, start, end);
Candle<CandleMid> candle = await _rateEndpoints.GetCandlesMid("EUR_USD");
Candle<CandleMid> candle = await _rateEndpoints.GetCandlesMid("EUR_USD", OandaTypes.GranularityType.D);
Candle<CandleMid> candle = await _rateEndpoints.GetCandlesMid("EUR_USD", OandaTypes.GranularityType.M, 10);
DateTime start = DateTime.UtcNow.AddDays(-1);
DateTime end = DateTime.UtcNow;

Candle<CandleMid> candle = await _rateEndpoints.GetCandlesMid("EUR_USD", OandaTypes.GranularityType.H1, start, end);
object candle =
    await
        _rateEndpoints.GetCandles("EUR_USD", OandaTypes.GranularityType.M, 100,
            OandaTypes.CandleFormat.bidask,
            true, null, OandaTypes.WeeklyAlignment.Friday);
DateTime start = DateTime.UtcNow.AddDays(-1);
DateTime end = DateTime.UtcNow;

object candle =
    await
        _rateEndpoints.GetCandles("EUR_USD", OandaTypes.GranularityType.M, start, end,
            OandaTypes.CandleFormat.midpoint,
            true, null, OandaTypes.WeeklyAlignment.Friday);

##Trades

#####GetTrades

List<Trade> trades = await _tradeEndpoints.GetTrades();
List<Trade> trades = await _tradeEndpoints.GetTrades("EUR_USD");
List<Trade> trades = await _tradeEndpoints.GetTrades("EUR_USD", 100);
List<Trade> trades = await _tradeEndpoints.GetTrades("EUR_USD", 100, null, null);

#####GetTrade

Trade trade = await _tradeEndpoints.GetTrade(968541259);

#####UpdateTrade

Trade trade = await _tradeEndpoints.UpdateTrade(968541259, null, 1.29f, null);

#####CloseTrade

TradeClosed trade = await _tradeEndpoints.CloseTrade(968541259);

##Positions

#####GetPositions

List<Position> positions = await _positionEndpoints.GetPositions();

#####GetPosition

Position position = await _positionEndpoints.GetPosition("EUR_USD");

#####ClosePosition

PositionClosed position = await _positionEndpoints.ClosePosition("EUR_USD");

##Transactions

#####GetTransactions

List<Transaction> transactions = await _transactionEndpoints.GetTransactions(null, null, null, "EUR_USD", "");

oanda-rest-64bit-cs's People

Contributors

valeravorobjev avatar sultanovic avatar

Watchers

 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.