| Overall Statistics |
|
Total Trades 209 Average Win 2.58% Average Loss -12.20% Compounding Annual Return 72.694% Drawdown 39.100% Expectancy 0.106 Net Profit 199.482% Sharpe Ratio 1.497 Probabilistic Sharpe Ratio 61.835% Loss Rate 9% Win Rate 91% Profit-Loss Ratio 0.21 Alpha 0.074 Beta 0.371 Annual Standard Deviation 0.383 Annual Variance 0.146 Information Ratio -1.553 Tracking Error 0.498 Treynor Ratio 1.546 Total Fees $1100137.87 Estimated Strategy Capacity $15000000.00 Lowest Capacity Asset ETHUSD XJ |
using QuantConnect.Data.Market;
using QuantConnect.Indicators;
using QuantConnect.Securities;
namespace QuantConnect.Algorithm.CSharp
{
public class EnergeticRedPanda : QCAlgorithm
{
//USER VARIABLES
private string _ticker = "ETHUSD"; //virtual pair - tracks the USD value of 1 ETH
private int _startingCash = 1000000;
private decimal _weight = .5m; //.5m;
private decimal _trailPercent = .025m; // trailing stop
private decimal _targetPercent = .025m; // profit target
private decimal _stopPercent = .05m; // stops loss
private SecurityHolding _holdings;
//private VolumeWeightedAveragePriceIndicator _vwap; //added as a Vwap entry
//public override void Initialize() //
//PROGRAM VARIABLES
public decimal _price;
public decimal usd; //the amount of USD in our cashbook
public decimal _holding; //the number of Ether we hold in the portfolio
public string _baseSymbol; //tracks the USD value of 1 ETH
public decimal _trailPrice;
public decimal _targetPrice;
public decimal _stopPrice;
public override void Initialize()
{
SetStartDate(2020, 1, 1); //Set Start Date - year/MM/DD
SetEndDate(2022, 1, 1);
SetCash(_startingCash); //Set Strategy Cash
var _crypto = AddCrypto(_ticker, Resolution.Daily);
_baseSymbol = _crypto.BaseCurrencySymbol;
_holdings = _crypto.Holdings;
//_vwap = VWAP( "ETHUSD", 20);
SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash);
//Adding insights to the simpliest possible alpha model
AddAlpha( new ConstantAlphaModel(InsightType.Price, InsightDirection.Up, TimeSpan.FromMinutes(5), 1, 1, null));
SetRiskManagement(new MaximumDrawdownPercentPerSecurity(0.25m));
// Schedule an event to fire on certain days of the week
Schedule.On(DateRules.Every(DayOfWeek.Monday, DayOfWeek.Friday), TimeRules.At(12, 0), () =>
{
Log("Mon/Fri at 12pm: Fired at: " + Time);
});
}
// ONDATA BLOCK
public override void OnData(Slice data)
{
_price = data[_ticker].Price;
if (!Portfolio.Invested)
{
SetHoldings(_ticker, _weight);
Log($"NotInv-Purchased {_ticker} at {_price}");
_targetPrice = _price + ( _price * _targetPercent);
_trailPrice = _price + ( _price * _trailPercent);
}
if (Portfolio.Invested)
{
_holding = Portfolio.CashBook[_baseSymbol].Amount;
_targetPrice = _price + ( _price * _targetPercent);
_stopPrice = _price - ( _price * _stopPercent);
if ( _price > _targetPrice)
{
Sell(_ticker, _holding);
Log($"Inv-Sold {_ticker} at {_price}");
}
if ( _price < _stopPrice)
{
Sell(_ticker, _holding);
Log($"Inv-Stopped {_ticker} at {_price}");
}
if ( _price > _trailPrice)
{
Sell(_ticker, _holding);
Log($"Inv-Stopped {_ticker} at {_price}");
}
}
}
// public override void OnEndOfDay(string _ticker)
// {
// Liquidate(_ticker);
// }
// public override void OnOrderEvent(OrderEvent orderEvent)
// {
// Log(orderEvent.ToString());
// }
}
}