Python Algorithmic Trading Framework
Project description
Modular-Trader
About The Project
Modular-trader is a algorithmic trading framework written in Python, designed with focus on modularity and flexibility. The framework provides solution as building blocks for live deployment of algorithmic trading, consists of five modules; Asset Selection, Signal Generation, Portfolio Builder, Order Execution and, Risk Management.
Built-in Models
Asset Selection
- Manual
Signal Generation
- Constant
Portfolio Builder
- EqualWeight
- ThresholdDeviation
Order Execution
- Instant
Risk Management
- FixedStopLoss
Supported Brokerages
Important Note: We are not affiliated, associated, authorized, endorsed by, or in any way officially connected with Alpaca Securities LLC, or any of its subsidiaries or its affiliates. The official Alpaca Securities LLC website can be found at https://alpaca.markets/.
Getting Started
Installation
pip install modular-trader
Usage
from dotenv import load_dotenv
from modular_trader.common.enums import TradingMode
from modular_trader.engine import AlpacaEngine
from modular_trader.framework import FrameworkCollection
from modular_trader.framework.asset_selection import ManualAssetSelection
from modular_trader.framework.order_execution import InstantOrderExecution
from modular_trader.framework.portfolio_builder import EqualWeightPortfolioBuilder
from modular_trader.framework.risk_management import NullRiskManagement
from modular_trader.framework.signal_generation import ConstantSignalGeneration
from modular_trader.trader import AlpacaTrader
# set Alpaca Token as environment variable
# create `.env` file then add
# ALPACA_API_KEY=xxxxxxxx
# ALPACA_SECRET_KEY=xxxxxxx
load_dotenv()
# Equally weighted portfolio
# with Instant rebalancing
symbols = ["SPY", "QQQ", "GLD"]
framework = FrameworkCollection(
asset_selection=ManualAssetSelection(symbols=symbols),
signal_generation=ConstantSignalGeneration(),
portfolio_builder=EqualWeightPortfolioBuilder(),
order_execution=InstantOrderExecution(),
risk_management=NullRiskManagement(),
)
# using Paper portfolio
engine = AlpacaEngine(mode=TradingMode.PAPER)
trader = AlpacaTrader(
engine=engine,
framework=framework,
subscription_symbols=symbols,
)
trader.run()
License
Distributed under the MIT License. See LICENSE
for more information.
Maintainers
Modular-Trader is currently maintained by kfuangsung (kachain.f@outlook.com).
Important Note: We do not provide technical support, or consulting and do not answer personal questions via email.
Acknowledgments
- alpaca-py: An official Python SDK for Alpaca APIs.
Disclaimer
Authors and contributors of Modular-Trader cannot be held responsible for possible losses or other damage. Consequently, no claims for damages can be asserted. Please also note that trading has a certain addictive potential. If you find yourself at risk, please seek professional help.
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 modular_trader-0.0.1.tar.gz
.
File metadata
- Download URL: modular_trader-0.0.1.tar.gz
- Upload date:
- Size: 63.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9b76287dedafea14d11e4c11cdc0a7296f49126677c9f56bc9bc7851bb8a8f9 |
|
MD5 | d3262fec43841974a2c9cf77db9f4928 |
|
BLAKE2b-256 | b36c0e388ad54e0e29ec7965f563df316306b5728f8d78ad2a146118ebdd9809 |
File details
Details for the file modular_trader-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: modular_trader-0.0.1-py3-none-any.whl
- Upload date:
- Size: 43.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 817e3e4f1c9bcee0523450a672238aea3a0fd2d59fdaf953f62dbb0534699313 |
|
MD5 | a57506d0ceae4ad5027782d97fa39111 |
|
BLAKE2b-256 | ac8de6caa4c762409da0e0ca22028056808034a859fc4e593bcb423da26f81c4 |