Skip to content

Instantly share code, notes, and snippets.

@ChadThackray
ChadThackray / historical-data.py
Created June 22, 2024 08:25
Get Historical Crypto price data in Python
# Licensed under the MIT License. See comment below for full licence information.
import pandas as pd
import yfinance as yf
df = yf.Ticker("BTC-USD").history(period = "1d", interval = "1m")
print(df)
@ChadThackray
ChadThackray / candle-aggregation.py
Created June 22, 2024 08:32
Aggregating Candlesticks to different time-frames in python
# Licensed under the MIT License. See comment below for full licence information.
import pandas as pd
"""
df = pd.read_csv("minute-data.csv")[["unix","open","high","low","close","volume"]]
df["date"] = pd.to_datetime(df["unix"], unit = "s")
df.set_index("date", inplace=True)
@ChadThackray
ChadThackray / ohlc-bitstamp.py
Created June 22, 2024 08:35
Historical Crypto candlestick/OHLC data from Bitstamp in Python
# Licensed under the MIT License. See comment below for full licence information.
import json
import requests
import pandas as pd
import datetime
start = "2021-11-01"
end = "2021-11-10"
@ChadThackray
ChadThackray / dca-backtesting-py.py
Created June 22, 2024 15:45
Backtest Your Dollar Cost Average Strategy easily in Python
# Licensed under the MIT License. See comment below for full licence information.
import pandas as pd
from backtesting import Backtest, Strategy
from backtesting.test import GOOG
import math
class DCA(Strategy):
@ChadThackray
ChadThackray / candles-vectorbt.py
Created June 22, 2024 15:55
Backtesting Candlestick Patterns in Python
# Licensed under the MIT License. See comment below for full licence information.
import vectorbt as vbt
import yfinance as yf
import pandas as pd
from datetime import datetime, timedelta
import talib
@ChadThackray
ChadThackray / polygon-data-2022.py
Created June 22, 2024 16:08
Free Crypto Price Data from Polygon.io in Python
# Licensed under the MIT License. See comment below for full licence information.
import requests
import pandas as pd
from datetime import date, datetime, timedelta
import time
def pull_1m_data(symbol, date):