Python package, for communicating with Alpaca Markets REST API.
Project description
PY-ALPACA-API
Unlock Alpacas Power with Seamless API Integration"
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
- Clone the py-alpaca-api repository:
$ git clone https://github.com/TexasCoding/py-alpaca-api
- Change to the project directory:
$ cd py-alpaca-api
- Install the dependencies: Recommended way is to use poetry, to install all dependencies including dev
$ poetry installUsing 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:
- Report Issues: Submit bugs found or log feature requests for the
py-alpaca-api
project. - Submit Pull Requests: Review open PRs, and submit your own PRs.
- Join the Discussions: Share your insights, provide feedback, or ask questions.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your github account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/TexasCoding/py-alpaca-api
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.'
- Push to github: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
- Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
License
This project is protected under the MIT License. For more details, refer to the LICENSE file.
Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac31b1c8cb161585435aab944b02ce8829357eb5014c60a31ad4b00f56a8ead1 |
|
MD5 | 642438e117c4daef6a46b665f5f82754 |
|
BLAKE2b-256 | e6383c71520faa3e38ea97549530ac4f1e7a0985e07c6966736d580b26f33fa1 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58ab7b38f3e36bd65ec0fd6e9d5c032657f765ce4189c9b9a09d51376a7d2ff7 |
|
MD5 | 31c807945a3c7f36044ccb9f9f4b2aa8 |
|
BLAKE2b-256 | 21786d5fa92f9abfd776f79da3aedf170504da04f76fce82c388e49dcbd3ae43 |