Skip to content

Commit

Permalink
Update README.md (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebou12 authored May 9, 2023
1 parent 24c2676 commit 5ff9027
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 43 deletions.
95 changes: 66 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,92 +18,123 @@ Based on code from
- https://github.com/kevindong/MarketWatch_API/
- https://github.com/bwees/pymarketwatch

## 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

```
```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 Price

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

### Get Games
### 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

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

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

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

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

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

### Sell
### 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()
```
marketwatch.sell("game-name", "AAPL", 100)

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

### Example
Expand Down Expand Up @@ -133,3 +164,9 @@ if __name__ == "__main__":
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.
65 changes: 51 additions & 14 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,121 @@
### Import
To start using the marketwatch library, import the MarketWatch class:
```
```python
from marketwatch import MarketWatch
```

### Login
Create a MarketWatch instance and log in with your username and password:
```
```python
marketwatch = MarketWatch(username, password)
```

### Get Price
Fetch the current price of a stock by passing its ticker symbol:
```
```python
marketwatch.get_price("AAPL")
```

### Get Games
Retrieve the list of games you are participating in:
```
```python
marketwatch.get_games()
```

### Get Game
Fetch detailed information about a specific game by providing the game's name:
```
```python
marketwatch.get_game("game-name")
```

### Get Game Settings
Access the settings of a specific game:
```
```python
marketwatch.get_game_settings("game-name")
```

### Get Leaderboard
Retrieve the leaderboard data for a specific game:
```
```python
marketwatch.get_leaderboard("game-name")
```

### Get Portfolio
Fetch your portfolio information in a specific game:
```
```python
marketwatch.get_portfolio("game-name")
```

### Get Portfolio Performance
Retrieve the performance of your portfolio in a specific game:
```
```python
marketwatch.get_portfolio_performance("game-name")
```

### Get Transactions
Access the transaction history for your portfolio in a specific game:
```
```python
marketwatch.get_transactions("game-name")
```

### Get Positions
Fetch the current positions of your portfolio in a specific game:
```
```python
marketwatch.get_positions("game-name")
```

### Get Pending Orders
Retrieve the list of pending orders for your portfolio in a specific game:
```
```python
marketwatch.get_pending_orders("game-name")
```

### Buy
Place a buy order for a specific stock by providing the game's name, the stock's ticker symbol, and the number of shares:
```
```python
marketwatch.buy("game-name", "AAPL", 100)
```

### Sell
Place a sell order for a specific stock by providing the game's name, the stock's ticker symbol, and the number of shares:
```
```python
marketwatch.sell("game-name", "AAPL", 100)
```

### Create Watchlist
Create a new watchlist by providing a name and optionally a list of tickers:
```python
marketwatch.create_watchlist("My Watchlist", ["AAPL", "GOOG", "TSLA"])
```

### Add to Watchlist
Add tickers to an existing watchlist by providing the watchlist ID and a list of tickers:
```python
marketwatch.add_to_watchlist("watchlist_id", ["MSFT", "AMZN"])
```

### Get Watchlists
Retrieve all your watchlists:
```python
marketwatch.get_watchlists()
```

### Get Watchlist
Fetch a specific watchlist by providing its ID:
```python
marketwatch.get_watchlist("watchlist_id")
```

### Delete Watchlist
Delete a specific watchlist by providing its ID:
```python
marketwatch.delete_watchlist("watchlist_id")
```

### Delete Watchlist Item
Remove a ticker from a watchlist by providing the watchlist ID and the ticker:
```python
marketwatch.delete_watchlist_item("watchlist_id", "AAPL")
```

For more examples and detailed explanations of each function, visit the official GitHub repository of the marketwatch library.

0 comments on commit 5ff9027

Please sign in to comment.