Example #1
0
            def get_price(self, order_book_id, start, end, freq):
                """
                :param order_book_id: e.g. 000002.XSHE
                :param start: 20160101
                :param end: 20160201
                :returns:
                :rtype: numpy.rec.array
                """
                start = get_date_from_int(start)
                end = get_date_from_int(end)

                scale = 1
                if freq[-1] == "m":
                    scale *= 240. / int(freq[:-1])
                bar_count = int((end - start).days * scale)

                dt = datetime.datetime.combine(end, datetime.time(23, 59, 59))
                bars = self.rqalpha_env.data_proxy.history_bars(order_book_id,
                                                                bar_count,
                                                                freq,
                                                                field=None,
                                                                dt=dt)

                if bars is None or len(bars) == 0:
                    raise KeyError("empty bars {}".format(order_book_id))
                bars = bars.copy()

                return bars
Example #2
0
            def get_price(self, order_book_id, start, end, freq):
                """
                :param order_book_id: e.g. 000002.XSHE
                :param start: 20160101
                :param end: 20160201
                :returns:
                :rtype: numpy.rec.array
                """
                start = get_date_from_int(start)
                end = get_date_from_int(end)

                scale = 1
                if freq[-1] == "m":
                    scale *= 240. / int(freq[:-1])
                bar_count = int((end - start).days * scale)

                dt = datetime.datetime.combine(end, datetime.time(23, 59, 59))
                bars = self.rqalpha_env.data_proxy.history_bars(
                    order_book_id, bar_count, freq, field=None,
                    dt=dt)

                if bars is None or len(bars) == 0:
                    raise KeyError("empty bars {}".format(order_book_id))
                bars = bars.copy()

                return bars
Example #3
0
            def get_trading_dates(self, start, end):
                """获取所有的交易日

                :param start: 20160101
                :param end: 20160201
                """
                start = get_date_from_int(start)
                end = get_date_from_int(end)
                trading_dates = self.rqalpha_env.data_proxy.get_trading_dates(
                    start, end).tolist()
                trading_dates = [
                    get_int_date(dt.date()) for dt in trading_dates
                ]
                return trading_dates