当前位置: 首页>>代码示例>>Python>>正文


Python Logger.log方法代码示例

本文整理汇总了Python中pyswing.utils.Logger.Logger.log方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.log方法的具体用法?Python Logger.log怎么用?Python Logger.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyswing.utils.Logger.Logger的用法示例。


在下文中一共展示了Logger.log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getActiveStrategies

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
def getActiveStrategies():

    connection = sqlite3.connect(pyswing.database.pySwingDatabase)

    query = "select rule1, rule2, exit, type, rule3, meanResultPerTrade, medianResultPerTrade, totalProfit, numberOfTrades, sharpeRatio, maximumDrawdown from ActiveStrategy where active = 1"

    strategies = None

    cursor = connection.cursor()
    try:
        cursor.execute(query)
        strategies = cursor.fetchall()
    except sqlite3.OperationalError:
        Logger.log(logging.INFO, "Error Getting Strategies", {"scope":__name__})

    connection.close()

    strategiesList = []
    for strategyRow in strategies:

        strategy = Strategy(strategyRow[0], strategyRow[1], strategyRow[2], strategyRow[3], strategyRow[4])
        strategiesList.append(strategy)

        strategy.meanResultPerTrade = strategyRow[5]
        strategy.medianResultPerTrade = strategyRow[6]
        strategy.totalProfit = strategyRow[7]
        strategy.numberOfTrades = strategyRow[8]
        strategy.sharpeRatio = strategyRow[9]
        strategy.maximumDrawdown = strategyRow[10]

    return strategiesList
开发者ID:garyjoy,项目名称:pyswing,代码行数:33,代码来源:strategy.py

示例2: analyseRule

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
    def analyseRule(self):
        """
        ?
        """

        Logger.log(logging.INFO, "Analysing Rule", {"scope":__name__, "Rule":self._ruleTableName})

        equityCount = self._getEquityCount()
        potentialRuleMatches = self._getPotentialRuleMatches()

        connection = sqlite3.connect(pyswing.database.pySwingDatabase)

        cursor = connection.cursor()

        try:
            query = "select count(1) from '%s' where Match = 1;" % self._ruleTableName
            cursor.execute(query)
            actualRuleMatches = int(cursor.fetchone()[0])

            query = "delete from Rules where Rule = '%s'" % self._ruleTableName
            cursor.execute(query)

            # Unit Testing is easier if the value is stored...
            self._matchesPerDay = actualRuleMatches / potentialRuleMatches * equityCount
            query = "insert into Rules values('%s',%s)" % (self._ruleTableName, self._matchesPerDay)
            cursor.execute(query)

        except sqlite3.OperationalError:
            Logger.log(logging.INFO, "Error Analysing Rule", {"scope":__name__, "Rule":self._ruleTableName})

        connection.commit()

        connection.close()
开发者ID:garyjoy,项目名称:pyswing,代码行数:35,代码来源:rule.py

示例3: importData

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
    def importData(self):
        """
        Import (New) Data from Yahoo.
        """

        start = self._getLatestDate()
        end = self._getTodaysDate()

        Logger.log(logging.INFO, "Loading Data", {"scope":__name__, "tickerCode":self._tickerCode, "start":str(start), "end":str(end)})
        self._data = DataReader(self._tickerCode, "yahoo", start, end)

        self._data['Code'] = self._tickerCode

        for item in ['Open', 'High', 'Low']:
            self._data[item] = self._data[item] * self._data['Adj Close'] / self._data['Close']

        self._data.drop('Close', axis=1, inplace=True)
        self._data.rename(columns={'Adj Close':'Close'}, inplace=True)
        self._data['Volume'] = self._data['Volume'].astype(float)

        connection = sqlite3.connect(pyswing.database.pySwingDatabase)

        query = "insert or replace into Equities (Date, Open, High, Low, Volume, Close, Code) values (?,?,?,?,?,?,?)"
        connection.executemany(query, self._data.to_records(index=True))
        connection.commit()

        connection.close()
开发者ID:garyjoy,项目名称:pyswing,代码行数:29,代码来源:equity.py

示例4: sendEmail

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
def sendEmail(tradeDetails):

    message = "Hello!\n\n"
    for trade in tradeDetails:
        message += trade
        message += "\n\n"

    message += "x"

    subject = None
    if len(tradeDetails) > 0:
        subject = "Horse Says Trade!"
    else:
        subject = "Horse Says Go Back To Bed!"

    header  = 'From: %s\n' % "[email protected]"
    header += 'To: %s\n' % ','.join(["[email protected]"])
    header += 'Subject: %s\n\n' % subject
    message = header + message

    server = smtplib.SMTP("smtp.gmail.com:587")
    server.starttls()
    server.login("[email protected]", "abcABC1234567890")
    problems = server.sendmail("[email protected]", ["[email protected]"], message)
    server.quit()

    if problems:
        Logger.log(logging.ERROR, "Error Sending E-mail", {"scope": __name__, "problems": str(problems)})
