Exemplo n.º 1
0
    def test_AnalyseStrategies(self):

        args = "-n unitTest -m 1.0 -s test_EvaluateTwoRuleStrategies".split()
        evaluateTwoRuleStrategies(args)

        rowCount = self._countRows("TwoRuleStrategy")

        self.assertEqual(rowCount, 1974)

        args = "-n unitTest -N 1 -s v4.0 -t 5".split()
        evaluateThreeRuleStrategies(args)

        rowCount = self._countRows("ThreeRuleStrategy")

        self.assertEqual(rowCount, 71)

        args = "-n unitTest -r 4.0 -s v4.0 -t 3".split()
        analyseStrategies(args)

        rowCount = self._countRows("Strategy")

        self.assertEqual(rowCount, 1)
Exemplo n.º 2
0
connection = sqlite3.connect("output/TestMultipleIndicatorRule.db")
query = "select e.Date, Close, SMA_200 from Equities e inner join Indicator_SMA i on e.Date = i.Date and e.Code = i.Code"
cbaEquityData = read_sql_query(query, connection, 'Date')
connection.close()
cbaEquityData.query("Date > '2015-06-01 00:00:00'").plot(y=['Close','SMA_200'], title='Testing')



from pyswing.AskHorse import askHorse
args = "-n asx".split()
askHorse(args)


from pyswing.AnalyseStrategies import analyseStrategies
args = "-n ftse -s v1.2 -r 0.4 -t 500".split
analyseStrategies(args)


# Run me to populate (emptying to begin with) the historic trades table using the strategies in active strategies (which must be put in there manually)...
from pyswing.GenerateHistoricTradesForActiveStrategies import generateHistoricTradesForActiveStrategies
args = "-n ftse".split()
generateHistoricTradesForActiveStrategies(args)


# Run me to chart the (distinct) results in active strategy
import pyswing.database
import sqlite3
from pandas.io.sql import read_sql_query
from pandas import expanding_sum
connection = sqlite3.connect(pyswing.database.pySwingDatabase)
query = ("select t.matchDate as Date, t.code as Code, t.type as Type, t.ExitValue as ExitValue from ( select distinct matchDate, Code, type, exitValue from historicTrades order by matchDate asc) t")
Exemplo n.º 3
0
import sqlite3
from pandas.io.sql import read_sql_query
connection = sqlite3.connect("output/TestMultipleIndicatorRule.db")
query = "select e.Date, Close, SMA_200 from Equities e inner join Indicator_SMA i on e.Date = i.Date and e.Code = i.Code"
cbaEquityData = read_sql_query(query, connection, 'Date')
connection.close()
cbaEquityData.query("Date > '2015-06-01 00:00:00'").plot(
    y=['Close', 'SMA_200'], title='Testing')

from pyswing.AskHorse import askHorse
args = "-n asx".split()
askHorse(args)

from pyswing.AnalyseStrategies import analyseStrategies
args = "-n ftse -s v1.2 -r 0.4 -t 500".split
analyseStrategies(args)

# Run me to populate (emptying to begin with) the historic trades table using the strategies in active strategies (which must be put in there manually)...
from pyswing.GenerateHistoricTradesForActiveStrategies import generateHistoricTradesForActiveStrategies
args = "-n ftse".split()
generateHistoricTradesForActiveStrategies(args)

# Run me to chart the (distinct) results in active strategy
import pyswing.database
import sqlite3
from pandas.io.sql import read_sql_query
from pandas import expanding_sum
connection = sqlite3.connect(pyswing.database.pySwingDatabase)
query = (
    "select t.matchDate as Date, t.code as Code, t.type as Type, t.ExitValue as ExitValue from ( select distinct matchDate, Code, type, exitValue from historicTrades order by matchDate asc) t"
)