예제 #1
0
def removeExpiredContracts(stockObject):
    today = datetimeConverter()
    i = 0
    while i < len(stockObject.options):
        if stockObject.options[i].expiry < today:
            del stockObject.options[i]
        elif stockObject.options[i].expiry is None:
            del stockObject.options[i]
        else:
            i += 1
예제 #2
0
    i = 0
    while i < len(stockObject.options):
        if stockObject.options[i].expiry < today:
            del stockObject.options[i]
        elif stockObject.options[i].expiry is None:
            del stockObject.options[i]
        else:
            i += 1


def buildPortfolio(symbols):  # symbols is a list of stock symbols
    #    , 'COF', 'AXP', 'TSLA', 'AMZN', 'GSK', 'NFLX']
    thisPortfolio = portfolio()
    while symbols:
        newStock(thisPortfolio, symbols.pop())
    l = len(thisPortfolio.stocks)
    pickler(thisPortfolio, "portfolio")
    #    return thisPortfolio
    print("Portfolio built with %d stocks loaded.") % l
    return thisPortfolio


def resetContractDetails(portfolioObject):
    for i in portfolioObject.stocks:
        i.options = []


if __name__ == "__main__":
    #    buildPortfolio()
    print(datetimeConverter())