开发者ID:garyjoy,项目名称:pyswing,代码行数:30,代码来源:AskHorse.py

示例5: askHorse

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
    def askHorse(self, latestDate):

        self.tradeDetails = []

        connection = sqlite3.connect(pyswing.database.pySwingDatabase)

        query = ("select r1.Code, r1.Date "
            "from '%s' r1 "
            " inner join '%s' r2 on r2.Match = 1 and r1.Date = r2.Date and r1.Code = r2.Code "
            " inner join '%s' r3 on r3.Match = 1 and r1.Date = r3.Date and r1.Code = r3.Code "
            "where r1.Match = 1 and r1.Date = '%s'") % (self._rule1, self._rule2, self._rule3, latestDate)

        trades = None

        cursor = connection.cursor()
        try:
            cursor.execute(query)
            # print(query)
            trades = cursor.fetchall()
        except sqlite3.OperationalError:
            Logger.log(logging.INFO, "Error Getting Trades", {"scope":__name__})

        connection.close()

        for trade in trades:
            tradeSummary = ("%s %s using %s") % (self._type, trade[0], self._exit)
            strategyDetail = ("Strategy: Mean: %s, Median: %s, Total: %s, Trades: %s, Sharpe Ratio: %s, Drawdown: %s") % (str(self.meanResultPerTrade), str(self.medianResultPerTrade), str(self.totalProfit), str(self.numberOfTrades), str(self.sharpeRatio), str(self.maximumDrawdown))
            rulesDetail = ("Rules: '%s', '%s' and '%s'") % (self._rule1, self._rule2, self._rule3)

            tradeDetail = "%s (%s)\n%s" % (tradeSummary, strategyDetail, rulesDetail)
            self.tradeDetails.append(tradeDetail)
            Logger.log(logging.INFO, "Suggested Trade", {"scope":__name__, "tradeDetail":tradeDetail})

        return len(self.tradeDetails) > 0
开发者ID:garyjoy,项目名称:pyswing,代码行数:36,代码来源:strategy.py

示例6: __init__

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
    def __init__(self):
        """
        ?
        """

        Logger.log(logging.DEBUG, "Log Object Creation", {"scope": __name__})

        self._rules = self._getRules()
开发者ID:garyjoy,项目名称:pyswing,代码行数:10,代码来源:historicMatches.py

示例7: __init__

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
    def __init__(self, tickerCode):
        """
        Constructor.

        There isn't much to see here. It just makes a note of the Ticker Code.

        :param tickerCode: Ticker Code.
        """

        Logger.log(logging.DEBUG, "Log Object Creation", {"scope":__name__, "arguments":" ".join({tickerCode})})

        self._tickerCode = tickerCode
开发者ID:garyjoy,项目名称:pyswing,代码行数:14,代码来源:equity.py

示例8: __init__

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
    def __init__(self, relativeFilePath):
        """
        Read the Ticker Codes in the specified file into a data set (pandas.DataFrame).

        :param relativeFilePath: Relative file path (String) for the (file) list of ticker codes.
        """

        Logger.log(logging.DEBUG, "Log Object Creation", {"scope":__name__, "arguments":" ".join({relativeFilePath})})

        self._relativeFilePath = relativeFilePath

        self.tickers = pandas.read_csv(relativeFilePath)
开发者ID:garyjoy,项目名称:pyswing,代码行数:14,代码来源:market.py

示例9: deleteDirectory

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
def deleteDirectory(relativeDirectoryPath):
    """
    Delete the specified directory.

    :param relativeDirectoryPath: Relative (from the working directory) path to a directory (i.e. that we want to delete).
    """

    try:
        if os.path.exists(relativeDirectoryPath):
            shutil.rmtree(relativeDirectoryPath)
    except OSError as osError:
        Logger.log(logging.ERROR, "Cannot Delete Directory", {"scope":__name__, "directory":relativeDirectoryPath})
        Logger.log(logging.DEBUG, "Caught Exception", {"scope":__name__, "exception":str(osError)})
开发者ID:garyjoy,项目名称:pyswing,代码行数:15,代码来源:FileHelper.py

示例10: evaluateThreeRuleStrategy

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
    def evaluateThreeRuleStrategy(self):
        """
        ?
        """

        Logger.log(logging.INFO, "Evaluating Three-Rule Strategy", {"scope":__name__, "Rule 1":self._rule1, "Rule 2":self._rule2, "Rule 3":self._rule3, "Type":self._type})

        connection = sqlite3.connect(pyswing.database.pySwingDatabase)
        c = connection.cursor()
        sql = self.evaluateThreeRuleSql % (pyswing.globals.pySwingStrategy, self._rule1, self._rule2, self._rule3, self._exit, self._type, self._rule1, self._rule2, self._rule3, self._exit, self._type)
        c.executescript(sql)
        connection.commit()
        c.close()
        connection.close()
