Sha256: e11da3509c1c87a2654703f251b6a83790512036b60d585acf6a9fe42347aff3
Contents?: true
Size: 1.19 KB
Versions: 5
Compression:
Stored size: 1.19 KB
Contents
require 'spec_helper' require 'support/client_helper' describe "OandaAPI::Resource::Position" do let(:account) { ClientHelper.account } it "gets all open positions", :vcr do VCR.use_cassette("account(id).positions.get") do ClientHelper.create_trade positions = account.positions.get expect(positions.first).to be_an OandaAPI::Resource::Position end end it "gets the position for an instrument", :vcr do VCR.use_cassette("account(id).positions(instrument).get") do ClientHelper.create_trade(instrument: "USD_JPY") position = account.positions("USD_JPY").get expect(position).to be_an OandaAPI::Resource::Position end end it "closes an existing position", :vcr do VCR.use_cassette("account(id).positions(instrument).close") do ClientHelper.create_trade(instrument: "USD_JPY") # Verify we have an open position. position = account.position("USD_JPY").get expect(position).to be_an OandaAPI::Resource::Position account.position("USD_JPY").close # Verify that the position has been closed. positions = account.positions.get expect(positions.map(&:instrument)).to_not include "USD_JPY" end end end
Version data entries
5 entries across 5 versions & 1 rubygems