Skip to main content

A simpler library for the alapaca trade api

Project description

cira

A simpler library for alpaca-trade-api from Alpaca Markets. Cira is available on pip. Plz give it a star if you like it!

a cira

GitHub stars Tweet

GitHub PyPI PyPI - Python Version

I was interested in using the Alpaca trade API for building a quantitative paper trader. The project is available here.
However after working on this for alomst a year (off and on) I realized that I had alomst build a small library for using the Alpaca API. So I thought that I would make this into a real library so that you can get started with quantitative paper trading as well.

The name cira is the word for a baby alpaca and because this is a simple and small lib I thought it would be a perfect fit.

Getting Started

Installation

You can install it using pip.

pip install cira

Usage

Since the Alpaca trade API need a API key, you need to generate your own key. I recommend keep it in a JSON file which cira needs the path to. You can also set the variables directly or use an environment variable, see the wiki for diffrent the ways. However, it is recommended that you store it in a file just make sure not to upload that file on any public repositories.
key.json

{
  "APCA-API-KEY-ID":"your_pub_key",
  "APCA-API-SECRET-KEY":"your_private_key"
}

then you can start using the lib

import cira
cira.KEY_FILE = "../mypath/key.json"
stock = cira.Stock("TSLA")
stock.buy(1)
stock.sell(1)

New classes with cira v.2!

portfolio = cira.Portfolio() # methods for your portfolio 
exchange = cira.Exchange() # methods for exchange 
stock = cira.Stock("TSLA") # a class for one stock

for a example with the new classes check out this simple index fund

Wiki and docs

To see what more you can do check out the wiki.

I also have an example of how to build a index fund trader with cira or check out paper-trader for my usage of cira.

Versioning & News

v.2.0.0, new structure!

With cira v.2.0.0 has a new structure and classes! With this new classes and structure you will be able to use the library more simply. Checkout the example page on the wiki. The main classes are the Stock, Portfolio and Exchange.

want the old version?

For backwards compatibility I made sure to fork cira in to cira-classic and cira-classic is also available on pypi with pip.

if you find bug plz let me know with a issue. If you know how to solve the problem then you can of course make a pull request and I will take a look at it.

Development

If you want to help develop cira you are more then welcome to do so. Feel free to make a pull request or issue. To install cira with all the dev req.

git clone git@github.com:AxelGard/cira.git
cd cira/
git checkout develop

and know you need to

python3 -m venv env
source env/bin/activate
pip install -e .[dev]

Run tests using pytest. Ensure that you are in the cira dir. But you will need a new key. This key should not only be used for testing or if you don't mind if all of the assets in the portfolio being sold.

touch tests/test_key.json
pytest

Coding style

I'm trying to follow the pep8 standard notation.

I try to make the library to be so intuitive as possible for easy of use.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cira-2.0.0.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

cira-2.0.0-py3-none-any.whl (9.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page