simple-fxtrade
Version:
A node js wrapper for the Oanda Rest v20 api to make things really simple
18 lines (13 loc) • 602 B
text/coffeescript
{omit, validate} = require './utils'
# GET /accounts/:accountId/[positions[/:id]|openPositions]
exports.positions = (req = {}) ->
{id, open} = req
route = switch
when id? then "accounts/#{@options.accountId}/positions/#{id}"
when open then "accounts/#{@options.accountId}/openPositions"
else "accounts/#{@options.accountId}/positions"
return @request req, route
# PUT /accounts/:accountId/positions/:id/close
exports.positions.close = (req = {}) ->
validate req, ['id']
return @('put').request body: omit(req, 'id'), "accounts/#{@options.accountId}/positions/#{req.id}/close"