openalgo


Nameopenalgo JSON
Version 1.0.5 PyPI version JSON
download
home_pagehttps://docs.openalgo.in
SummaryPython library for algorithmic trading with OpenAlgo - Accounts, Orders, and Market Data APIs
upload_time2024-12-17 16:27:24
maintainerNone
docs_urlNone
authorOpenAlgo
requires_python>=3.7
licenseNone
keywords trading algorithmic-trading finance stock-market api-wrapper openalgo market-data trading-api stock-trading
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenAlgo Python Library

A Python library for algorithmic trading using OpenAlgo's REST APIs. This library provides a comprehensive interface for order management, market data, and account operations.

## Installation

```bash
pip install openalgo
```

## Quick Start

```python
from openalgo import api

# Initialize the client
client = api(
    api_key="your_api_key",
    host="http://127.0.0.1:5000"  # or your OpenAlgo server URL
)
```

## API Categories

### 1. Accounts API

#### Funds
Get funds and margin details of the trading account.
```python
result = client.funds()
# Returns:
{
    "data": {
        "availablecash": "18083.01",
        "collateral": "0.00",
        "m2mrealized": "0.00",
        "m2munrealized": "0.00",
        "utiliseddebits": "0.00"
    },
    "status": "success"
}
```

#### Orderbook
Get orderbook details with statistics.
```python
result = client.orderbook()
# Returns order details and statistics including:
# - Total buy/sell orders
# - Total completed/open/rejected orders
# - Individual order details with status
```

#### Tradebook
Get execution details of trades.
```python
result = client.tradebook()
# Returns list of executed trades with:
# - Symbol, action, quantity
# - Average price, trade value
# - Timestamp, order ID
```

#### Positionbook
Get current positions across all segments.
```python
result = client.positionbook()
# Returns list of positions with:
# - Symbol, exchange, product
# - Quantity, average price
```

#### Holdings
Get stock holdings with P&L details.
```python
result = client.holdings()
# Returns:
# - List of holdings with quantity and P&L
# - Statistics including total holding value
# - Total investment value and P&L
```

### 2. Orders API

#### Place Order
Place a regular order.
```python
result = client.placeorder(
    symbol="RELIANCE",
    exchange="NSE",
    action="BUY",
    quantity=1,
    price_type="MARKET",
    product="MIS"
)
```

#### Place Smart Order
Place an order with position sizing.
```python
result = client.placesmartorder(
    symbol="RELIANCE",
    exchange="NSE",
    action="BUY",
    quantity=1,
    position_size=100,
    price_type="MARKET",
    product="MIS"
)
```

#### Basket Order
Place multiple orders simultaneously.
```python
orders = [
    {
        "symbol": "RELIANCE",
        "exchange": "NSE",
        "action": "BUY",
        "quantity": 1,
        "pricetype": "MARKET",
        "product": "MIS"
    },
    {
        "symbol": "INFY",
        "exchange": "NSE",
        "action": "SELL",
        "quantity": 1,
        "pricetype": "MARKET",
        "product": "MIS"
    }
]
result = client.basketorder(orders=orders)
```

#### Split Order
Split a large order into smaller ones.
```python
result = client.splitorder(
    symbol="YESBANK",
    exchange="NSE",
    action="SELL",
    quantity=105,
    splitsize=20,
    price_type="MARKET",
    product="MIS"
)
```

#### Order Status
Check status of a specific order.
```python
result = client.orderstatus(
    order_id="24120900146469",
    strategy="Test Strategy"
)
```

#### Open Position
Get current open position for a symbol.
```python
result = client.openposition(
    symbol="YESBANK",
    exchange="NSE",
    product="CNC"
)
```

#### Modify Order
Modify an existing order.
```python
result = client.modifyorder(
    order_id="24120900146469",
    symbol="RELIANCE",
    action="BUY",
    exchange="NSE",
    quantity=2,
    price="2100",
    product="MIS",
    price_type="LIMIT"
)
```

#### Cancel Order
Cancel a specific order.
```python
result = client.cancelorder(
    order_id="24120900146469"
)
```

#### Cancel All Orders
Cancel all open orders.
```python
result = client.cancelallorder()
```

#### Close Position
Close all open positions.
```python
result = client.closeposition()
```

### 3. Data API

#### Quotes
Get real-time quotes for a symbol.
```python
result = client.quotes(
    symbol="RELIANCE",
    exchange="NSE"
)
```

#### Market Depth
Get market depth (order book) data.
```python
result = client.depth(
    symbol="RELIANCE",
    exchange="NSE"
)
```

#### Historical Data
Get historical price data.
```python
result = client.history(
    symbol="RELIANCE",
    exchange="NSE",
    interval="5m",
    start_date="2024-01-01",
    end_date="2024-01-31"
)
```

