Skip to content

Examples demonstrating the use of oandapyV20 (oanda-api-v20)

License

Notifications You must be signed in to change notification settings

hootnot/oandapyV20-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oandapyV20 - examples

This repo contains a number of examples to demonstrate how to use OANDA's REST-V20 API with the oandapyV20 Python API-wrapper.

Setup

Install

Clone the repository:

$ git clone https://github.com/hootnot/oandapyV20-examples

Install oandapyV20 and other pypi-packages the examples depend on. Maybe you want to do this from a virtual environment.

$ pip install -r requirements.txt

Token

Access to the OANDA V20 REST-API requires a token. If you do not have a token you can obtain one. Check developer.oanda.com for details. Edit the file token.txt and put the token in it.

AccountID

If you have a token, you have an account. Edit the file account.txt and put the accountID in it. Verify that it is your V20 accountID!

Warning

Make sure you have made the setup based on a practice account ! Leveraged trading is high risk. Losses can exceed investment!

Examples

All examples can be run from the cloned repo directory as:

$ python src/<example.py>
Source Description
Account  
src/instruments_list.py Get list of tradable instruments for account
Streams  
src/streaming_prices.py Simple streaming prices using pydantic to process records
src/streaming_trans.py Simple streaming transactions
src/concurrent_streaming.py Demonstrate concurrent streaming of prices and events along with the polling of account changes based on gevent greenlets
Data  
src/candle-data.py Retrieve candle data
Orders  
src/market_order.py Placing market orders / logging
src/market_order_request.py Placing market orders using contrib.requests / logging
src/contrib_mo_tp_sl.py Placing market order with takeprofit on-fill and stoploss on-fill
Console  
src/oanda_console.py Console application showing realtime tickdata (Linux/Unix only / python 3 only) CONSOLE_APP
Auto Trading  
src/simplebot.py Simple trading bot based on a moving-average crossover. The bot gets initialized by retrieving the longest MA period of candles. After that new records are fabricated from the stream. When there is a state change an order is placed with a takeprofit and a stoploss order with it. The positions can be traced with the src/oanda_console application.

About this software

The oanda-api-v20 / oandapyV20 software is a personal project. I have no prior or existing relationship with OANDA.

If you have any questions regarding this software, please take a look at the documentation first:

If you still have questions/issues you can open an issue on Gitub: https://github.com/hootnot/oanda-api-v20

About

Examples demonstrating the use of oandapyV20 (oanda-api-v20)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages