<jupyter_start><jupyter_text>Position Management  Get a List of All Open Positions`get_positions(self, account_id, **params)`<jupyter_code>from datetime import datetime, timedelta
import pandas as pd
import oandapy
import configparser

config = configparser.ConfigParser()
config.read('../config/config_v1.ini')
account_id = config['oanda']['account_id']
api_key = config['oanda']['api_key']

oanda = oandapy.API(environment="practice", 
                    access_token=api_key)
trade_expire = datetime.now() + timedelta(days=1)
trade_expire = trade_expire.isoformat("T") + "Z"
fx_list = ["AUD_USD", "NZD_USD", "USD_JPY"]
for oo in fx_list:
    response = oanda.create_order(account_id,
                                  instrument = oo,
                                  units=1000,
                                  side="buy",
                                  type="market",
                                  expiry=trade_expire)

response = oanda.get_positions(account_id)
print(response)
pd.DataFrame(response['positions'])<jupyter_output><empty_output><jupyter_text>Get the Position for An Instrument`get_position(self, account_id, instrument, **params)`<jupyter_code>response = oanda.get_position(account_id, 
                              instrument="USD_JPY")
print(response)<jupyter_output>{'avgPrice': 115.204, 'units': 1000, 'side': 'buy', 'instrument': 'USD_JPY'}<jupyter_text>Close an Existing Position`close_position(self, account_id, instrument, **params)`<jupyter_code>response = oanda.close_position(account_id, 
                                instrument="USD_JPY")
print(response)
response = oanda.get_positions(account_id)
pd.DataFrame(response['positions'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11981297486849796, 'fraction_numerical': 0.009351256575102279, 'mean_word_length': 3.446753246753247, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '38724', 'license': 'MIT', 'n_tokens_mistral': 568, 'n_tokens_neox': 525, 'n_words': 89, 'path': 'Oanda v1 REST-oandapy/06.00 Position Management.ipynb', 'repo_name': 'anthonyng2/FX-Trading-with-Python-and-Oanda', 'size': '1711'}