Skip to main content

Python Algorithmic Trading Framework

Project description

Modular-Trader

Python Badge Pydantic Badge

logo

About The Project

flow

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

(back to top)

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/.

(back to top)

Getting Started

Installation

pip install modular-trader

(back to top)

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()

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

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.

(back to top)

Acknowledgments

  • alpaca-py: An official Python SDK for Alpaca APIs.

(back to top)

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.

(back to top)

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.2.tar.gz (64.3 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.2-py3-none-any.whl (43.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modular_trader-0.0.2.tar.gz
  • Upload date:
  • Size: 64.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for modular_trader-0.0.2.tar.gz
Algorithm Hash digest
SHA256 52228efe188fd792af708d94757169f092d164282bbf94bb5c50863bd4d55d9a
MD5 195846cbc115ea57623cd21e65950b9b
BLAKE2b-256 1dc48e2140dc83df19c6c234463a70b64dc1d7ed15e19dd1a0317f6ba66c0608

See more details on using hashes here.

Provenance

The following attestation bundles were made for modular_trader-0.0.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: modular_trader-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 43.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for modular_trader-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 26c057a7dc9f857e8a1817d80056f03a0dd197e850ff9e7556bdca6d7a8786bc
MD5 00c2105b261ac38e1aa115b64acd0e7c
BLAKE2b-256 e5a11f91977baa2fb3452b21953b9b3fafdc27303c1b3e25e203e9a87269fead

See more details on using hashes here.

Provenance

The following attestation bundles were made for modular_trader-0.0.2-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