Skip to main content

Algorithmic Trading API

Backtest, forward tests and deploy trading algorithms and strategies on binance spot, futures and nft markets and other cryptocurrency exchanges, including arbitrage.

  • Daily Close Prices
  • Daily Logarithmic Returns, Mean Returns
  • Tangency Portfolio with optimal weights
  • Market Capitalisation
  • Annualised Risk σ, Variance and Return
  • Correlation Matrix and Covariance
  • Systematic & Unsystematic Variance
  • Sharpe, beta, CAPM, alpha

Installation

pip install atapi 

Instructions on how to setup a your API key for the spot testnet:

Binance Spot API Key

Export as environment variables:

Bash/Sh/Zsh:

export BINANCE_API_KEY='your_api_key'           
export BINANCE_API_SECRET='your_secret_key'      

# Check
echo $BINANCE_API_KEY
echo $BINANCE_API_SECRET

Powershell:

$env:BINANCE_API_KEY = 'your_api_key'          
$env:BINANCE_API_SECRET = 'your_secret_key'    

# Check
$env:BINANCE_API_KEY
$env:BINANCE_API_KEY

Run:

python -m atapi
Welcome to the Algorithmic Trading API. Type help/? for commands.

atf🖖

Examples (See Wiki for More)

atf🖖 help

Documented commands (type help <topic>):
========================================
assets_close        correlation  marketcap_summary  returns      stats_mcap
balance             covariance   mean_returns       servertime   weights_cwi
bye                 help         normalized         stats        weights_ewi
circulating_supply  marketcap    optimal_weights    stats_index  weights_pwi
atf🖖 returns
            BTCUSDT  ETHUSDT  BNBUSDT  XRPUSDT  TRXUSDT  LTCUSDT      TP
Date
2021-01-23  -0.0267   0.0008   0.0004  -0.0018   0.0235   0.0001  0.0004
2021-01-24   0.0057   0.1212   0.0221   0.0063   0.0250   0.0240  0.0221
2021-01-25  -0.0002  -0.0551   0.0002  -0.0215  -0.0168  -0.0283  0.0002
2021-01-26   0.0066   0.0358   0.0001   0.0029   0.0000  -0.0177  0.0001
2021-01-27  -0.0669  -0.0975  -0.0231  -0.0692  -0.0437  -0.0952 -0.0231
...             ...      ...      ...      ...      ...      ...     ...
2022-06-01  -0.0648  -0.0660  -0.0660  -0.0578  -0.0101  -0.0870 -0.0660
2022-06-02   0.0215   0.0088   0.0260   0.0187   0.0091   0.0283  0.0260
2022-06-03  -0.0250  -0.0327  -0.0320  -0.0379  -0.0389  -0.0299 -0.0320
2022-06-04   0.0055   0.0165   0.0090   0.0054  -0.0083   0.0174  0.0090
2022-06-05  -0.0003   0.0005  -0.0013   0.0025  -0.0022   0.0016 -0.0013

[499 rows x 7 columns]
atf🖖 correlation
         BTCUSDT  ETHUSDT  BNBUSDT  XRPUSDT  TRXUSDT  LTCUSDT     TP
BTCUSDT   1.0000   0.8185   0.6730   0.6215   0.6770   0.8043 0.6730
ETHUSDT   0.8185   1.0000   0.6970   0.6390   0.6892   0.8268 0.6970
BNBUSDT   0.6730   0.6970   1.0000   0.5832   0.6057   0.6896 1.0000
XRPUSDT   0.6215   0.6390   0.5832   1.0000   0.6422   0.7094 0.5832
TRXUSDT   0.6770   0.6892   0.6057   0.6422   1.0000   0.7249 0.6057
LTCUSDT   0.8043   0.8268   0.6896   0.7094   0.7249   1.0000 0.6896
TP        0.6730   0.6970   1.0000   0.5832   0.6057   0.6896 1.0000
atf🖖 stats
         Return   Risk  Sharpe  Variance  Sys. Var.  Unsys. Var.   beta   CAPM   alpha
BTCUSDT -0.0721 0.7503 -0.1374    0.5630     0.6433      -0.0803 0.3964 0.5978 -0.6699
ETHUSDT  0.2794 0.9686  0.2564    0.9382     0.8600       0.0782 0.5299 0.7887 -0.5093
BNBUSDT  1.4609 1.2739  1.1224    1.6229     1.6229      -0.0000 1.0000 1.4609  0.0000
XRPUSDT  0.2698 1.3363  0.1787    1.7857     0.9929       0.7928 0.6118 0.9058 -0.6359
TRXUSDT  0.7560 1.1559  0.6272    1.3360     0.8919       0.4441 0.5496 0.8168 -0.0608
LTCUSDT -0.5629 1.1156 -0.5324    1.2445     0.9801       0.2644 0.6039 0.8945 -1.4574
TP       1.4609 1.2739  1.1224    1.6229     1.6229      -0.0000 1.0000 1.4609  0.0000

Development

Run:

cd atapi
pip install .[dev]

Project

https://github.com/streetyoga/atapi

License

MIT

Metadata

Release files for atapi 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for atapi 0.1.2
File Size Uploaded Provenance Actions
atapi-0.1.2.tar.gz 11.9 kB Without provenance Details for atapi-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for atapi 0.1.2
File Interpreter ABI Platform Actions
atapi-0.1.2-py3-none-any.whl Python 3 none any Details for atapi-0.1.2-py3-none-any.whl

Total release size: 20.5 kB

Release files / atapi-0.1.2.tar.gz

Download URL atapi-0.1.2.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1eac520ab2e3edf8a95632db749f155d3e57c494aafae44a470e24ed61ad246d
BLAKE2b-256 checksum
How to use checksums
dce3ef8dedcadf4da6bfe8e0b3f6fb45e426f1fc0f35f399d70548380bd20cd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / atapi-0.1.2-py3-none-any.whl

Download URL atapi-0.1.2-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bbb7026372050cfe091cb5315ce65ca85a649e2dc2306e38ee9719ca6af01cc
BLAKE2b-256 checksum
How to use checksums
d2cb4203ac23172b41aba6a6244b189917efcd6661c7d5e83ebc2a0005b9eaa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Security for atapi 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page