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
Hashes for py_alpaca_api-0.3.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 479ab8226fa32b9eb21c3f2e4e6ef262d052dc36dad32ae0442f834e87783482 |
|
MD5 | baa33b6f2a5f97a1ba2603d607cc3d9e |
|
BLAKE2b-256 | 53bdbd8e44522a76afe43f3f80c9eeda4a7578e74fc360ce7ca8f8653864cb94 |