本文整理汇总了Python中pyswing.utils.Logger.Logger.pushLogData方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.pushLogData方法的具体用法?Python Logger.pushLogData怎么用?Python Logger.pushLogData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyswing.utils.Logger.Logger
的用法示例。
在下文中一共展示了Logger.pushLogData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def setUpClass(self):
Logger.pushLogData("unitTesting", __name__)
forceWorkingDirectory()
pyswing.globals.potentialRuleMatches = None
pyswing.globals.equityCount = None
pyswing.database.overrideDatabase("output/TestMarketRule.db")
pyswing.constants.pySwingStartDate = datetime.datetime(2014, 1, 1)
deleteFile(pyswing.database.pySwingDatabase)
args = "-n %s" % ("unitTesting")
createDatabase(args.split())
pretendDate = datetime.datetime(2015, 9, 1)
with patch.object(Equity, '_getTodaysDate', return_value=pretendDate) as mock_method:
self._equity = Equity("WOR.AX")
self._equity.importData()
indicatorADI = IndicatorADI()
indicatorADI.updateIndicator()
self.rule = MarketRule("Indicator_ADI", "ADI > 0")
self.rule.evaluateRule()
示例2: setUpClass
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def setUpClass(self):
Logger.pushLogData("unitTesting", __name__)
forceWorkingDirectory()
pyswing.globals.potentialRuleMatches = None
pyswing.globals.equityCount = None
pyswing.database.overrideDatabase("output/TestDatabase.db")
pyswing.constants.pySwingStartDate = datetime.datetime(2015, 1, 1)
deleteFile(pyswing.database.pySwingDatabase)
deleteFile(pyswing.database.pySwingTestDatabase)
args = "-n %s" % ("unitTesting")
createDatabase(args.split())
pretendDate = datetime.datetime(2015, 7, 1)
with patch.object(Equity, '_getTodaysDate', return_value=pretendDate) as mock_method:
args = "-n unitTest".split()
importData(args)
args = "-n unitTest".split()
updateIndicators(args)
args = "-n unitTest".split()
evaluateRules(args)
args = "-n unitTest".split()
analyseRules(args)
args = "-n unitTest".split()
calculateExitValues(args)
示例3: createDatabase
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def createDatabase(argv):
"""
Create Database.
:param argv: Command Line Parameters.
-n = Name
Example:
python -m pyswing.CreateDatabase -n asx
"""
Logger.log(logging.INFO, "Log Script Call", {"scope":__name__, "arguments":" ".join(argv)})
Logger.pushLogData("script", __name__)
marketName = ""
try:
shortOptions = "n:dh"
longOptions = ["marketName=", "debug", "help"]
opts, __ = getopt.getopt(argv, shortOptions, longOptions)
except getopt.GetoptError as e:
Logger.log(logging.ERROR, "Error Reading Options", {"scope": __name__, "exception": str(e)})
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-d", "--debug"):
Logger().setLevel(logging.DEBUG)
elif opt in ("-h", "--help"):
print("?")
usage()
sys.exit()
elif opt in ("-n", "--marketName"):
marketName = arg
if marketName != "":
pyswing.database.initialiseDatabase(marketName)
databaseFilePath = pyswing.database.pySwingDatabase
scriptFilePath = pyswing.constants.pySwingDatabaseScript
Logger.log(logging.INFO, "Creating Database", {"scope":__name__, "databaseFilePath":databaseFilePath, "scriptFilePath":scriptFilePath})
query = open(pyswing.constants.pySwingDatabaseScript, 'r').read()
connection = sqlite3.connect(databaseFilePath)
c = connection.cursor()
c.executescript(query)
connection.commit()
c.close()
connection.close()
TeamCity.setBuildResultText("Created Database")
else:
Logger.log(logging.ERROR, "Missing Options", {"scope": __name__, "options": str(argv)})
usage()
sys.exit(2)
示例4: setUpClass
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def setUpClass(self):
Logger.pushLogData("unitTesting", __name__)
forceWorkingDirectory()
pyswing.database.pySwingDatabase = None
pyswing.database.pySwingDatabaseInitialised = False
pyswing.database.pySwingDatabaseOverridden = False
示例5: importData
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def importData(argv):
"""
Import Share Data.
:param argv: Command Line Parameters.
-n = Name
Example:
python -m pyswing.ImportData -n asx
"""
Logger.log(logging.INFO, "Log Script Call", {"scope":__name__, "arguments":" ".join(argv)})
Logger.pushLogData("script", __name__)
marketName = ""
try:
shortOptions = "n:dh"
longOptions = ["marketName=", "debug", "help"]
opts, __ = getopt.getopt(argv, shortOptions, longOptions)
except getopt.GetoptError as e:
Logger.log(logging.ERROR, "Error Reading Options", {"scope": __name__, "exception": str(e)})
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-d", "--debug"):
Logger().setLevel(logging.DEBUG)
elif opt in ("-h", "--help"):
print("?")
usage()
sys.exit()
elif opt in ("-n", "--marketName"):
marketName = arg
if marketName != "":
pyswing.database.initialiseDatabase(marketName)
Logger.log(logging.INFO, "Import Market Data", {"scope":__name__, "market":marketName})
tickerCodesRelativeFilePath = "resources/%s.txt" % (marketName)
market = Market(tickerCodesRelativeFilePath)
for index, row in market.tickers.iterrows():
equity = Equity(row[0])
equity.importData()
TeamCity.setBuildResultText("Imported Data from Yahoo")
else:
Logger.log(logging.ERROR, "Missing Options", {"scope": __name__, "options": str(argv)})
usage()
sys.exit(2)
示例6: generateHistoricTradesForActiveStrategies
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def generateHistoricTradesForActiveStrategies(argv):
"""
Generate (in the HistoricTrades database table) Historic Trades for the Active Strategies.
Empty the database table and then fill it with the historic trades for all the active strategies.
:param argv: Command Line Parameters.
-n = Name
Example:
python -m pyswing.GenerateHistoricTradesForActiveStrategies -n asx
"""
Logger.log(logging.INFO, "Log Script Call", {"scope":__name__, "arguments":" ".join(argv)})
Logger.pushLogData("script", __name__)
marketName = ""
try:
shortOptions = "n:dh"
longOptions = ["marketName=", "debug", "help"]
opts, __ = getopt.getopt(argv, shortOptions, longOptions)
except getopt.GetoptError as e:
Logger.log(logging.ERROR, "Error Reading Options", {"scope": __name__, "exception": str(e)})
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-d", "--debug"):
Logger().setLevel(logging.DEBUG)
elif opt in ("-h", "--help"):
print("?")
usage()
sys.exit()
elif opt in ("-n", "--marketName"):
marketName = arg
if marketName != "":
pyswing.database.initialiseDatabase(marketName)
Logger.log(logging.INFO, "Generate Historic Trades for Active Strategies", {"scope":__name__, "market":marketName})
emptyHistoricTradesTable()
strategies = getActiveStrategies()
for strategy in strategies:
strategy.generateHistoricTrades()
else:
Logger.log(logging.ERROR, "Missing Options", {"scope": __name__, "options": str(argv)})
usage()
sys.exit(2)
示例7: setUpClass
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def setUpClass(self):
Logger.pushLogData("unitTesting", __name__)
forceWorkingDirectory()
pyswing.database.overrideDatabase("output/TestCalculateExitValues.db")
pyswing.constants.pySwingStartDate = datetime.datetime(2015, 1, 1)
deleteFile(pyswing.database.pySwingDatabase)
args = "-n %s" % ("unitTesting")
createDatabase(args.split())
示例8: analyseRules
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def analyseRules(argv):
"""
Analyse Rules.
:param argv: Command Line Parameters.
-n = Name
Example:
python -m pyswing.AnalyseRules -n asx
"""
Logger.log(logging.INFO, "Log Script Call", {"scope":__name__, "arguments":" ".join(argv)})
Logger.pushLogData("script", __name__)
marketName = ""
try:
shortOptions = "n:dh"
longOptions = ["marketName=", "debug", "help"]
opts, __ = getopt.getopt(argv, shortOptions, longOptions)
except getopt.GetoptError as e:
Logger.log(logging.ERROR, "Error Reading Options", {"scope": __name__, "exception": str(e)})
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-d", "--debug"):
Logger().setLevel(logging.DEBUG)
elif opt in ("-h", "--help"):
print("?")
usage()
sys.exit()
elif opt in ("-n", "--marketName"):
marketName = arg
if marketName != "":
pyswing.database.initialiseDatabase(marketName)
Logger.log(logging.INFO, "Analyse Rules", {"scope":__name__, "market":marketName})
rules = getRules()
for ruleString in rules:
rule = Rule(ruleString)
rule.analyseRule()
TeamCity.setBuildResultText("Analysed Rules")
else:
Logger.log(logging.ERROR, "Missing Options", {"scope": __name__, "options": str(argv)})
usage()
sys.exit(2)
示例9: setUpClass
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def setUpClass(self):
Logger.pushLogData("unitTesting", __name__)
forceWorkingDirectory()
pyswing.globals.potentialRuleMatches = None
pyswing.globals.equityCount = None
pyswing.database.overrideDatabase("output/TestAskHorse.db")
pyswing.constants.pySwingStartDate = datetime.datetime(2015, 1, 1)
deleteFile(pyswing.database.pySwingDatabase)
copyFile(pyswing.database.pySwingTestDatabase, pyswing.database.pySwingDatabase)
示例10: test_pushLogData
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def test_pushLogData(self):
myLogEntry = Logger._buildLogMessage(logging.INFO, "Test Log Entry", {"key1":"value1","key2":"value2"})
self.assertTrue('key1="value1" key2="value2"' in myLogEntry, 'Expected key1="value1" key2="value2" in %s' % myLogEntry)
Logger.pushLogData("key3","value3")
myLogEntry = Logger._buildLogMessage(logging.INFO, "Test Log Entry", {"key1":"value1","key2":"value2"})
self.assertTrue('key1="value1" key2="value2"' in myLogEntry, 'Expected key1="value1" key2="value2" in %s' % myLogEntry)
self.assertTrue('key3="value3"' in myLogEntry, 'Expected key3="value3" in %s' % myLogEntry)
Logger.popLogData("key3")
myLogEntry = Logger._buildLogMessage(logging.INFO, "Test Log Entry", {"key1":"value1","key2":"value2"})
self.assertTrue('key1="value1" key2="value2"' in myLogEntry, 'Expected key1="value1" key2="value2" in %s' % myLogEntry)
self.assertFalse('key3="value3"' in myLogEntry, 'Did Not Expect key3="value3" in %s' % myLogEntry)
示例11: setUpClass
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def setUpClass(self):
Logger.pushLogData("unitTesting", __name__)
forceWorkingDirectory()
pyswing.globals.potentialRuleMatches = None
pyswing.globals.equityCount = None
pyswing.database.overrideDatabase("output/TestAnalyseRules.db")
pyswing.constants.pySwingStartDate = datetime.datetime(2015, 1, 1)
deleteFile(pyswing.database.pySwingDatabase)
args = "-n %s" % ("unitTesting")
createDatabase(args.split())
示例12: setUpClass
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def setUpClass(self):
Logger.pushLogData("unitTesting", __name__)
forceWorkingDirectory()
pyswing.database.overrideDatabase("output/TestRule.db")
args = "-n %s" % ("unitTesting")
createDatabase(args.split())
myRule = Rule("Rule - myRule")
myRule._createTable()
myOtherRule = Rule("Rule - myOtherRule")
myOtherRule._createTable()
示例13: setUpClass
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def setUpClass(self):
Logger.pushLogData("unitTesting", __name__)
forceWorkingDirectory()
pyswing.database.overrideDatabase("output/TestIndicatorDX.db")
pyswing.constants.pySwingStartDate = datetime.datetime(2014, 1, 1)
deleteFile(pyswing.database.pySwingDatabase)
args = "-n %s" % ("unitTesting")
createDatabase(args.split())
pretendDate = datetime.datetime(2015, 9, 1)
with patch.object(Equity, '_getTodaysDate', return_value=pretendDate) as mock_method:
self._equityCBA = Equity("CBA.AX")
self._equityCBA.importData()
示例14: setUpClass
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def setUpClass(self):
Logger.pushLogData("unitTesting", __name__)
forceWorkingDirectory()
pyswing.globals.potentialRuleMatches = None
pyswing.globals.equityCount = None
pyswing.database.overrideDatabase("output/TestStrategy.db")
pyswing.constants.pySwingStartDate = datetime.datetime(2015, 1, 1)
deleteFile(pyswing.database.pySwingDatabase)
copyFile(pyswing.database.pySwingTestDatabase, pyswing.database.pySwingDatabase)
twoRuleStrategy = Strategy("Rule Equities Indicator_BB20 abs(t1.Close - t2.upperband) < abs(t1.Close - t2.middleband)", "Rule Equities abs(Close - High) * 2 < abs(Close - Low)", "Exit TrailingStop3.0 RiskRatio2", "Buy")
twoRuleStrategy.evaluateTwoRuleStrategy()
threeRuleStrategy = Strategy("Rule Equities Indicator_BB20 abs(t1.Close - t2.upperband) < abs(t1.Close - t2.middleband)", "Rule Equities abs(Close - High) * 2 < abs(Close - Low)", "Exit TrailingStop3.0 RiskRatio2", "Buy", "Rule Indicator_RSI RSI > 20")
threeRuleStrategy.evaluateThreeRuleStrategy()
historicTrades = Strategy("Rule Equities Indicator_BB20 abs(t1.Close - t2.upperband) < abs(t1.Close - t2.middleband)", "Rule Equities abs(Close - High) * 2 < abs(Close - Low)", "Exit TrailingStop3.0 RiskRatio2", "Buy", "Rule Indicator_RSI RSI > 20")
historicTrades.generateHistoricTrades()
示例15: calculateExitValues
# 需要导入模块: from pyswing.utils.Logger import Logger [as 别名]
# 或者: from pyswing.utils.Logger.Logger import pushLogData [as 别名]
def calculateExitValues(argv):
"""
Calculate Exit Values.
:param argv: Command Line Parameters.
-n = Name
Example:
python -m pyswing.CalculateExitValues -n asx
"""
Logger.log(logging.INFO, "Log Script Call", {"scope":__name__, "arguments":" ".join(argv)})
Logger.pushLogData("script", __name__)
marketName = ""
try:
shortOptions = "n:dh"
longOptions = ["marketName=", "debug", "help"]
opts, __ = getopt.getopt(argv, shortOptions, longOptions)
except getopt.GetoptError as e:
Logger.log(logging.ERROR, "Error Reading Options", {"scope": __name__, "exception": str(e)})
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-d", "--debug"):
Logger().setLevel(logging.DEBUG)
elif opt in ("-h", "--help"):
print("?")
usage()
sys.exit()
elif opt in ("-n", "--marketName"):
marketName = arg
if marketName != "":
pyswing.database.initialiseDatabase(marketName)
Logger.log(logging.INFO, "Calculate Exit Values", {"scope":__name__, "market":marketName})
tickerCodesRelativeFilePath = "resources/%s.txt" % (marketName)
market = Market(tickerCodesRelativeFilePath)
for index, row in market.tickers.iterrows():
tickerCode = row[0]
exitValuesTrailingStop3 = ExitValuesTrailingStop(tickerCode, 0.03, 2)
exitValuesTrailingStop3.calculateExitValues()
# exitValuesTrailingStop2 = ExitValuesTrailingStop(tickerCode, 0.02, 3)
# exitValuesTrailingStop2.calculateExitValues()
#
# exitValuesYesterday2 = ExitValuesYesterday(tickerCode, 0.02, 3)
# exitValuesYesterday2.calculateExitValues()
#
# exitValuesYesterday3 = ExitValuesYesterday(tickerCode, 0.03, 2)
# exitValuesYesterday3.calculateExitValues()
TeamCity.setBuildResultText("Calculated Exit Values")
else:
Logger.log(logging.ERROR, "Missing Options", {"scope": __name__, "options": str(argv)})
usage()
sys.exit(2)