当前位置: 首页>>代码示例>>Python>>正文


Python dt.datetime_is_naive函数代码示例

本文整理汇总了Python中pyalgotrade.utils.dt.datetime_is_naive函数的典型用法代码示例。如果您正苦于以下问题:Python datetime_is_naive函数的具体用法?Python datetime_is_naive怎么用?Python datetime_is_naive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了datetime_is_naive函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, dateTime, frequency):
        assert isinstance(frequency, int)
        assert frequency > 1
        assert frequency < bar.Frequency.DAY

        ts = int(dt.datetime_to_timestamp(dateTime))
        slot = int(ts / frequency)
        slotTs = slot * frequency
        self.__begin = dt.timestamp_to_datetime(slotTs, not dt.datetime_is_naive(dateTime))
        if not dt.datetime_is_naive(dateTime):
            self.__begin = dt.localize(self.__begin, dateTime.tzinfo)
        self.__end = self.__begin + datetime.timedelta(seconds=frequency)
开发者ID:363158858,项目名称:pyalgotrade-cn,代码行数:12,代码来源:resamplebase.py

示例2: testWithoutTimezone

 def testWithoutTimezone(self):
     barFeed = yahoofeed.Feed()
     barFeed.addBarsFromCSV(YahooTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv"))
     barFeed.addBarsFromCSV(YahooTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv"))
     for dateTime, bars in barFeed:
         bar = bars.getBar(YahooTestCase.TestInstrument)
         self.assertTrue(dt.datetime_is_naive(bar.getDateTime()))
开发者ID:akkineniramesh,项目名称:pyalgotrade,代码行数:7,代码来源:csvbarfeed_test.py

示例3: XigniteGlobalRealTime_GetBar

def XigniteGlobalRealTime_GetBar(token, identifier, identifierType, endDateTime, precision, period, secureRequest=None):
    if dt.datetime_is_naive(endDateTime):
        raise Exception("endDateTime must have a timezone")

    # Parse the exchange from the identifier.
    instrument, exchange = parse_instrument_exchange(identifier)

    if secureRequest is None:
        secureRequest = USE_SECURE_REQUESTS

    if secureRequest:
        scheme = "https"
    else:
        scheme = "http"

    # print datetime_to_string(endDateTime, exchange)
    params = {
        "_Token": token,
        "Identifier": identifier,
        "IdentifierType": identifierType,
        "EndTime": datetime_to_string(endDateTime, exchange),
        "Precision": precision,
        "Period": period,
    }
    parts = (scheme, "globalrealtime.xignite.com", "v3/xGlobalRealTime.json/GetBar", urllib.urlencode(params), "")
    url = urlparse.urlunsplit(parts)

    ret = json_http_request(url)
    if ret.get("Outcome") != "Success":
        msg = ret.get("Message")
        if msg is None:
            msg = "Error %s" % (ret.get("Outcome"))
        raise XigniteError(msg, ret)

    return ret
开发者ID:Greenwicher,项目名称:pyalgotrade,代码行数:35,代码来源:api.py

示例4: testFeedWithQuandl

    def testFeedWithQuandl(self):
        class RowFilter(csvfeed.RowFilter):
            def includeRow(self, dateTime, values):
                return dateTime.year == 2013

        feed = csvfeed.Feed("Date", "%Y-%m-%d", maxLen=40, timezone=marketsession.USEquities.timezone)
        feed.setRowFilter(RowFilter())
        feed.setTimeDelta(datetime.timedelta(hours=23, minutes=59, seconds=59))
        feed.addValuesFromCSV(common.get_data_file_path("quandl_gold_2.csv"))

        for col in ["USD", "GBP", "EUR"]:
            self.assertEqual(len(feed[col]), 0)

        dispatcher = observer.Dispatcher()
        dispatcher.addSubject(feed)
        dispatcher.run()

        for col in ["USD", "GBP", "EUR"]:
            self.assertEqual(len(feed[col]), 39)

        self.assertEqual(feed["USD"][-1], 1333.0)
        self.assertEqual(feed["GBP"][-1], 831.203)
        self.assertEqual(feed["EUR"][-1], 986.75)
        self.assertFalse(dt.datetime_is_naive(feed["USD"].getDateTimes()[-1]))
        self.assertEqual(feed["USD"].getDateTimes()[-1], dt.localize(datetime.datetime(2013, 9, 29, 23, 59, 59), marketsession.USEquities.timezone))
开发者ID:akkineniramesh,项目名称:pyalgotrade,代码行数:25,代码来源:csvfeed_test.py

示例5: testWithPerFileTimezone

 def testWithPerFileTimezone(self):
     barFeed = yahoofeed.Feed()
     barFeed.addBarsFromCSV(FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv"), marketsession.USEquities.getTimezone())
     barFeed.addBarsFromCSV(FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv"), marketsession.USEquities.getTimezone())
     for dateTime, bars in barFeed:
         bar = bars.getBar(FeedTestCase.TestInstrument)
         self.assertFalse(dt.datetime_is_naive(bar.getDateTime()))
开发者ID:Greenwicher,项目名称:pyalgotrade,代码行数:7,代码来源:yahoofeed_test.py

示例6: testWithoutTimezone

    def testWithoutTimezone(self):
        barFeed = self.__loadIntradayBarFeed(None)
        ds = barFeed.getDataSeries()

        for i, currentBar in enumerate(ds):
            # Datetime must be set to UTC.
            self.assertFalse(dt.datetime_is_naive(currentBar.getDateTime()))
            self.assertEqual(ds[i].getDateTime(), ds.getDateTimes()[i])
开发者ID:Greenwicher,项目名称:pyalgotrade,代码行数:8,代码来源:ninjatraderfeed_test.py

示例7: testWithTimezone

	def testWithTimezone(self):
		timeZone = marketsession.USEquities.getTimezone()
		barFeed = self.__loadIntradayBarFeed(timeZone)
		ds = barFeed.getDataSeries()

		for i in xrange(ds.getLength()):
			currentBar = ds.getValueAbsolute(i)
			self.assertFalse(dt.datetime_is_naive(currentBar.getDateTime()))
开发者ID:jimmyho,项目名称:pyalgotrade,代码行数:8,代码来源:csvbarfeed_test.py

示例8: get_slot_datetime

def get_slot_datetime(dateTime, frequency):
	ts = dt.datetime_to_timestamp(dateTime)
	slot = ts / frequency
	slotTs = (slot + 1) * frequency - 1
	ret = dt.timestamp_to_datetime(slotTs, False)
	if not dt.datetime_is_naive(dateTime):
		ret = dt.localize(ret, dateTime.tzinfo)
	return ret
开发者ID:imoran21,项目名称:Pyalgo-Django,代码行数:8,代码来源:resampled.py

示例9: testWithTimezone

    def testWithTimezone(self):
        timeZone = marketsession.USEquities.getTimezone()
        barFeed = self.__loadIntradayBarFeed(timeZone)
        ds = barFeed.getDataSeries()

        for i, currentBar in enumerate(ds):
            self.assertFalse(dt.datetime_is_naive(currentBar.getDateTime()))
            self.assertEqual(ds[i].getDateTime(), ds.getDateTimes()[i])
开发者ID:Greenwicher,项目名称:pyalgotrade,代码行数:8,代码来源:ninjatraderfeed_test.py

示例10: testWithoutTimezone

	def testWithoutTimezone(self):
		barFeed = self.__loadIntradayBarFeed(None)
		ds = barFeed.getDataSeries()

		for i in xrange(ds.getLength()):
			currentBar = ds.getValueAbsolute(i)
			# Datetime must be set to UTC.
			self.assertFalse(dt.datetime_is_naive(currentBar.getDateTime()))
开发者ID:jimmyho,项目名称:pyalgotrade,代码行数:8,代码来源:csvbarfeed_test.py

示例11: testWithTimezone

    def testWithTimezone(self):
        timeZone = marketsession.USEquities.getTimezone()
        barFeed = self.__loadIntradayBarFeed(timeZone)
        ds = barFeed.getDataSeries()

        for i in xrange(ds.getLength()):
            currentBar = ds[i]
            assert not dt.datetime_is_naive(currentBar.getDateTime())
            assert ds[i].getDateTime() == ds.getDateTimes()[i]
开发者ID:tibkiss,项目名称:pyalgotrade,代码行数:9,代码来源:csvbarfeed_test.py

示例12: testWithoutTimezone

    def testWithoutTimezone(self):
        barFeed = self.__loadIntradayBarFeed(None)
        ds = barFeed.getDataSeries()

        for i in xrange(ds.getLength()):
            currentBar = ds[i]
            # Datetime must be set to UTC.
            currentBarDT = currentBar.getDateTime()
            assert not dt.datetime_is_naive(currentBarDT)
            assert ds[i].getDateTime() == ds.getDateTimes()[i]
开发者ID:tibkiss,项目名称:pyalgotrade,代码行数:10,代码来源:csvbarfeed_test.py

示例13: testWithDefaultTimezone

	def testWithDefaultTimezone(self):
		barFeed = yahoofeed.Feed(marketsession.USEquities.getTimezone())
		barFeed.addBarsFromCSV(YahooTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv"))
		barFeed.addBarsFromCSV(YahooTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv"))
		barFeed.start()
		for bars in barFeed:
			bar = bars.getBar(YahooTestCase.TestInstrument)
			self.assertFalse(dt.datetime_is_naive(bar.getDateTime()))
		barFeed.stop()
		barFeed.join()
开发者ID:charnugagoo,项目名称:pyalgotrade,代码行数:10,代码来源:csvbarfeed_test.py

示例14: to_utc_if_naive

def to_utc_if_naive(dateTime):
    if dateTime is not None and dt.datetime_is_naive(dateTime):
        dateTime = dt.as_utc(dateTime)
    return dateTime
开发者ID:Chin-I,项目名称:pyalgotrade,代码行数:4,代码来源:barfeed.py


注:本文中的pyalgotrade.utils.dt.datetime_is_naive函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。