DEEPAGI

A Guide to Automating Your Stock Analysis With Python

Mohammad Nurdin

In order for you to use i-Bursa API first, you need to subscribe to the API key provided by DEEPAGI, you may find the registration link here
https://docs.google.com/forms/d/e/1FAIpQLSfJXYZuLQTFF6rMD4HKjIMvzO98evqpS4INCyRLcjcIVLlXLw/viewform.

Once you acquire the API key, you need to install Python and Jupyter Notebook in order to use this notebook as we go through this guide

  1. Python (Windows) > https://www.python.org/ftp/python/3.8.7/python-3.8.7-embed-amd64.zip
  2. Python (macOS) > https://www.python.org/ftp/python/3.8.7/python-3.8.7-macosx10.9.pkg
  3. Python (Linux) > run “sudo apt install python3” in your terminal

After you installed Python, opens up your Command Prompt on your Windows machine or Terminal in your Linux or Mac machine and try running the command “python –version” to check Python availability in your machine.

P/s: Your Python version may not similar to mine, so just proceed with this guide.

command line

Next, you need to install Jupyter Notebook by using pip, the package library for Python. In the same Command Prompt or terminal session, run “pip install notebook” to install Jupyter Notebook

P/s: The output may differs between your installation and mine cause I already have Jupyter in my machine.

command line

Download and put this notebook in the Documents folder of your machine or any folder, and navigate to the folder using “cd” command in your terminal, and then run “jupyter notebook” commands.

command line

Open the ipynb file or this notebook that you have downloaded, and press Run on the next cell to install pandas and requests package to use DEEPAGI i-Bursa API.

pip install pandas requests

Remove YOUR_API_KEY below and replace with the API key provided by DEEPAGI without removing the quotes and run all the cells below.

API_key = YOUR_API_KEY

Getting single stock details.

import requests
import pandas
pandas.options.display.max_rows = 300

stocksdata = requests.get("https://i-bursa.herokuapp.com/getstocksdata?stocksname=MSNIAGA&token=" + API_key)
rec = stocksdata.json()['res']
data = pandas.json_normalize(rec)
del data['index']
data['date'] = (pandas.to_datetime(data['date'], unit='ms').dt.tz_localize('utc')).dt.date
data

jupyter notebook

Get stocks list

stockslist = requests.get("https://i-bursa.herokuapp.com/getstockslist?token=" + API_key)
availablestocks = stockslist.json()['stocks_list']
availablestocks

jupyter notebook

Find uptrend stocks.

uptrend_res = requests.get("https://i-bursa.herokuapp.com/getlatestuptrend?token=" + API_key)
uptrends = uptrend_res.json()['uptrend']
uptrends_pandas = pandas.json_normalize(uptrends)
uptrends_pandas

jupyter notebook

Select DNEX.

macd_res = requests.get("https://i-bursa.herokuapp.com/getlatestMACD?stocksname=DNEX&token=" + API_key)
macd = macd_res.json()['MACD']
macd_pandas = pandas.json_normalize(macd)
macd_pandas

 

jupyter notebook
jupyter notebook

If MACD > MACDhist, high > EMA &  MACD < 0 , you should buy.

Below is the Bollinger Band chart.

macd_stocksplot = macd_res.json()['stocksplot']
macd_stocksplot

jupyter notebook

Copy the text and paste it here, you can get the chart (https://codebeautify.org/base64-to-image-converter).

bollinger band

Entry point, stop loss, and take profit.

pivot_res = requests.get("https://i-bursa.herokuapp.com/getlatestpivot?stocksname=DNEX&token=" + API_key)
pivot = pivot_res.json()['pivot']
pivot_pandas = pandas.json_normalize(pivot)
pivot_pandas

jupyter notebook

If you take classic pivot, you can set your entry point (Classic_S1-close price), stop loss (Classic_S20), and take profit (Classic_R2-Classic_R3).

You can view other API endpoints available here (https://i-bursa.herokuapp.com/docs). Let us know if you got any difficulties or issues using it.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top