| Overall Statistics |
|
Total Orders 1 Average Win 0% Average Loss 0% Compounding Annual Return -1.086% Drawdown 36.300% Expectancy 0 Start Equity 25000 End Equity 22403.93 Net Profit -10.384% Sharpe Ratio -0.221 Sortino Ratio -0.149 Probabilistic Sharpe Ratio 0.004% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.036 Beta 0.188 Annual Standard Deviation 0.099 Annual Variance 0.01 Information Ratio -0.655 Tracking Error 0.152 Treynor Ratio -0.116 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset WIKI/IBM.NasdaqCustomColumns 2S Portfolio Turnover 0.03% |
from AlgorithmImports import *
from QuantConnect.DataSource import *
class NasdaqImporterAlgorithm(QCAlgorithm):
def initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
self.nasdaq_code = "WIKI/IBM"
## Optional argument - personal token necessary for restricted dataset
# NasdaqDataLink.set_auth_code(self.get_parameter("nasdaq-data-link-api-key"))
self.set_start_date(2014,4,1) #Set Start Date
self.set_end_date(datetime.today() - timedelta(1)) #Set End Date
self.set_cash(25000) #Set Strategy Cash
self.add_data(NasdaqCustomColumns, self.nasdaq_code, Resolution.DAILY, TimeZones.NEW_YORK)
self.sma = self.SMA(self.nasdaq_code, 14)
def on_data(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.'''
if not self.portfolio.hold_stock:
self.set_holdings(self.nasdaq_code, 1)
self.debug("Purchased {0} >> {1}".format(self.nasdaq_code, self.time))
self.plot(self.nasdaq_code, "PriceSMA", self.sma.current.value)
# NasdaqDataLink often doesn't use close columns so need to tell LEAN which is the "value" column.
class NasdaqCustomColumns(NasdaqDataLink):
'''Custom nasdaq data type for setting customized value column name. Value column is used for the primary trading calculations and charting.'''
def __init__(self):
# Define ValueColumnName: cannot be None, Empty or non-existant column name
super().__init__("adj. close")
self.value_column_name = "adj. close"