Getting Started

This example will get you started with downloading and setting up the Pax Financial Examples package, show you how to sign up with Pax Financial and find your API key, and then guide you through a simple example in which we use the Pax Financial API to download some historical financial price data.

Downloading and Setting Up the Pax Financial Examples Software Package

  1. Clone the git repository and execute the setup.py script.

    clone https://github.com/JustinGirard/PaxFinancialExamples.git
    cd PaxFinancialExamples
    python3 setup.py
    
  2. Add the PaxFinancialExamples/paxdk directory to your system's PYTHONPATH, by running from a terminal

    export PYTHONPATH = $PYTHONPATH:/<path>/PaxFinancialExamples/paxdk
    

Signing Up With Pax Financial

  1. In a web browser, navigate to the Pax Financial home page and follow the Log In link.
  2. Sign in with Google or your e-mail, according to the instructions.

Finding your API key

Once you have signed up and signed in, you are ready to locate your API key.

  1. In the top left corner of the screen that appears when you sign in, there is a hamburger icon (three stacked horizontal lines). Click this icon. A panel should slide out from the left side of the screen. You will see your API key.

  2. Copy the API key. Open the file PaxFinancialExamples/.config with an editor and replace the API key in the file with your API key.

Once you have your API key entered into the .config file, you are ready to execute the first example of using the Pax Financial API.

A First Example: Reading Financial Data

In our first example of the use of the Pax Financial API we will read some historical price data and display it.

We import the Pax Development Kit and instantiate the Pax Financial API:

import paxdk

import json
with open("../.config") as f:
    data = json.load(f)
api_key = data['api_key']

pq = paxdk.PaxFinancialAPI(url_version='dev',api_key=api_key)
PaxFinancialAPI v4 loaded!

We use the Pax Financial API to read some historical hourly price data about the Bitcoin/US dollar exchange rate, and we display the hour bars we obtain. An hour bar corresponds to a one-hour period and contains the opening price, closing price, high price, and low price for that period. We display the hour bars data as a Pandas dataframe.

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