當前位置: 首頁>>代碼示例>>Python>>正文


Python Book.ask方法代碼示例

本文整理匯總了Python中book.Book.ask方法的典型用法代碼示例。如果您正苦於以下問題:Python Book.ask方法的具體用法?Python Book.ask怎麽用?Python Book.ask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在book.Book的用法示例。


在下文中一共展示了Book.ask方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: len

# 需要導入模塊: from book import Book [as 別名]
# 或者: from book.Book import ask [as 別名]
#!/usr/bin/python

import sys

from book import Book

if __name__ == '__main__':
    if len(sys.argv) != 2:
        print "usage: %s input.csv" % sys.argv[0]
        sys.exit(0)
    try:
        reader = open(sys.argv[1], 'r')
        quotebook = Book()
        for line in reader:
            if line[0] == 'B':
                quotebook.bid(line.rstrip())
            elif line[0] == 'A':
                quotebook.ask(line.rstrip())
            else:
                quotebook.trade(line.rstrip())

            # Manual Debugging
            print "\n"
            print "Input: " + line
            print quotebook
            raw_input("Press enter to continue.")
        reader.close()
    except IOError:
        print 'Cannot open input file "%s"' % sys.argv[1]
        sys.exit(1)
開發者ID:hedgefair,項目名稱:PyLimitBook,代碼行數:32,代碼來源:parse.py

示例2: len

# 需要導入模塊: from book import Book [as 別名]
# 或者: from book.Book import ask [as 別名]
        ask = b.ask()
        if   bid is None and ask is None: mark = oldMark if oldMark is not None else 50
        elif bid is None                : mark = ask
        elif ask is None                : mark = bid
        else                            : mark = (bid+ask)/2.0

        if mark != oldMark:
            pnlEvents.append(("M", game.gameId, time.time(), "", "", "", "", mark))
            oldMark = mark

        ## responses for gateways
        for e in gatewayEvents:
            gateways.sendToOwner(e)

        ## feed handler
        if len(events):
            msg = ";".join(str(e) for e in events)
            f.send(msg)
            if debugFeedBook:
                log.info("FB MESSAGE:" + msg)
                fb.processMessage(msg)

        ## now check that the local book and reconstructed book look the same
        if debugFeedBook:
            x = str(b ).split("\n")
            y = str(fb).split("\n")
            assert len(x) == len(y)
            z = "\n".join(xx + "  " + (" " if xx == yy else "X") + "   " + yy for xx,yy in zip(x,y))
            log.info("Book:\n"+z)
            assert x == y or (fb.bid() is None and fb.ask() is None)
開發者ID:mschubmehl,項目名稱:chesschallenge,代碼行數:32,代碼來源:me.py


注:本文中的book.Book.ask方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。