#### Intervals
Get supported time intervals for historical data.
```python
result = client.interval()
```

## Examples

Check the examples directory for detailed usage:
- account_test.py: Test account-related functions
- order_test.py: Test order management functions
- data_examples.py: Test market data functions

## Publishing to PyPI

1. Update version in `openalgo/__init__.py`

2. Build the distribution:
```bash
python -m pip install --upgrade build
python -m build
```

3. Upload to PyPI:
```bash
python -m pip install --upgrade twine
python -m twine upload dist/*
```

## License

This project is licensed under the MIT License - see the LICENSE file for details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://docs.openalgo.in",
    "name": "openalgo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "trading, algorithmic-trading, finance, stock-market, api-wrapper, openalgo, market-data, trading-api, stock-trading",
    "author": "OpenAlgo",
    "author_email": "support@openalgo.in",
    "download_url": "https://files.pythonhosted.org/packages/e3/20/05cd0ff75682106d79e50533f702800297701c128691f53b356c3a8b6612/openalgo-1.0.5.tar.gz",
    "platform": null,
    "description": "# OpenAlgo Python Library\n\nA Python library for algorithmic trading using OpenAlgo's REST APIs. This library provides a comprehensive interface for order management, market data, and account operations.\n\n## Installation\n\n```bash\npip install openalgo\n```\n\n## Quick Start\n\n```python\nfrom openalgo import api\n\n# Initialize the client\nclient = api(\n    api_key=\"your_api_key\",\n    host=\"http://127.0.0.1:5000\"  # or your OpenAlgo server URL\n)\n```\n\n## API Categories\n\n### 1. Accounts API\n\n#### Funds\nGet funds and margin details of the trading account.\n```python\nresult = client.funds()\n# Returns:\n{\n    \"data\": {\n        \"availablecash\": \"18083.01\",\n        \"collateral\": \"0.00\",\n        \"m2mrealized\": \"0.00\",\n        \"m2munrealized\": \"0.00\",\n        \"utiliseddebits\": \"0.00\"\n    },\n    \"status\": \"success\"\n}\n```\n\n#### Orderbook\nGet orderbook details with statistics.\n```python\nresult = client.orderbook()\n# Returns order details and statistics including:\n# - Total buy/sell orders\n# - Total completed/open/rejected orders\n# - Individual order details with status\n```\n\n#### Tradebook\nGet execution details of trades.\n```python\nresult = client.tradebook()\n# Returns list of executed trades with:\n# - Symbol, action, quantity\n# - Average price, trade value\n# - Timestamp, order ID\n```\n\n#### Positionbook\nGet current positions across all segments.\n```python\nresult = client.positionbook()\n# Returns list of positions with:\n# - Symbol, exchange, product\n# - Quantity, average price\n```\n\n#### Holdings\nGet stock holdings with P&L details.\n```python\nresult = client.holdings()\n# Returns:\n# - List of holdings with quantity and P&L\n# - Statistics including total holding value\n# - Total investment value and P&L\n```\n\n### 2. Orders API\n\n#### Place Order\nPlace a regular order.\n```python\nresult = client.placeorder(\n    symbol=\"RELIANCE\",\n    exchange=\"NSE\",\n    action=\"BUY\",\n    quantity=1,\n    price_type=\"MARKET\",\n    product=\"MIS\"\n)\n```\n\n#### Place Smart Order\nPlace an order with position sizing.\n```python\nresult = client.placesmartorder(\n    symbol=\"RELIANCE\",\n    exchange=\"NSE\",\n    action=\"BUY\",\n    quantity=1,\n    position_size=100,\n    price_type=\"MARKET\",\n    product=\"MIS\"\n)\n```\n\n#### Basket Order\nPlace multiple orders simultaneously.\n```python\norders = [\n    {\n        \"symbol\": \"RELIANCE\",\n        \"exchange\": \"NSE\",\n        \"action\": \"BUY\",\n        \"quantity\": 1,\n        \"pricetype\": \"MARKET\",\n        \"product\": \"MIS\"\n    },\n    {\n        \"symbol\": \"INFY\",\n        \"exchange\": \"NSE\",\n        \"action\": \"SELL\",\n        \"quantity\": 1,\n        \"pricetype\": \"MARKET\",\n        \"product\": \"MIS\"\n    }\n]\nresult = client.basketorder(orders=orders)\n```\n\n#### Split Order\nSplit a large order into smaller ones.\n```python\nresult = client.splitorder(\n    symbol=\"YESBANK\",\n    exchange=\"NSE\",\n    action=\"SELL\",\n    quantity=105,\n    splitsize=20,\n    price_type=\"MARKET\",\n    product=\"MIS\"\n)\n```\n\n#### Order Status\nCheck status of a specific order.\n```python\nresult = client.orderstatus(\n    order_id=\"24120900146469\",\n    strategy=\"Test Strategy\"\n)\n```\n\n#### Open Position\nGet current open position for a symbol.\n```python\nresult = client.openposition(\n    symbol=\"YESBANK\",\n    exchange=\"NSE\",\n    product=\"CNC\"\n)\n```\n\n#### Modify Order\nModify an existing order.\n```python\nresult = client.modifyorder(\n    order_id=\"24120900146469\",\n    symbol=\"RELIANCE\",\n    action=\"BUY\",\n    exchange=\"NSE\",\n    quantity=2,\n    price=\"2100\",\n    product=\"MIS\",\n    price_type=\"LIMIT\"\n)\n```\n\n#### Cancel Order\nCancel a specific order.\n```python\nresult = client.cancelorder(\n    order_id=\"24120900146469\"\n)\n```\n\n#### Cancel All Orders\nCancel all open orders.\n```python\nresult = client.cancelallorder()\n```\n\n#### Close Position\nClose all open positions.\n```python\nresult = client.closeposition()\n```\n\n### 3. Data API\n\n#### Quotes\nGet real-time quotes for a symbol.\n```python\nresult = client.quotes(\n    symbol=\"RELIANCE\",\n    exchange=\"NSE\"\n)\n```\n\n#### Market Depth\nGet market depth (order book) data.\n```python\nresult = client.depth(\n    symbol=\"RELIANCE\",\n    exchange=\"NSE\"\n)\n```\n\n#### Historical Data\nGet historical price data.\n```python\nresult = client.history(\n    symbol=\"RELIANCE\",\n    exchange=\"NSE\",\n    interval=\"5m\",\n    start_date=\"2024-01-01\",\n    end_date=\"2024-01-31\"\n)\n```\n\n#### Intervals\nGet supported time intervals for historical data.\n```python\nresult = client.interval()\n```\n\n## Examples\n\nCheck the examples directory for detailed usage:\n- account_test.py: Test account-related functions\n- order_test.py: Test order management functions\n- data_examples.py: Test market data functions\n\n## Publishing to PyPI\n\n1. Update version in `openalgo/__init__.py`\n\n2. Build the distribution:\n```bash\npython -m pip install --upgrade build\npython -m build\n```\n\n3. Upload to PyPI:\n```bash\npython -m pip install --upgrade twine\npython -m twine upload dist/*\n```\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python library for algorithmic trading with OpenAlgo - Accounts, Orders, and Market Data APIs",
    "version": "1.0.5",
    "project_urls": {
        "Documentation": "https://docs.openalgo.in",
        "Homepage": "https://docs.openalgo.in",
        "Source": "https://github.com/openalgo/openalgo-python",
        "Tracker": "https://github.com/openalgo/openalgo-python/issues"
    },
    "split_keywords": [
        "trading",
        " algorithmic-trading",
        " finance",
        " stock-market",
        " api-wrapper",
        " openalgo",
        " market-data",
        " trading-api",
        " stock-trading"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b048a95bc35cd70c3bf64324efd8be57311900d95e5d666f5a7e18cda49ede58",
                "md5": "1110b133c0fdc52bb19ec88d22088a06",
                "sha256": "edaf3c4209d548474b26b0bb4e470c2d7640bfa2c4ccafb3dfedc0bc5856cd88"
            },
            "downloads": -1,
            "filename": "openalgo-1.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1110b133c0fdc52bb19ec88d22088a06",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 10574,
            "upload_time": "2024-12-17T16:27:22",
            "upload_time_iso_8601": "2024-12-17T16:27:22.535370Z",
            "url": "https://files.pythonhosted.org/packages/b0/48/a95bc35cd70c3bf64324efd8be57311900d95e5d666f5a7e18cda49ede58/openalgo-1.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e32005cd0ff75682106d79e50533f702800297701c128691f53b356c3a8b6612",
                "md5": "f0c7c847bbcc2164e8fcd5a411bca681",
                "sha256": "05cd1d41a4c807e2cfb1828bb70c4a12f574fe9280763e93d4cf012984f5d216"
            },
            "downloads": -1,
            "filename": "openalgo-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "f0c7c847bbcc2164e8fcd5a411bca681",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10964,
            "upload_time": "2024-12-17T16:27:24",
            "upload_time_iso_8601": "2024-12-17T16:27:24.601931Z",
            "url": "https://files.pythonhosted.org/packages/e3/20/05cd0ff75682106d79e50533f702800297701c128691f53b356c3a8b6612/openalgo-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 16:27:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "openalgo",
    "github_project": "openalgo-python",
    "github_not_found": true,
    "lcname": "openalgo"
}
        
Elapsed time: 0.67879s