pyoanda package

Submodules

pyoanda.client module

class pyoanda.client.Client(environment, account_id=None, access_token=None, json_options=None)[source]

Bases: object

API_VERSION = 'v1'
close_order(order_id)[source]

See more: http://developer.oanda.com/rest-live/orders/#closeOrder

close_position(instrument)[source]

Close an existing position

instrument : string
The instrument to close the position for.

See more: http://developer.oanda.com/rest-live/positions/#closeExistingPosition

close_trade(trade_id)[source]

Close an open trade.

trade_id : int
The id of the trade to close.

See more: http://developer.oanda.com/rest-live/trades/#closeOpenTrade

create_account(currency=None)[source]

Create a new account.

This call is only available on the sandbox system. Please create accounts on fxtrade.oanda.com on our production system.

See more: http://developer.oanda.com/rest-sandbox/accounts/#-a-name-createtestaccount-a-create-a-test-account

create_order(order)[source]

See more: http://developer.oanda.com/rest-live/orders/#createNewOrder

get_accounts(username=None)[source]

Get a list of accounts owned by the user.

username : string
The name of the user. Note: This is only required on the sandbox, on production systems your access token will identify you.

See more: http://developer.oanda.com/rest-sandbox/accounts/#-a-name-getaccountsforuser-a-get-accounts-for-a-user

get_credentials()[source]

See more: http://developer.oanda.com/rest-live/accounts/

get_instrument_history(instrument, candle_format='bidask', granularity='S5', count=500, daily_alignment=None, alignment_timezone=None, weekly_alignment='Monday', start=None, end=None)[source]

See more: http://developer.oanda.com/rest-live/rates/#retrieveInstrumentHistory

get_instruments()[source]

See more: http://developer.oanda.com/rest-live/rates/#getInstrumentList

get_order(order_id)[source]

See more: http://developer.oanda.com/rest-live/orders/#getInformationForAnOrder

get_orders(instrument=None, count=50)[source]

See more: http://developer.oanda.com/rest-live/orders/#getOrdersForAnAccount

get_position(instrument)[source]

Get the position for an instrument.

instrument : string
The instrument to get the open position for.

See more: http://developer.oanda.com/rest-live/positions/#getPositionForInstrument

get_positions()[source]

Get a list of all open positions.

See more: http://developer.oanda.com/rest-live/positions/#getListAllOpenPositions

get_prices(instruments, stream=True)[source]

See more: http://developer.oanda.com/rest-live/rates/#getCurrentPrices

get_trade(trade_id)[source]

Get information on a specific trade.

trade_id : int
The id of the trade to get information on.

See more: http://developer.oanda.com/rest-live/trades/#getInformationSpecificTrade

get_trades(max_id=None, count=None, instrument=None, ids=None)[source]

Get a list of open trades

max_id : int
The server will return trades with id less than or equal to this, in descending order (for pagination)
count : int
Maximum number of open trades to return. Default: 50 Max value: 500
instrument : str
Retrieve open trades for a specific instrument only Default: all
ids : list
A list of trades to retrieve. Maximum number of ids: 50. No other parameter may be specified with the ids parameter.

See more: http://developer.oanda.com/rest-live/trades/#getListOpenTrades

get_transaction(transaction_id)[source]

Get information on a specific transaction.

transaction_id : int
The id of the transaction to get information on.

See more: http://developer.oanda.com/rest-live/transaction-history/#getInformationForTransaction http://developer.oanda.com/rest-live/transaction-history/#transactionTypes

get_transaction_history(max_wait=5.0)[source]

Download full account history.

Uses request_transaction_history to get the transaction history URL, then polls the given URL until it’s ready (or the max_wait time is reached) and provides the decoded response.

max_wait : float
The total maximum time to spend waiting for the file to be ready; if this is exceeded a failed response will be returned. This is not guaranteed to be strictly followed, as one last attempt will be made to check the file before giving up.

See more: http://developer.oanda.com/rest-live/transaction-history/#getFullAccountHistory http://developer.oanda.com/rest-live/transaction-history/#transactionTypes

get_transactions(max_id=None, count=None, instrument='all', ids=None)[source]

Get a list of transactions.

max_id : int
The server will return transactions with id less than or equal to this, in descending order (for pagination).
count : int
Maximum number of open transactions to return. Default: 50. Max value: 500.
instrument : str
Retrieve open transactions for a specific instrument only. Default: all.
ids : list
A list of transactions to retrieve. Maximum number of ids: 50. No other parameter may be specified with the ids parameter.

See more: http://developer.oanda.com/rest-live/transaction-history/#getTransactionHistory http://developer.oanda.com/rest-live/transaction-history/#transactionTypes

request_transaction_history()[source]

Request full account history.

Submit a request for a full transaction history. A successfully accepted submission results in a response containing a URL in the Location header to a file that will be available once the request is served. Response for the URL will be HTTP 404 until the file is ready. Once served the URL will be valid for a certain amount of time.

See more: http://developer.oanda.com/rest-live/transaction-history/#getFullAccountHistory http://developer.oanda.com/rest-live/transaction-history/#transactionTypes

update_order(order_id, order)[source]

See more: http://developer.oanda.com/rest-live/orders/#modifyExistingOrder

update_trade(trade_id, stop_loss=None, take_profit=None, trailing_stop=None)[source]

Modify an existing trade.

Note: Only the specified parameters will be modified. All other parameters will remain unchanged. To remove an optional parameter, set its value to 0.

trade_id : int
The id of the trade to modify.
stop_loss : number
Stop Loss value.
take_profit : number
Take Profit value.
trailing_stop : number
Trailing Stop distance in pips, up to one decimal place

See more: http://developer.oanda.com/rest-live/trades/#modifyExistingTrade

pyoanda.exceptions module

exception pyoanda.exceptions.BadCredentials[source]

Bases: Exception

exception pyoanda.exceptions.BadRequest[source]

Bases: Exception

pyoanda.order module

class pyoanda.order.Order(**kwargs)[source]

Bases: object

check()[source]

Logic extracted from: http://developer.oanda.com/rest-live/orders/#createNewOrder

Module contents