Skip to main content

A Python package for analyzing investment portfolios, including using quantitative methods like the efficient frontier for calculations an optimal asset allocation strategy.

Project description

trade_strategy

PyPI - Version PyPI - Python Version


Table of Contents

Installation

pip install trade-strategy

How to Run

To use the risk_return function, you can use the following Python code:

from trade_strategy import risk_return

tickers = ["AAPL", "MSFT", "GOOG"]
start_date = '2013-03-07'
end_date = '2025-04-05'

risk_return(tickers, start_date, end_date)
  • Assets: ["AAPL", "MSFT", "GOOG"]
  • Start Date: 2013-03-07
  • End Date: 2025-04-05

Expected Output

The script will output a JSON payload containing the lowest risk, highest returns, and highest Sharpe ratio allocations for the specified tickers and date range. The returns and volatility fields are expressed as percentages.

{
  "lowest_risk_allocation": {
    "returns": 24.8073,
    "volatility": 23.4054,
    "sharpe_ratio": 1.059898,
    "weights": [0.347, 0.352, 0.3],
    "assets": ["AAPL", "MSFT", "GOOG"]
  },
  "highest_returns_allocation": {
    "returns": 26.8417,
    "volatility": 26.2248,
    "sharpe_ratio": 1.023524,
    "weights": [0.003, 0.986, 0.011],
    "assets": ["AAPL", "MSFT", "GOOG"]
  },
  "highest_sharpe_allocation": {
    "returns": 25.8282,
    "volatility": 23.8805,
    "sharpe_ratio": 1.081562,
    "weights": [0.301, 0.588, 0.111],
    "assets": ["AAPL", "MSFT", "GOOG"]
  }
}

License

trade-strategy is distributed under the terms of the MIT license.

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

trade_strategy-0.1.5.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

trade_strategy-0.1.5-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file trade_strategy-0.1.5.tar.gz.

File metadata

  • Download URL: trade_strategy-0.1.5.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for trade_strategy-0.1.5.tar.gz
Algorithm Hash digest
SHA256 926013546c18a4a33c97ccc3e4fbfd8a6466b2b830f5eb1004b93b9785ddbd57
MD5 e6c60df52adc34831687773d6b614d3f
BLAKE2b-256 5b86e74fa06ed4e946917906b6aad4eeb2f78dc878b88ce801277a8c3ac6f257

See more details on using hashes here.

File details

Details for the file trade_strategy-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: trade_strategy-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for trade_strategy-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6ef4768f0271ec65e36f68aa6d29510141ae97c677349f26b8ac013aeb2eec78
MD5 f592324ea2fa36946b2711ee9286beff
BLAKE2b-256 c79bd47604256eee58e0239312f7e0fa66644a701e24a3c4855e90bab1d9e496

See more details on using hashes here.

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