Marketwatch API Python Library
Broken login by captcha
A Python libary to interact with the MarketWatch Stock Market Game Based on code from
Feature
- Logging in and out of the site
- Getting the current price of a stock
- Getting information about games on the site
- Buying, selling, shorting, and covering stocks in a game
- Creating, adding to, getting, and deleting watchlists
- Getting, adding to, and deleting items from a portfolio
- Getting and cancelling pending orders
- Checking if the game is down
Installation
pip install marketwatch
pip install git+https://github.com/antoinebou12/marketwatch.git
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:
from marketwatch import MarketWatch
Login
Then, create an instance of the MarketWatch class using your MarketWatch username and password:
marketwatch = MarketWatch(username, password)
Get Stock Price
To get the current price of a stock:
marketwatch.get_price("AAPL")
Interact with Games
https://www.marketwatch.com/games
To get information about games on the site:
marketwatch.get_games()
Get Game
marketwatch.get_game("game-name")
Get Game Settings
marketwatch.get_game_settings("game-name")
Get Leaderboard
marketwatch.get_leaderboard("game-name")
Get Portfolio
marketwatch.get_portfolio("game-name")
Get Positions
marketwatch.get_positions("game-name")
Get Pending Orders
marketwatch.get_pending_orders("game-name")
Buy Stock
marketwatch.buy(game_id, "AAPL", 100)
Sell Stock
marketwatch.sell("game-name", "AAPL", 100)
Create Watchlist
https://www.marketwatch.com/watchlist
To create a watchlist:
marketwatch.create_watchlist('My Watchlist')
Add Stock to Watchlist
To add stocks to a watchlist:
marketwatch.add_to_watchlist(watchlist_id, ['AAPL', 'GOOG'])
Get All Watchlists
To get all watchlists:
watchlists = marketwatch.get_watchlists()
Delete Watchlist
To delete a watchlist:
marketwatch.delete_watchlist(watchlist_id)
Example
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.
Metadata
Release files for marketwatch 0.2.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| marketwatch-0.2.4.2.tar.gz | 21.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| marketwatch-0.2.4.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.5 kB
Release files / marketwatch-0.2.4.2.tar.gz
| Download URL | marketwatch-0.2.4.2.tar.gz |
|---|---|
| Size | 21.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72fbc839ef0da9f5bf52abe9f41b31ef566ab8255d58bc9b940ff479b2e2c423
|
|
BLAKE2b-256 checksum How to use checksums |
6873af1a3cb029614f79dafa8ab1de6511cf7afa6bdc42376f33aa9a74d1c354
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Release files / marketwatch-0.2.4.2-py3-none-any.whl
| Download URL | marketwatch-0.2.4.2-py3-none-any.whl |
|---|---|
| Size | 22.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a0f1e5375ef7677170dcc79ab0792c9e7f4df981504f80427757e2ca6cce26a
|
|
BLAKE2b-256 checksum How to use checksums |
c38e8fd0e10128f8eee50c7ad6adbeed788c40874abf00d2e0eaaa958adfe602
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Security for marketwatch 0.2.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.