marketwatch


Namemarketwatch JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttp://github.com/antoineboucher/marketwatch
SummaryMarketWatch's API
upload_time2024-01-26 21:15:14
maintainer
docs_urlNone
authorAntoine Boucher
requires_python>=3.8,<4.0
licenseApache-2.0
keywords marketwatch api stock finance market game
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Marketwatch API Python Library

![PyPI](https://img.shields.io/pypi/v/marketwatch)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/marketwatch)
![PyPI - License](https://img.shields.io/pypi/l/marketwatch)
![PyPI - Downloads](https://img.shields.io/pypi/dm/marketwatch)
![GitHub last commit](https://img.shields.io/github/last-commit/antoinebou12/marketwatch)
[![Python Test and Build](https://github.com/antoinebou12/marketwatch/actions/workflows/python-test.yml/badge.svg)](https://github.com/antoinebou12/marketwatch/actions/workflows/python-test.yml)
![Coverage](https://raw.githubusercontent.com/antoinebou12/marketwatch/main/.github/badge/coverage.svg)

[MarketWatch](https://www.marketwatch.com)

[Documentation](https://antoinebou12.github.io/marketwatch/)

A Python libary to interact with the MarketWatch Stock Market Game
Based on code from

- https://github.com/kevindong/MarketWatch_API/
- https://github.com/bwees/pymarketwatch

## Feature
- [X]  Logging in and out of the site
- [X]  Getting the current price of a stock
- [X]  Getting information about games on the site
- [X]  Buying, selling, shorting, and covering stocks in a game
- [X]  Creating, adding to, getting, and deleting watchlists
- [X]  Getting, adding to, and deleting items from a portfolio
- [X]  Getting and cancelling pending orders
- [X]  Checking if the game is down

## Installation

```shell
pip install marketwatch
```

```shell
pip install git+https://github.com/antoinebou12/marketwatch.git
```

```shell
git clone https://github.com/antoinebou12/marketwatch.git
```

## Usage
Here are some examples of how you can use the MarketWatch class:

### Import
First, import the MarketWatch class from the script:
```python
from marketwatch import MarketWatch
```

### Login
Then, create an instance of the MarketWatch class using your MarketWatch username and password:
```python
marketwatch = MarketWatch(username, password)
```

### Get Stock Price
To get the current price of a stock:
```python
marketwatch.get_price("AAPL")
```

### Interact with Games
https://www.marketwatch.com/games

To get information about games on the site:
```python
marketwatch.get_games()
```

### Get Game
```python
marketwatch.get_game("game-name")
```

### Get Game Settings
```python
marketwatch.get_game_settings("game-name")
```

### Get Leaderboard
```python
marketwatch.get_leaderboard("game-name")
```

### Get Portfolio
```python
marketwatch.get_portfolio("game-name")
```

### Get Positions
```python
marketwatch.get_positions("game-name")
```

### Get Pending Orders 
```python
marketwatch.get_pending_orders("game-name")
```

### Buy Stock
```python
marketwatch.buy(game_id, "AAPL", 100)
```

### Sell Stock
```python
marketwatch.sell("game-name", "AAPL", 100)
```

### Create Watchlist
https://www.marketwatch.com/watchlist

To create a watchlist:
```python
marketwatch.create_watchlist('My Watchlist')
```

### Add Stock to Watchlist
To add stocks to a watchlist:
```python
marketwatch.add_to_watchlist(watchlist_id, ['AAPL', 'GOOG'])
```

### Get All Watchlists
To get all watchlists:
```python
watchlists = marketwatch.get_watchlists()
```

### Delete Watchlist
To delete a watchlist:
```python
marketwatch.delete_watchlist(watchlist_id)
```

### Example

```python
import os
username = os.environ.get("MARKETWATCH_USERNAME")
password = os.environ.get("MARKETWATCH_PASSWORD")

marketwatch = MarketWatch(username, password)

print(f"Price: {marketwatch.get_price('AAPL')} \n")
print(f"Games: {marketwatch.get_games()} \n")

games1 = marketwatch.get_games()[0]["name"].lower().replace(" ", "-")

print(f"Game: {marketwatch.get_game(games1)} \n")
print(f"Game Settings: {marketwatch.get_game_settings(games1)} \n")

print(f"Leaderboard: {marketwatch.get_leaderboard(games1)} \n")
print(f"Porfolio: {marketwatch.get_portfolio(games1)} \n")

print(f"Position: {marketwatch.get_positions(games1)}")
print(f"Orders Pending: {marketwatch.get_pending_orders(games1)}")
marketwatch.buy(games1, "AAPL", 100)

print(f"Position diff: {marketwatch.get_positions(games1)}")
```

## Contributing
Contributions are welcome. Please open an issue or submit a pull request.

## License
This project is licensed under the MIT License.


            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/antoineboucher/marketwatch",
    "name": "marketwatch",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "marketwatch,api,stock,finance,market,game",
    "author": "Antoine Boucher",
    "author_email": "antoine.boucher012@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/11/38/0f05042e17526cae8eaa82ee3c5d306d9ef5e2a142fad45ffd9d711b8316/marketwatch-0.2.2.tar.gz",
    "platform": null,
    "description": "# Marketwatch API Python Library\n\n![PyPI](https://img.shields.io/pypi/v/marketwatch)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/marketwatch)\n![PyPI - License](https://img.shields.io/pypi/l/marketwatch)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/marketwatch)\n![GitHub last commit](https://img.shields.io/github/last-commit/antoinebou12/marketwatch)\n[![Python Test and Build](https://github.com/antoinebou12/marketwatch/actions/workflows/python-test.yml/badge.svg)](https://github.com/antoinebou12/marketwatch/actions/workflows/python-test.yml)\n![Coverage](https://raw.githubusercontent.com/antoinebou12/marketwatch/main/.github/badge/coverage.svg)\n\n[MarketWatch](https://www.marketwatch.com)\n\n[Documentation](https://antoinebou12.github.io/marketwatch/)\n\nA Python libary to interact with the MarketWatch Stock Market Game\nBased on code from\n\n- https://github.com/kevindong/MarketWatch_API/\n- https://github.com/bwees/pymarketwatch\n\n## Feature\n- [X]  Logging in and out of the site\n- [X]  Getting the current price of a stock\n- [X]  Getting information about games on the site\n- [X]  Buying, selling, shorting, and covering stocks in a game\n- [X]  Creating, adding to, getting, and deleting watchlists\n- [X]  Getting, adding to, and deleting items from a portfolio\n- [X]  Getting and cancelling pending orders\n- [X]  Checking if the game is down\n\n## Installation\n\n```shell\npip install marketwatch\n```\n\n```shell\npip install git+https://github.com/antoinebou12/marketwatch.git\n```\n\n```shell\ngit clone https://github.com/antoinebou12/marketwatch.git\n```\n\n## Usage\nHere are some examples of how you can use the MarketWatch class:\n\n### Import\nFirst, import the MarketWatch class from the script:\n```python\nfrom marketwatch import MarketWatch\n```\n\n### Login\nThen, create an instance of the MarketWatch class using your MarketWatch username and password:\n```python\nmarketwatch = MarketWatch(username, password)\n```\n\n### Get Stock Price\nTo get the current price of a stock:\n```python\nmarketwatch.get_price(\"AAPL\")\n```\n\n### Interact with Games\nhttps://www.marketwatch.com/games\n\nTo get information about games on the site:\n```python\nmarketwatch.get_games()\n```\n\n### Get Game\n```python\nmarketwatch.get_game(\"game-name\")\n```\n\n### Get Game Settings\n```python\nmarketwatch.get_game_settings(\"game-name\")\n```\n\n### Get Leaderboard\n```python\nmarketwatch.get_leaderboard(\"game-name\")\n```\n\n### Get Portfolio\n```python\nmarketwatch.get_portfolio(\"game-name\")\n```\n\n### Get Positions\n```python\nmarketwatch.get_positions(\"game-name\")\n```\n\n### Get Pending Orders \n```python\nmarketwatch.get_pending_orders(\"game-name\")\n```\n\n### Buy Stock\n```python\nmarketwatch.buy(game_id, \"AAPL\", 100)\n```\n\n### Sell Stock\n```python\nmarketwatch.sell(\"game-name\", \"AAPL\", 100)\n```\n\n### Create Watchlist\nhttps://www.marketwatch.com/watchlist\n\nTo create a watchlist:\n```python\nmarketwatch.create_watchlist('My Watchlist')\n```\n\n### Add Stock to Watchlist\nTo add stocks to a watchlist:\n```python\nmarketwatch.add_to_watchlist(watchlist_id, ['AAPL', 'GOOG'])\n```\n\n### Get All Watchlists\nTo get all watchlists:\n```python\nwatchlists = marketwatch.get_watchlists()\n```\n\n### Delete Watchlist\nTo delete a watchlist:\n```python\nmarketwatch.delete_watchlist(watchlist_id)\n```\n\n### Example\n\n```python\nimport os\nusername = os.environ.get(\"MARKETWATCH_USERNAME\")\npassword = os.environ.get(\"MARKETWATCH_PASSWORD\")\n\nmarketwatch = MarketWatch(username, password)\n\nprint(f\"Price: {marketwatch.get_price('AAPL')} \\n\")\nprint(f\"Games: {marketwatch.get_games()} \\n\")\n\ngames1 = marketwatch.get_games()[0][\"name\"].lower().replace(\" \", \"-\")\n\nprint(f\"Game: {marketwatch.get_game(games1)} \\n\")\nprint(f\"Game Settings: {marketwatch.get_game_settings(games1)} \\n\")\n\nprint(f\"Leaderboard: {marketwatch.get_leaderboard(games1)} \\n\")\nprint(f\"Porfolio: {marketwatch.get_portfolio(games1)} \\n\")\n\nprint(f\"Position: {marketwatch.get_positions(games1)}\")\nprint(f\"Orders Pending: {marketwatch.get_pending_orders(games1)}\")\nmarketwatch.buy(games1, \"AAPL\", 100)\n\nprint(f\"Position diff: {marketwatch.get_positions(games1)}\")\n```\n\n## Contributing\nContributions are welcome. Please open an issue or submit a pull request.\n\n## License\nThis project is licensed under the MIT License.\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "MarketWatch's API",
    "version": "0.2.2",
    "project_urls": {
        "Documentation": "https://antoinebou12.github.io/marketwatch/api/",
        "Homepage": "http://github.com/antoineboucher/marketwatch",
        "Repository": "http://github.com/antoineboucher/marketwatch"
    },
    "split_keywords": [
        "marketwatch",
        "api",
        "stock",
        "finance",
        "market",
        "game"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "772b88f509c3fac128a06d393528c18fdbc304a740113deeb890a4665b6830fb",
                "md5": "b5412cf4b4b22f5663f1d03ab4b80f89",
                "sha256": "d33c17c4f697a95c6742dcd6f284ce80fdd2272863ed6740c544b2001efae177"
            },
            "downloads": -1,
            "filename": "marketwatch-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b5412cf4b4b22f5663f1d03ab4b80f89",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 20036,
            "upload_time": "2024-01-26T21:15:12",
            "upload_time_iso_8601": "2024-01-26T21:15:12.495371Z",
            "url": "https://files.pythonhosted.org/packages/77/2b/88f509c3fac128a06d393528c18fdbc304a740113deeb890a4665b6830fb/marketwatch-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "11380f05042e17526cae8eaa82ee3c5d306d9ef5e2a142fad45ffd9d711b8316",
                "md5": "3f031e042c816c471ad523e5ff3c71c5",
                "sha256": "fe010667d4b975598a98811b6442465b74539dce9887e3e741573f0f6d12b785"
            },
            "downloads": -1,
            "filename": "marketwatch-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "3f031e042c816c471ad523e5ff3c71c5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 19227,
            "upload_time": "2024-01-26T21:15:14",
            "upload_time_iso_8601": "2024-01-26T21:15:14.065870Z",
            "url": "https://files.pythonhosted.org/packages/11/38/0f05042e17526cae8eaa82ee3c5d306d9ef5e2a142fad45ffd9d711b8316/marketwatch-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-26 21:15:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "antoineboucher",
    "github_project": "marketwatch",
    "github_not_found": true,
    "lcname": "marketwatch"
}
        
Elapsed time: 0.16921s