Esempio n. 1
0
    def __init__(self, crosserTable, crosserColumn, crosseeTable,
                 crosseeColumn):
        """
        Class Constructor.

        :param crosserTable:
        :param crosserColumn:
        :param crosseeTable:
        :param crosseeColumn:
        """

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

        ruleTableName = "Rule %s %s Cross %s %s" % (
            crosserTable, crosserColumn, crosseeTable, crosseeColumn)
        Rule.__init__(self, ruleTableName)

        if crosserTable == crosseeTable:
            self._selectQuery = "select r.Date, r.Code, %s as Crosser, %s as Crossee from %s r" % (
                crosserColumn, crosseeColumn, crosserTable)
        else:
            self._selectQuery = "select r.Date, r.Code, r.%s as Crosser, e.%s as Crossee from %s r inner join %s e on r.Date = e.Date and r.Code = e.Code" % (
                crosserColumn, crosseeColumn, crosserTable, crosseeTable)

        self._crosserColumn = crosserColumn
        self._crosseeColumn = crosseeColumn
Esempio n. 2
0
    def __init__(self,
                 indicatorTable,
                 indicatorColumn,
                 relativeIndex,
                 comparison,
                 multiplier=1.00):
        """
        Class Constructor.

        :param indicatorTable:
        :param indicatorColumn:
        :param relativeIndex: Relative Index to compare the Indicator Column e.g. -1 means previous day and -5 means five days ago
        :param comparison:
        :param multiplier:
        """

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

        ruleTableName = "Rule %s %s %s %s %s" % (
            indicatorTable, indicatorColumn, relativeIndex, comparison,
            multiplier)
        Rule.__init__(self, ruleTableName)

        self._selectQuery = "select Date, Code, %s from %s" % (indicatorColumn,
                                                               indicatorTable)

        self._indicatorColumn = indicatorColumn
        self._relativeIndex = relativeIndex
        self._comparison = comparison
        self._multiplier = multiplier
Esempio n. 3
0
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)
Esempio n. 4
0
    def __init__(self, indicatorTable, indicatorRule):
        """
        Class Constructor.

        :param ?
        """

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

        ruleTableName = "Rule %s %s" % (indicatorTable, indicatorRule)
        Rule.__init__(self, ruleTableName)

        self._selectQuery = "select Date, Code, %s as Match from %s" % (indicatorRule, indicatorTable)
Esempio n. 5
0
    def __init__(self, indicatorTable1, indicatorTable2, indicatorRule):
        """
        Class Constructor.

        :param ?
        :param ?
        :param indicatorRule: Columns should be prefixed with t1 and t2
        """

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

        ruleTableName = "Rule %s %s %s" % (indicatorTable1, indicatorTable2, indicatorRule)
        Rule.__init__(self, ruleTableName)

        self._selectQuery = "select t1.Date, t1.Code, %s as Match from %s t1 inner join %s t2 on t1.Date = t2.Date and t1.Code = t2.Code" % (indicatorRule, indicatorTable1, indicatorTable2)
Esempio n. 6
0
    def __init__(self, crosserTable, crosserColumn, crosseeTable, crosseeColumn):
        """
        Class Constructor.

        :param crosserTable:
        :param crosserColumn:
        :param crosseeTable:
        :param crosseeColumn:
        """

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

        ruleTableName = "Rule %s %s Cross %s %s" % (crosserTable, crosserColumn, crosseeTable, crosseeColumn)
        Rule.__init__(self, ruleTableName)

        if crosserTable == crosseeTable:
            self._selectQuery = "select r.Date, r.Code, %s as Crosser, %s as Crossee from %s r" % (crosserColumn, crosseeColumn, crosserTable)
        else:
            self._selectQuery = "select r.Date, r.Code, r.%s as Crosser, e.%s as Crossee from %s r inner join %s e on r.Date = e.Date and r.Code = e.Code" % (crosserColumn, crosseeColumn, crosserTable, crosseeTable)

        self._crosserColumn = crosserColumn
        self._crosseeColumn = crosseeColumn
Esempio n. 7
0
    def __init__(self, indicatorTable, indicatorColumn, relativeIndex, comparison, multiplier=1.00):
        """
        Class Constructor.

        :param indicatorTable:
        :param indicatorColumn:
        :param relativeIndex: Relative Index to compare the Indicator Column e.g. -1 means previous day and -5 means five days ago
        :param comparison:
        :param multiplier:
        """

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

        ruleTableName = "Rule %s %s %s %s %s" % (indicatorTable, indicatorColumn, relativeIndex, comparison, multiplier)
        Rule.__init__(self, ruleTableName)

        self._selectQuery = "select Date, Code, %s from %s" % (indicatorColumn, indicatorTable)

        self._indicatorColumn = indicatorColumn
        self._relativeIndex = relativeIndex
        self._comparison = comparison
        self._multiplier = multiplier
Esempio n. 8
0
    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()
Esempio n. 9
0
    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()