Skip to main content

A Flexible Algorithmic Trading Framework

Project description

Modular-Trader: A Flexible Algorithmic Trading Framework

Python Badge

Important Note: This project is currently undergoing substantial updates. Significant changes to existing functions and classes are anticipated, and compatibility with the current version may be affected.

logo

About The Project

flow

Modular Trader is a Python-based framework for algorithmic trading, designed with a strong emphasis on modularity and flexibility. It provides a comprehensive solution as a set of building blocks for the live deployment of algorithmic trading strategies.

The framework is organized into five core modules, each addressing a critical aspect of the trading process:

  • Asset Selection: Identifies and selects the assets to include in the trading universe.
  • Signal Generation: Produces trading signals based on various strategies and indicators.
  • Portfolio Construction: Allocates portfolio weights based on the generated signals.
  • Risk Management: Adjusts portfolio allocations to mitigate and manage risk effectively
  • Order Execution: Manages the execution of buy/sell orders in the market.

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_construction import EqualWeightPortfolioConstruction
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_construction=EqualWeightPortfolioConstruction(),
    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


Download files

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

Source Distribution

modular_trader-0.0.3.tar.gz (64.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modular_trader-0.0.3-py3-none-any.whl (44.9 kB view details)

Uploaded Python 3

File details

Details for the file modular_trader-0.0.3.tar.gz.

File metadata

  • Download URL: modular_trader-0.0.3.tar.gz
  • Upload date:
  • Size: 64.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for modular_trader-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a1f12c4c0ccdc3f33f73ed36620cdf638571723d4dc69b2721510502b6d45882
MD5 8f57459e91edeba0e979a6827df90f54
BLAKE2b-256 6d36f40733517e3110ac4d37f2a105cc5603a87e7375fe46ea41b9d97d8497fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for modular_trader-0.0.3.tar.gz:

Publisher: pypi.yml on kfuangsung/modular-trader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file modular_trader-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: modular_trader-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 44.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for modular_trader-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7e12fffcf30ab27b2885248b52729e56835ad38d9e855d344041da864ba07616
MD5 53b5068ded76ed38b831923239eaceb1
BLAKE2b-256 d79980a1de4a0f225e7ff24e61517ee87ce67978767657dda4af581680864e3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for modular_trader-0.0.3-py3-none-any.whl:

Publisher: pypi.yml on kfuangsung/modular-trader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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