<jupyter_start><jupyter_text>Bonus Material I  FOREX LABS ENDPOINTS*Note: According to the documentation materials in these section are under development. So it may change at any point in time or become invalid*<jupyter_code>import pandas as pd
%matplotlib inline
import seaborn as sns
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)<jupyter_output><empty_output><jupyter_text>Obtaining Historical Economic Calendar<jupyter_code>calendar = oanda.get_eco_calendar(instrument="EUR_USD", period=86400)
print(calendar)
df = pd.DataFrame(calendar)
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='s')
df.tail(10)<jupyter_output><empty_output><jupyter_text>***  Historical Position Ratios<jupyter_code>response = oanda.get_historical_position_ratios(instrument='USD_JPY', 
                                                period=60)
print(response['data']['USD_JPY']['data'])
df = pd.DataFrame(response['data']['USD_JPY']['data'])
df.columns = ["Timestamp", "Long_pos_ratio", "exchange_rate"]
df["Timestamp"] = pd.to_datetime(df['Timestamp'], unit='s')
df
df = df.set_index("Timestamp")
df['Long_pos_ratio'].plot();<jupyter_output><empty_output><jupyter_text>***  Get Historical Spread<jupyter_code>response = oanda.get_historical_spreads(instrument='GBP_USD', period=600)
print(response)<jupyter_output>{'avg': [[1485820800, 2.95722], [1485821700, 2.763]], 'max': [[1485820800, 4], [1485821700, 3.8]], 'min': [[1485820800, 2.3], [1485821700, 2.3]]}<jupyter_text>***  Commitments of Traders<jupyter_code>response = oanda.get_commitments_of_traders(instrument='USD_CAD')
print(response['USD_CAD'][:10])<jupyter_output>[{'unit': 'Contracts Of CAD 100,000', 'ncs': '15224', 'price': '1.000845', 'date': 1199768400, 'oi': '82454', 'ncl': '31648'}, {'unit': 'Contracts Of CAD 100,000', 'ncs': '15101', 'price': '1.010115', 'date': 1200373200, 'oi': '81827', 'ncl': '22866'}, {'unit': 'Contracts Of CAD 100,000', 'ncs': '16786', 'price': '1.02546', 'date': 1200978000, 'oi': '86378', 'ncl': '24463'}, {'unit': 'Contracts Of CAD 100,000', 'ncs': '21653', 'price': '1.019535', 'date': 1201582800, 'oi': '90907', 'ncl': '25948'}, {'unit': 'Contracts Of CAD 100,000', 'ncs': '20363', 'price': '1.000095', 'date': 1202187600, 'oi': '93574', 'ncl': '30603'}, {'unit': 'Contracts Of CAD 100,000', 'ncs': '22956', 'price': '0.999475', 'date': 1202792400, 'oi': '101187', 'ncl': '43391'}, {'unit': 'Contracts Of CAD 100,000', 'ncs': '21440', 'price': '1.005535', 'date': 1203397200, 'oi': '95614', 'ncl': '33387'}, {'unit': 'Contracts Of CAD 100,000', 'ncs': '24139', 'price': '1.002335', 'date': 1204002000, 'oi': '110073', 'ncl': [...]<jupyter_text>***  Orderbook<jupyter_code>response = oanda.get_orderbook(instrument="EUR_USD", period=1)
pd.DataFrame(response)
pd.DataFrame(response['1485820801']['price_points'])<jupyter_output><empty_output><jupyter_text>***  Auto Chartist<jupyter_code>response = oanda.get_autochartist()
pd.DataFrame(response['signals'][:5])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20074696545284781, 'fraction_numerical': 0.12573918456271396, 'mean_word_length': 7.639784946236559, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '139129', 'license': 'MIT', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1189, 'n_words': 236, 'path': 'Oanda v1 REST-oandapy/09.00 Bonus Materials I.ipynb', 'repo_name': 'anthonyng2/FX-Trading-with-Python-and-Oanda', 'size': '3213'}