示例#1
0
    def defaultSimulator(self):

        # According to HWK 4 Example 1
        balance = 1000000
        startDate = dt.date(2011, 1, 10)
        endDate = dt.date(2011, 12, 20)

        orderFilename = "scratches/orders.csv"
        historyFilename = "scratches/history.csv"

        orders = OrderDf()
        orders.fetchFromCsv(orderFilename)

        symbols = orders.extractSymbols()

        series = TimeSeries(startDate, endDate)
        window = MarketWindow(series, symbols)

        account = Account(balance, window)
        history = PricePanel(window, self.provider)

        sim = Simulator()
        sim.config(account, window, orders, history)
        sim.setBidBarPrice(ADJ_CLOSE)
        return sim
示例#2
0
    def testOrders(self):

        orderFilename = "scratches/orders.csv"

        orders = OrderDf()
        orders.fetchFromCsv(orderFilename)

        symbols = orders.extractSymbols()
        self.assertEqual(len(symbols), 4)
        self.assertEqual(len(orders), 14)