Instantly Getting Started on Google Colab

This notebook is intended as a one page sharable introduction to the PaxFinancial SDK. It will get you started, with some data, so you can begin to consider more advanced examples. This specific example is meant to be run on google collabratory and may not be suited for a local installation. To install on a general system see paxfinancial.ai . To view this directly on google colab, please visit The Colab Notebook.

First, we will need to clone the Pax Financial Examples repo locally, so we can use it to display some data.

from google.colab import drive
drive.mount("/content/gdrive")

2. Download the Pax Financial Examples repository

Second, we will pull the latest examples repository, which includes a deployment of the paxdk.

! mkdir "gdrive/My Drive/pax_financial_example/"
mkdir: cannot create directory ‘gdrive/My Drive/pax_financial_example/’: File exists
%cd "gdrive/My Drive/pax_financial_example/"
/content/gdrive/My Drive/pax_financial_example
! git clone https://github.com/JustinGirard/PaxFinancialExamples.git
Cloning into 'PaxFinancialExamples'...
remote: Enumerating objects: 250, done.
remote: Counting objects: 100% (250/250), done.
remote: Compressing objects: 100% (133/133), done.
remote: Total 250 (delta 86), reused 242 (delta 78), pack-reused 0
Receiving objects: 100% (250/250), 1.44 MiB | 3.22 MiB/s, done.
Resolving deltas: 100% (86/86), done.
! ls "PaxFinancialExamples"
docs  examples  paxdk  README.md  setup.py  tests

3. Pull Some Example Data

Using the supplied api key, you can now pull some data. In this example we will look at minute level data from AAPL and compare it with BTCUSDT in the last few days.

3.1.1 Import the paxdk library

import sys
sys.path.append("/content/gdrive/My Drive/pax_financial_example/PaxFinancialExamples/paxdk/")
import paxdk
PaxFinancialAPI v4 loaded!
api_key = 'PUT_IN_YOUR_API_KEY'
pq = paxdk.PaxFinancialAPI(url_version='dev',api_key=api_key)

3.1.2 Display financial data

import pandas as pd
import datetime

bars = pq.get_historical_hour({'api_key':api_key,
                                'time_in':datetime.datetime(2020,4,1,10),
                                'time_end':datetime.datetime(2020,4,1,12),
                                'Ticker':'BTCUSDT',
                                                             },remote=True)
df=pd.DataFrame(bars)
df[['DateTime','Ticker','OpenPrice','ClosePrice','HighPrice','LowPrice']]
DateTime Ticker OpenPrice ClosePrice HighPrice LowPrice
0 2020-04-01 10:00:00 BTCUSDT 6298.74 6295.03 6318.89 6288.02
1 2020-04-01 11:00:00 BTCUSDT 6295.03 6294.25 6301.76 6271.20
2 2020-04-01 12:00:00 BTCUSDT 6294.25 6217.51 6332.16 6215.66