You want to look at how brokers are made. here are some examples https://github.com/mementum/backtrader/tree/master/backtrader/brokers
then feeds in here : https://github.com/mementum/backtrader/tree/master/backtrader/feeds
In all of these links there are examples of how to use live trading for Oanda or other providers. you can inspire your work based on the implementation of the latters.
I hope it helps.