开发者ID:garyjoy,项目名称:pyswing,代码行数:16,代码来源:strategy.py

示例11: emptyHistoricTradesTable

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
def emptyHistoricTradesTable():

    connection = sqlite3.connect(pyswing.database.pySwingDatabase)

    query = "delete from HistoricTrades"

    cursor = connection.cursor()
    try:
        cursor.execute(query)
        connection.commit()
    except sqlite3.OperationalError:
        Logger.log(logging.INFO, "Error Deleting Historic Trades", {"scope":__name__})

    connection.close()
开发者ID:garyjoy,项目名称:pyswing,代码行数:16,代码来源:strategy.py

示例12: deleteEmptyThreeRuleStrategies

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
def deleteEmptyThreeRuleStrategies():

    connection = sqlite3.connect(pyswing.database.pySwingDatabase)

    query = "delete from ThreeRuleStrategy where resultPerTrade is NULL"

    cursor = connection.cursor()
    try:
        cursor.execute(query)
        connection.commit()
    except sqlite3.OperationalError:
        Logger.log(logging.INFO, "Error Deleting Empty Three Rule Strategies", {"scope":__name__})

    connection.close()
开发者ID:garyjoy,项目名称:pyswing,代码行数:16,代码来源:strategy.py

示例13: markTwoRuleStrategyAsProcessed

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
def markTwoRuleStrategyAsProcessed(rule1, rule2, type):

    connection = sqlite3.connect(pyswing.database.pySwingDatabase)

    query = "update TwoRuleStrategy set Searched = 1 where rule1 = '%s' and rule2 = '%s' and type = '%s';" % (rule1, rule2, type)

    cursor = connection.cursor()
    try:
        cursor.execute(query)
        connection.commit()
    except sqlite3.OperationalError:
        Logger.log(logging.INFO, "Error Updating Strategy", {"scope":__name__})

    connection.close()
开发者ID:garyjoy,项目名称:pyswing,代码行数:16,代码来源:strategy.py

示例14: forceWorkingDirectory

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
def forceWorkingDirectory():
    """
    forceWorkingDirectory() will ensure that the working directory is set to the project root (i.e. /Users/Gary/PycharmProjects/pyswing).

    There is a discrepancy between TeamCity (which always forces the working directory to be the project root) and IDEs
    (e.g. Eclipse, PyCharm) (which, by default, set the working directory to be the directory containing the script being run).
    """

    Logger.log(logging.DEBUG, "Log Method Call", {"scope":__name__, "arguments":""})

    workingDirectory = os.path.abspath(os.path.curdir)
    if (os.path.exists("pyswing") and os.path.exists("test")):
        Logger.log(logging.DEBUG, "Working Directory", {"scope":__name__, "workingDirectory":workingDirectory})
    else:
        newWorkingDirectory = None

        if os.path.exists("../pyswing") and os.path.exists("../test"):
            newWorkingDirectory = os.path.abspath("../")
        elif os.path.exists("../../pyswing") and os.path.exists("../../test"):
            newWorkingDirectory = os.path.abspath("../../")
        elif os.path.exists("../../../pyswing") and os.path.exists("../../../test"):
            newWorkingDirectory = os.path.abspath("../../../")
        elif os.path.exists("../../../../pyswing") and os.path.exists("../../../../test"):
            newWorkingDirectory = os.path.abspath("../../../../")
        elif os.path.exists("../../../../../pyswing") and os.path.exists("../../../../../test"):
            newWorkingDirectory = os.path.abspath("../../../../../")
        elif os.path.exists("../../../../../../pyswing") and os.path.exists("../../../../../../test"):
            newWorkingDirectory = os.path.abspath("../../../../../../")

        if newWorkingDirectory is not None:
            os.chdir(newWorkingDirectory)
            Logger.log(logging.DEBUG, "Changed Working Directory", {"scope":__name__, "old":workingDirectory,"new":newWorkingDirectory})

        else:
            Logger.log(logging.WARN, "Cannot Change Working Directory", {"scope":__name__, "workingDirectory":workingDirectory})
开发者ID:garyjoy,项目名称:pyswing,代码行数:37,代码来源:FileHelper.py

示例15: generateHistoricTrades

# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import log [as 别名]
    def generateHistoricTrades(self):
        """
        ?
        """

        Logger.log(logging.INFO, "Generating Historic Trades", {"scope":__name__, "Rule 1":self._rule1, "Rule 2":self._rule2, "Rule 3":self._rule3, "Type":self._type})

        connection = sqlite3.connect(pyswing.database.pySwingDatabase)
        c = connection.cursor()
        sql = self.insertIntoHistoricTradesSql % (self._type, self._rule1, self._rule2, self._rule3, self._exit, self._type)
        # print(sql)
        c.executescript(sql)
        connection.commit()
        c.close()
        connection.close()
开发者ID:garyjoy,项目名称:pyswing,代码行数:17,代码来源:strategy.py


注:本文中的pyswing.utils.Logger.Logger.log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。