This repository provides a complete pipeline for simulating trading strategies based on real-time stock data using the Korea Investment & Securities API. The focus is on analyzing Samsung Electronics' intraday stock data and implementing a moving average crossover strategy.
-
Access Token Generation
- Obtain an API access token from Korea Investment & Securities to interact with their real-time data services.
-
Data Retrieval
- Request 330-minute interval data for Samsung Electronics (005930.KQ) for the current trading day.
-
Data Visualization
- Use
pandas
andmatplotlib
to visualize stock trends, including candlestick patterns and moving averages.
- Use
-
Trading Strategy Simulation
- Simulate a trading strategy based on moving average crossovers.
- Generate buy/sell signals and evaluate performance.
-
Results Export
- Save the simulation results as a CSV file for further analysis.
trading_simul.ipynb
- A Jupyter Notebook that consolidates all functionalities:
- Authenticates with the API and fetches stock data.
- Visualizes stock trends and moving averages.
- Implements a moving average crossover strategy.
- Simulates trades and evaluates the strategy.
- Exports simulation results to a CSV file.
- A Jupyter Notebook that consolidates all functionalities:
Below is a sample of the CSV file generated by the simulation:
Date | Price | Signal | Profit/Loss |
---|---|---|---|
2025-01-16 | 70000 | BUY | 0 |
2025-01-16 | 71000 | SELL | 1000 |
The tools in this repository are developed using the Korea Investment & Securities API, which helps automate investment processes and provides access to real-time stock data for analysis.