Metadata-Version: 2.4
Name: TradeSim-Coptee
Version: 0.1.2
Summary: Trading simulation using SET50 data with portfolio and order matching features.
Author: Coptee
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: rich
Requires-Dist: gspread
Requires-Dist: google-auth
Requires-Dist: google-api-python-client
Requires-Dist: google-auth-httplib2
Requires-Dist: google-auth-oauthlib
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Trading Simulation

A Python-based trading simulator using SET50 daily tick data.  
This system mimics real-time trading environments and supports development of algorithmic (ALGO) trading strategies with features such as order matching, portfolio management, commission/VAT handling, and more.

---

## 💼 Overview

The simulator reproduces a streaming-like stock trading system with capabilities including:

- Order placement and matching
- Real-time-like data streaming
- Portfolio tracking and analysis
- Automated performance summarization

Each trader starts with an **initial cash balance of 10,000,000 THB**. This capital will be managed through the portfolio system and used throughout the trading competition or simulation.

---

## 🧠 Features

### 📈 Stock & Portfolio Management

- Initialize a portfolio or load an existing one
- Update market prices during simulation
- Track and calculate key financial metrics:
  - Amount by cost
  - Average cost per stock
  - Unrealized & realized gains/losses (in value and %)
  - Net Asset Value (NAV)
  - Maximum Drawdown
  - Calmar Ratio

### 📊 Portfolio Summary

- Automatically generate transaction summaries
- Output metrics such as buy/sell volume, average price, commission, VAT, and net result

### 📝 Order Handling

- Submit buy/sell orders under these rules:
  - Stocks must belong to the **SET50 index**
  - Volume must be a multiple of 100 (standard lot size)
  - Partial or invalid volumes (e.g. 150) are rejected
  - Orders exceeding portfolio cash will be rejected
- All valid orders are recorded and matched against streaming market data

### 🔁 Order Matching Simulation

- Market simulator checks all orders during each time step
- Orders are executed only if matched price/volume is available in the stream
- Realistic handling of slippage, VAT (7%), and commission (0.157%), and slippage (0.03%)

### 📤 Strategy Result Submission

- After simulation, trading performance and results are automatically generated
- Ensure the portfolio name matches your trader/team name for correct result assignment

---

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.


## ⚙️ Requirements

- Python 3.9.13+
- pandas
- rich
- gspread
- google-auth
- google-api-python-client
- google-auth-httplib2
- google-auth-oauthlib

Install dependencies:

```bash
pip install -r requirements.txt
