Thanks for your query and congratulations on reaching the deploying RL model stage.
I would recommend performing basic steps to deploy on Oanda and then you can extend that on the reinforcement learning.
The basic steps are as follows:
- Connection Testing
I see that you are using tpqoa package. Run the below lines in Jupyter notebook to confirm that the connection is successful
import tpqoa
oanda = tpqoa.tpqoa('oanda.cfg')
oanda.get_account_summary()
You will receive a json of your account details
2. Data retrieval
In this step, we access the data. We try to retrieve EUR_USD data. M5 indicates 5 minute data and price='M' indicates middle. You can change to A for Ask and so on.
data = oanda.get_history(instrument='EUR_USD',
start='2022-05-22 09:00 ',
end='2022-05-23 12:00',
granularity='M5',
price='M')
print(data)
3. Order Placement
The below code will place buy order for 100 units of EUR_USD. To place sell order set units to -100. Note: set the environment to practice in cfg file before placing order. This will ensure that orders are placed in practice environment.
oanda.create_order('EUR_USD', units=100)
Once the above steps run successfully, you can modify the code in RL python file you have shared
1. Connection Setup
You need to place the below code for connection inside initialize method
import tpqoa
oanda = tpqoa.tpqoa('oanda.cfg')
oanda.get_account_summary()
2. schedule_function
The schedule function is from ibridgepy. You need to define the logic for it in Python. That is when you want to call the strategy function such as every 5 minutes
3. Data
You need to change the data call to the one shown below. The end date needs to be dynamically adjusted based on recent date time so that you get the most recent data
data = oanda.get_history(instrument='EUR_USD',
start='2022-05-22 09:00 ',
end='2022-05-23 12:00',
granularity='M5',
price='M')
4. Ordering
Wherever order_target is used, you need to change to the create_order method of oanda.
oanda.create_order('EUR_USD', units=100)
Here the number of units is specified compared to the order target which specified the percentage of the capital required to place an order.
I hope this helps.