MarketWatch's API
Project description
Marketwatch API Python Library
A Python libary to interact with the MarketWatch Stock Market Game Based on code from
Installation
pip install marketwatch
pip install git+https://github.com/antoinebou12/marketwatch.git
git clone https://github.com/antoinebou12/marketwatch.git
Usage
Import
from marketwatch import MarketWatch
Login
marketwatch = MarketWatch(username, password)
Get Price
marketwatch.get_price("AAPL")
Get Games
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
marketwatch.buy("game-name", "AAPL", 100)
Sell
marketwatch.sell("game-name", "AAPL", 100)
Example
if __name__ == "__main__":
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)}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
marketwatch-0.1.8.tar.gz
(16.4 kB
view hashes)
Built Distribution
Close
Hashes for marketwatch-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73ed8ab9ac187420226f6024a1b851d6635ee01f6c9876601ee5cb3fcae36174 |
|
MD5 | 55bb7f009c936d7e6c3f1cbbcbf0af04 |
|
BLAKE2b-256 | b265b11d293cb345900097cab659d55d8fdbe2305c480444fd54fc7a692c4e18 |