Freetrade
Freetrade is a free stock investing app, where you can invest your money in various UK stocks, US stocks, and ETFs. There isn’t an official API as the time of writing. So out of curiosity, I started to research if there is an unofficial RESTful API to get the relevant information such as, bid price, asking price and Dividend information. Luckily, I found an unofficial RESTful API called FinKi from Freetrade forum, and I wrote a very basic wrapper around this API
How to get API key
In order to to obtain API key, you will need to email HELLO@FINKI.IO to request for API key. Of course, ask nicely!
How to get Freetrade API wrapper
After getting your API key, you are almost ready to go. Firstly, you need to pull the source file called “FreeTradeWrapper.py” from my GitHub page. Currently, I haven’t uploaded this package on PyPI yet, but I will upload the package down the line. In addition, this wrapper supports Python 3.6+ and the only dependency required for this wrapper is “requests”, which comes with Python 3.6 and above.
How to use Freetrade API wrapper
Firstly, import the “FreeTradeWrapper”
import sys
sys.path.append('The location of FreeTradeWrapper.py file')
from FreeTrade import FreeTrade
Secondly, Initialise the session with your Finki API keys and your google sheet credential Json file, and then you can call functions to get various data point, such as ask price, bid price and dividend information by using isin reference number or use stock’s symbol. The isin reference number and stock’s symbol of different shares that Freetrade offers can be found in the following google sheet:
API_key = "Your_API_Key"
gsheet_json = "Your_google_sheet_credential.json"sess = FreeTrade(API_key, gsheet_json)# To get bid price
sess.get_bid_price('isin_reference_number')# To get ask price
sess.get_ask_price('isin_reference_number')# To get currency of a stock
sess.get_currency('isin_reference_number')# To get dividend information
sess.get_dividendData('isin_reference_number')# To get bid, ask price and currency in a dictionary format
sess.get_all_info('isin_reference_number')
Final thoughts
The wrapper is still in its infant stage, so there are a lot can be done and many functionalities can be added to the wrapper. If you have any thoughts and suggestions, please leave in the comment section below.
In the meantime, please share with your friends if you enjoy this article, and check out some of my other articles down below.