A simple Flask application that allows users to:
- Manage Users (CRUD)
- Manage Trades (CRUD)
- Analyze Trade Performance (win/loss, most profitable, average profit, etc.)
- Track Strategies & Notes (CRUD)
- Add Comments on trades (CRUD)
This file contains sample data structures for:
- users (dictionary)
- trades (list)
- strategies (dictionary)
- comments (list)
A minimal example:
{
"users": {
"1": { "name": "Alice", "email": "alice@example.com" },
"2": { "name": "Bob", "email": "bob@example.com" }
},
"trades": [
{
"id": 1,
"user_id": 1,
"asset": "AAPL",
"quantity": 10,
"profit": 200
}
],
"strategies": {
"1": [
{
"id": 1,
"user_id": 1,
"description": "My initial strategy"
}
],
"2": []
},
"comments": []
}-
GET
/users- Retrieve all users.
-
GET
/users/<user_id>- Retrieve a single user by ID (integer).
-
POST
/users- Create a new user (body with JSON fields, e.g.,
name,email).
- Create a new user (body with JSON fields, e.g.,
-
PUT
/users/<user_id>- Update existing user data (body with JSON to update fields).
-
DELETE
/users/<user_id>- Delete a user by ID.
-
GET
/trades- Retrieve all trades.
-
GET
/trades/<trade_id>- Retrieve a specific trade by ID.
-
POST
/trades- Add a new trade (body with JSON fields like
user_id,asset,profit, etc.).
- Add a new trade (body with JSON fields like
-
PUT
/trades/<trade_id>- Update a trade.
-
DELETE
/trades/<trade_id>
- Delete a trade by ID.
- GET
/trades/user/<user_id>
- Retrieve all trades belonging to a single user.
- GET
/trades/win-loss/<user_id>
- Return the count of winning (
profit > 0) vs losing (profit < 0) trades.
- GET
/trades/most-profitable
- Return the top 5 trades by highest
profit.
- GET
/trades/average-profit/<user_id>
- Calculate the average profit for trades belonging to a user.
- GET
/trades/most-traded-assets/<user_id>
- List distinct assets a user has traded.
- GET
/strategy
- Get all strategies across all users.
- GET
/strategy/<user_id>
- Get strategies belonging to one user.
- POST
/strategy
- Add a new strategy (body includes
user_idanddescription).
- PUT
/strategy/<strategy_id>
- Update a strategy’s details.
- DELETE
/strategy/<strategy_id>
- Delete a strategy by ID.
- GET
/comments
- Retrieve all comments.
- GET
/comments/<comment_id>
- Retrieve a specific comment by ID.
- POST
/comments
- Add a new comment (body includes
trade_id,user_id, andtext).
- PUT
/comments/<comment_id>
- Update an existing comment.
- DELETE
/comments/<comment_id>
- Delete a comment by ID.