Skip to content

marketwatch: A client around a virtual trading game

marketwatch is an archived Python client for MarketWatch’s virtual trading game. It wraps login, game queries and simulated order operations. These are game interactions, not connections to a brokerage account.

Library Archived
  • Updated
  • 19
  • Python · 77.68%
  • Apache-2.0
Repository languagesPython 77.68%4

Shares calculated from GitHub Linguist bytes.

Language%Bytes
Python77.68%103,813
Jupyter Notebook13.22%17,674
Jinja7.65%10,228
Dockerfile1.45%1,934

GitHub · README · Language statistics

Overview

Why it exists

Robust Python client library scraping and wrapping the MarketWatch virtual stock market game API.

Best fit

Automated trading bot development and portfolio backtesting.

Getting started

These commands come from the repository documentation. They were not run during this review.

README.md · Installation
pip install marketwatch
README.md · Installation
pip install git+https://github.com/antoinebou12/marketwatch.git
README.md · Installation
git clone https://github.com/antoinebou12/marketwatch.git

Repository references

Excerpts from the repository’s guides, in their original language. Links open the inspected source revision.

Configuration and usage

Usage

README.md

Here are some examples of how you can use the MarketWatch class:
Read the full instructions ↗

Usage

docs/getting-started.md

First, you need to create an account on MarketWatch and then create a virtual game. Once you have created a game, you will be able to get the game’s id from its URL, which will be used throughout the library.
Read the full instructions ↗
Development and contributions

Contributing

README.md

Contributions are welcome. Please open an issue or submit a pull request.
Read the full instructions ↗

Contributing

CONTRIBUTING.md

Contributions are welcome. Please open an issue or submit a pull request.
Read the full instructions ↗
Source documentation

3 documents read from 3 candidates.

Features and components 2

Session and game scope
MarketWatchGame subclasses MarketWatch and stores a game identifier. Methods such as buy and sell delegate to the base client with that identifier. Ledger and portfolio operations are scoped by the game.
Remote dependency
The client depends on the website’s authentication and response structure. A Python method still existing does not mean its remote counterpart remains accessible. Authentication failure can block otherwise unchanged game methods.

Architecture

The components and their connections remain available as text. The diagram adds an interactive view.

System context Context
  1. Python caller
  2. MarketWatchGame wrapper
  3. Base HTTP client
  4. Virtual game service

Links verified in the repository.

Mermaid Interactive diagram (loads on open)

System overview of the components and connections verified in the repository.

Static architecture view for marketwatch
Static preview. The interactive diagram replaces it after Mermaid loads.
flowchart LR
  n0["Python caller"]
  n1["MarketWatchGame wrapper"]
  n2["Base HTTP client"]
  n3["Virtual game service"]
  n0 --> n1
  n1 --> n2
  n2 --> n3
  n3 --> n2
Text version of the diagram
  • Python caller → MarketWatchGame wrapper
  • MarketWatchGame wrapper → Base HTTP client
  • Base HTTP client → Virtual game service
  • Virtual game service → Base HTTP client
Follow one path through the code

Follow buy from the game wrapper into the base client. The wrapper adds the game ID; session handling and the actual HTTP request happen below it.

Types and file structure

13 declared types, with 12 in the base-relationship overview.

Type diagram
classDiagram
direction TB
class t342c57589891["MarketWatch"] {
  __init__()
  create_session()
  generate_csrf_token()
  get_client_id()
}
class te2660179edef["MarketWatchGame"] {
  __init__()
  create_game()
  buy()
  sell()
}
class tc6adc7beb6df["MarketWatchException"] {
  __init__()
}
class tc9e9c1f2c012["MarketWatchGameException"] {
  __init__()
}
class td4c12f6259f0["Term"] {
}
class tb06037cc6ec7["PriceType"] {
}
class t3d7a45c40645["OrderType"] {
}
class t7d8a40bf3f38["GameSettings"] {
  __init__()
  __str__()
}
class tc2b2eb26d380["Order"] {
  __init__()
  __str__()
  __repr__()
}
class t45b8a20e40d7["Position"] {
  __init__()
  __str__()
  __repr__()
}
class t0783a857f7ca["Player"] {
  __init__()
  __str__()
  __repr__()
}
class t6ddf82fcb3c7["Game"] {
  __init__()
  __str__()
  __repr__()
}
class b4a739b8cc727["MarketWatch"] {
  <<unresolved_base>>
}
b4a739b8cc727 <|-- te2660179edef
class b218d46208022["Exception"] {
  <<unresolved_base>>
}
b218d46208022 <|-- tc6adc7beb6df
b218d46208022 <|-- tc9e9c1f2c012
class bcdccbbebe0a2["Enum"] {
  <<unresolved_base>>
}
bcdccbbebe0a2 <|-- td4c12f6259f0
bcdccbbebe0a2 <|-- tb06037cc6ec7
bcdccbbebe0a2 <|-- t3d7a45c40645

Unresolved bases remain labelled; full signatures are not reconstructed.

Type index

Reference

20 / 20 eligible files read (65 in the tree); 0 oversized, 0 failed reads and 0 syntax diagnostics.

What the scan covers

Known dependency/build folders, credential files and binaries are excluded. The scan covers READMEs, recognized manifests and parser-supported source files.

Linguist statistics cover the whole repository and may include other languages.

File map
flowchart TD
  root["marketwatch"]
  f0["README.md"]
  root --> f0
  f1["marketwatch/__init__.py"]
  root --> f1
  f2["marketwatch/game.py"]
  root --> f2
  f3["pyproject.toml"]
  root --> f3
  f4["requirements.txt"]
  root --> f4
  f5["setup.py"]
  root --> f5
  f6["api/__init__.py"]
  root --> f6
  f7["api/app.py"]
  root --> f7
  f8["api/docker-compose.yml"]
  root --> f8
  f9["api/requirements.txt"]
  root --> f9
  f10["marketwatch/exceptions.py"]
  root --> f10
  f11["marketwatch/schemas.py"]
  root --> f11
  f12["marketwatch/watchlist.py"]
  root --> f12
  f13["test/__init__.py"]
  root --> f13
  f14["test/test_exceptions.py"]
  root --> f14
  f15["test/test_game.py"]
  root --> f15

Files to read 3

References