Skip to main content

Python package, for communicating with Alpaca Markets REST API.

Project description

project-logo

PY-ALPACA-API

Unlock Alpacas Power with Seamless API Integration"

license last-commit repo-top-language repo-language-count


Table of Contents

Overview

The py-alpaca-api project is a Python library that simplifies interaction with the Alpaca API. It provides a robust interface, encapsulated in the PyAlpacaApi class, enabling developers to access Alpaca Market API trading functionalities effortlessly. By utilizing data classes for orders, assets, and accounts, the project abstracts away complexities, enhancing flexibility in processing API responses. With clear metadata management through Poetry, this project serves as a valuable tool for those looking to integrate Alpaca trading capabilities seamlessly into their applications.

This project is still in development. New functionality will be added and updated daily. Hopefully this project will help make communicating with Alpaca Markets API, much easier for some. Any input or help would be appreciated.


Features

Feature Description
⚙️ Architecture Designed with a clear separation of concerns, utilizing data classes for enhanced abstraction and maintainability. Follows a modular approach to interact with the Alpaca API efficiently.
🔩 Code Quality Maintains high code quality standards with consistent use of Python best practices. Codebase is well-formatted, follows PEP8 guidelines, and includes automated code formatting and linting with tools like black, flake8, and isort.
📄 Documentation Provides thorough documentation with a focus on API usage, setup instructions, and data class definitions. Utilizes Sphinx for generating documentation to support developers in understanding and integrating the project.
🔌 Integrations Relies on key external dependencies such as requests for handling HTTP requests and numpy for numerical computations. Also integrates with pre-commit for code quality checks and pytest for testing.
🧩 Modularity Emphasizes modularity and reusability with well-defined data classes that abstract API responses. Offers developers flexibility in handling different aspects of Alpaca trading functionalities.
🧪 Testing Utilizes pytest as the primary testing framework along with requests-mock for mocking API requests. Ensures reliable testing for validating the behavior of the PyAlpacaApi class.
⚡️ Performance Demonstrates efficiency in API communication and data processing. Optimizes speed by handling requests and responses effectively, contributing to overall performance.
🛡️ Security Implements secure data handling by requiring Alpaca API Key and Secret for authentication. Employs measures to protect sensitive information and control access to the Alpaca trading functionalities.
📦 Dependencies Depends on various libraries including requests, pandas, and numpy for API interactions, data processing, and numerical computations. Managed efficiently using Poetry for dependency management.
🚀 Scalability Shows potential for scalability with its modular design and efficient data processing. Capable of handling increased traffic and load by abstracting API interactions and ensuring maintainability.

Repository Structure

└── py-alpaca-api/
    ├── .github
       └── ISSUE_TEMPLATE
    ├── CODE_OF_CONDUCT.md
    ├── LICENSE
    ├── README.md
    ├── SECURITY.md
    ├── poetry.lock
    ├── py_alpaca_api
       ├── __init__.py
       ├── alpaca.py
       └── src
    ├── pyproject.toml
    └── tests
        ├── __init__.py
        └── test_alpaca.py

Modules

.
File Summary
pyproject.toml Defines metadata and dependencies for py-alpaca-api. Manages project details, such as name, version, description, homepage, repository, and dependencies like pandas, requests, and numpy. Organizes development and testing dependencies using Poetry.
py_alpaca_api
File Summary
alpaca.py The alpaca.py file in the py-alpaca-api repository contains a class called PyAlpacaApi, designed to interact with the Alpaca API. This class facilitates communication by handling API requests and responses, leveraging data classes for account, asset, and order information. The constructor requires the Alpaca API Key and Secret, with an option to specify the usage of the Alpaca Paper Trading API. This component serves as a fundamental interface for developers to access and manage Alpaca trading functionalities within the broader project architecture.
py_alpaca_api.src
File Summary
data_classes.py Defines data classes for Orders, Assets, and Accounts to map JSON data to Python objects. Abstracts data processing from API responses, enhancing flexibility and maintainability.

Getting Started

System Requirements:

  • Python: version 3.12.3

Installation

From source

  1. Clone the py-alpaca-api repository:
$ git clone https://github.com/TexasCoding/py-alpaca-api
  1. Change to the project directory:
$ cd py-alpaca-api
  1. Install the dependencies: Recommended way is to use poetry, to install all dependencies including dev
$ poetry install

Using pip, this does not include -dev dependencies:

$ pip install -r requirements.txt

Usage

Include PyAlpacaAPI In Your App

from py_alpaca_api.alpaca import PyAlpacaApi

api_key = 'your_api_key'
api_secret = 'your_api_secret'

alpaca = PyAlpacaApi(api_key=api_key, api_secret=api_secret, api_paper=True)

asset = alpaca.get_asset('AAPL')

print(asset)

Tests

Run the test suite using the command below:

$ pytest

Project Roadmap

  • ► Adding all functionality from Alpaca's API

Contributing

Contributions are welcome! Here are several ways you can contribute:

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/TexasCoding/py-alpaca-api
    
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
    
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
    
  6. Push to github: Push the changes to your forked repository.
    git push origin new-feature-x
    
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph


License

This project is protected under the MIT License. For more details, refer to the LICENSE file.


Acknowledgments

Return


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

py_alpaca_api-0.2.7.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

py_alpaca_api-0.2.7-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file py_alpaca_api-0.2.7.tar.gz.

File metadata

  • Download URL: py_alpaca_api-0.2.7.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/5.15.146.1-microsoft-standard-WSL2

File hashes

Hashes for py_alpaca_api-0.2.7.tar.gz
Algorithm Hash digest
SHA256 ac31b1c8cb161585435aab944b02ce8829357eb5014c60a31ad4b00f56a8ead1
MD5 642438e117c4daef6a46b665f5f82754
BLAKE2b-256 e6383c71520faa3e38ea97549530ac4f1e7a0985e07c6966736d580b26f33fa1

See more details on using hashes here.

File details

Details for the file py_alpaca_api-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: py_alpaca_api-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/5.15.146.1-microsoft-standard-WSL2

File hashes

Hashes for py_alpaca_api-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 58ab7b38f3e36bd65ec0fd6e9d5c032657f765ce4189c9b9a09d51376a7d2ff7
MD5 31c807945a3c7f36044ccb9f9f4b2aa8
BLAKE2b-256 21786d5fa92f9abfd776f79da3aedf170504da04f76fce82c388e49dcbd3ae43

See more details on using hashes here.

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