This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CryptoMomentum(QCAlgorithm): | |
def Initialize(self): | |
resolution = Resolution.Daily | |
self.SetBrokerageModel(BrokerageName.Binance, AccountType.Cash) | |
self.SetStartDate(2018, 1, 1) | |
self.SetCash('USDT', 9000) | |
self.SetWarmUp(timedelta(200), resolution) | |
self.EQUITY_RISK_PC = 0.01 | |
tickers = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CryptoMomentum(QCAlgorithm): | |
def Initialize(self): | |
resolution = Resolution.Daily | |
self.SetBrokerageModel(BrokerageName.Binance, AccountType.Cash) | |
self.SetStartDate(2018, 1, 1) | |
self.SetCash('USDT', 9000) | |
self.SetWarmUp(timedelta(200), resolution) | |
self.EQUITY_RISK_PC = 0.01 | |
tickers = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SymbolIndicators: | |
def __init__(self) -> None: | |
self.ma = SimpleMovingAverage(50) | |
self.ma_long = SimpleMovingAverage(200) | |
self.atr = AverageTrueRange(21) | |
self.closed_below_window = RollingWindow[bool](2) | |
def update(self, trade_bar): | |
self.ma.Update(trade_bar.EndTime, trade_bar.Close) | |
self.ma_long.Update(trade_bar.EndTime, trade_bar.Close) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import yfinance as yf | |
import pandas as pd | |
from typing import Optional; | |
def ticker_in_uptrend(ticker: str) -> tuple[bool, Optional[str]]: | |
now = datetime.datetime.now() | |
price_data = yf.download( | |
ticker, | |
now - datetime.timedelta(days=365), |