<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Willian Pinho on Medium]]></title>
        <description><![CDATA[Stories by Willian Pinho on Medium]]></description>
        <link>https://medium.com/@willianpinho?source=rss-41213db98542------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wEmZ7QPXZdnbqB9MPSZM5g.jpeg</url>
            <title>Stories by Willian Pinho on Medium</title>
            <link>https://medium.com/@willianpinho?source=rss-41213db98542------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 19:40:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@willianpinho/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Store Historical Trading Data in MySQL for Backtesting ️]]></title>
            <link>https://medium.com/@willianpinho/how-to-store-historical-trading-data-in-mysql-for-backtesting-%EF%B8%8F-c88e43f72370?source=rss-41213db98542------2</link>
            <guid isPermaLink="false">https://medium.com/p/c88e43f72370</guid>
            <category><![CDATA[crytocurrency]]></category>
            <category><![CDATA[binance]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Willian Pinho]]></dc:creator>
            <pubDate>Mon, 04 Aug 2025 18:24:54 GMT</pubDate>
            <atom:updated>2025-08-04T18:24:54.353Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Storing Market Data Efficiently Matters</h3><p>In the previous post, we collected historical OHLCV (Open, High, Low, Close, Volume) data from Binance. But raw data alone is not enough — we need to store it efficiently for easy access during backtesting.</p><p>✅ Why use a database instead of just CSV files?</p><p>• Faster queries 🚀 — Retrieve specific timeframes instantly instead of scanning large files.</p><p>• Scalability 📈 — Handle millions of records without performance issues.</p><p>• Data integrity 🔒 — Prevent duplicated or missing records.</p><p>• Multi-strategy support 🏦 — Store and compare data across different timeframes &amp; assets.</p><p>Today, we’ll store our trading data in MySQL, setting up a structured, queryable, and scalable database for backtesting.</p><h3>📌 Step 2: Setting Up MySQL for Trading Data</h3><p><strong>1️⃣ Creating the Database and Table</strong></p><p>First, let’s create a MySQL database to store historical trading data. We define a dynamic table structure to store OHLCV data for different symbols and timeframes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3bRmWXxsEaJzdN__" /></figure><h3>📝 Writing Python Code to Insert Data into MySQL</h3><p>Now that our table is ready, we need a Python script to insert our collected Binance data into the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*a0rKmDgKaWAD0DdS" /></figure><h3>📊 Querying and Using Stored Data for Backtesting</h3><p>Once our data is stored, we can easily retrieve it for analysis and backtesting.</p><p><strong>🔎 Fetching Historical Data from MySQL with Python</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GWCRo7oS1btL9n72" /></figure><h3>🚀 Benefits of Using MySQL for Backtesting</h3><p>✔️ Fast access to historical data — Optimized queries instead of parsing CSVs.</p><p>✔️ Scalable storage — Store years of trading data with efficient indexing.</p><p>✔️ Structured and queryable — Retrieve data for specific symbols and timeframes instantly.</p><p>✔️ Ensures data integrity — No duplicate records, and timestamps remain unique.</p><p>By storing our data properly, we eliminate data bottlenecks and make backtesting much faster.</p><h3>💡 Next Steps: Implementing a Bitcoin Trading Strategy</h3><p>Now that we collected and stored historical market data, we can implement a trading strategy and test it with backtesting.</p><p>🚀 In the next post, we will:</p><p>✅ Implement a Scalping Strategy for Bitcoin using technical indicators like RSI, EMA, and Bollinger Bands.</p><p>✅ Write Python code to analyze market conditions and generate trading signals.</p><p>✅ Discuss position sizing, risk management, and strategy execution.</p><h3>🔎 Summary of This Post:</h3><p>✅ Why databases are better than CSVs for backtesting.</p><p>✅ How to create a MySQL database and store OHLCV data.</p><p>✅ Python scripts to insert and retrieve market data.</p><p>✅ How to query and use stored data for analysis.</p><p>👉 What is your preferred method for storing trading data? Do you use databases or keep everything in CSVs?</p><p>Let me know in the comments! 👇</p><p>📢 If you missed Step 1 on how to collect historical trading data, check it out here:</p><p>🔗 <a href="https://medium.com/@willianpinho/backtesting-a-bitcoin-trading-strategy-using-python-mysql-and-binance-api-1573716366e9">Step 1: Collecting Historical Trading Data</a></p><p>📢 If you found this post useful, like &amp; share it to help more developers build powerful backtesting systems! 🚀</p><p>#Trading #Python #AlgorithmicTrading #Crypto #Backtesting #MySQL #Finance #QuantitativeTrading</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c88e43f72370" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Backtesting a Bitcoin Trading Strategy Using Python, MySQL, and Binance API ]]></title>
            <link>https://medium.com/@willianpinho/backtesting-a-bitcoin-trading-strategy-using-python-mysql-and-binance-api-1573716366e9?source=rss-41213db98542------2</link>
            <guid isPermaLink="false">https://medium.com/p/1573716366e9</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[binance]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Willian Pinho]]></dc:creator>
            <pubDate>Mon, 04 Aug 2025 15:45:24 GMT</pubDate>
            <atom:updated>2025-08-04T15:45:24.260Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Backtesting Matters in Algorithmic Trading?</h3><p>Backtesting is a crucial step in developing algorithmic trading strategies. Before deploying a strategy in live trading, we need to validate its performance, risk metrics, and profitability using historical data. Without proper backtesting, we risk running an unoptimized or even losing strategy in real markets.</p><p>In this post series, I will walk you through a complete backtesting pipeline for Bitcoin trading strategies, using Python, MySQL, Pandas, NumPy, TA-Lib, and Binance API.</p><h3>🔍 What Will You Learn in This Series?</h3><p>Throughout this series, I will cover:</p><p>✅ How to collect historical market data from Binance using Python.</p><p>✅ How to store trading data efficiently in a MySQL database.</p><p>✅ How to implement a Bitcoin trading strategy using technical indicators.</p><p>✅ How to run a backtest to validate the strategy’s performance.</p><p>✅ How to analyze results using key metrics such as Sharpe Ratio, Win Rate, Drawdown, and Profit Factor.</p><p>By the end of this series, you’ll have a fully working backtesting system that you can use to test and optimize your own trading strategies.</p><h3>📌 Step 1: Collecting Historical Trading Data</h3><p>The first step of any backtesting system is data collection. We need a reliable source of historical price data to simulate trades. In this case, we will use the Binance API to retrieve OHLCV (Open, High, Low, Close, Volume) candlestick data for the BTC/USDT trading pair.</p><p><strong>Challenges in Data Collection</strong></p><p>🔸 The Binance API has a limit of 1000 candles per request, so we need to fetch data in chunks to collect long-term historical data.</p><p>🔸 We must convert timestamps from Binance’s format to human-readable datetime.</p><p>🔸 The data needs to be stored efficiently in a database or a CSV file for future use.</p><p><strong>📝 Python Code to Fetch Historical Data from Binance</strong></p><p>Below is a Python function that collects historical OHLCV data from Binance and returns it as a Pandas DataFrame.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/0*1aSzIXdRJV01rhL2" /></figure><p><strong>📂 Storing the Data for Future Use</strong></p><p>Once we have collected the data, we can save it for later analysis. The two most common methods are:</p><p>✅ Saving to CSV — Ideal for small datasets and quick tests.</p><p>✅ Storing in a SQL database — Recommended for long-term storage and efficient querying.</p><p>Here’s how to save the collected data as a CSV file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YlmvRwUvNDHVeuCS" /></figure><p><strong>💡 Next Steps: Storing Data in a Database</strong></p><p>In the next post, I will show you how to store the collected trading data in a MySQL database. This will allow us to efficiently query and retrieve historical data for backtesting.</p><p>🚀 Stay tuned! If you’re interested in algorithmic trading and Python, follow me for the next steps in building a complete backtesting system!</p><p><strong>🔎 Summary of This Post:</strong></p><p>✅ Why backtesting is essential for trading strategies</p><p>✅ Challenges when collecting historical trading data</p><p>✅ How to fetch OHLCV data from Binance API using Python</p><p>✅ How to save the data in CSV format for later use</p><p>👉 What other data sources do you use for backtesting? Let me know in the comments!</p><p><a href="https://github.com/willianpinho/trading-bot">https://github.com/willianpinho/trading-bot</a></p><p>#Trading #Python #AlgorithmicTrading #Crypto #Backtesting #BinanceAPI #Finance #QuantitativeTrading</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1573716366e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>