for timestamp in QUOTE_TIMESTAMP_COLS:
            if timestamp in quote and quote[timestamp]:
                quote[timestamp] = quote[timestamp].isoformat()
        for datefield in QUOTE_DATE_COLS:
            if datefield in quote and quote[datefield]:
                quote[datefield] = quote[datefield].isoformat()
    print(pp.pprint(quotes))
except NotImplementedError as err:
    print("getQuote failed: {}".format(err))

# getHistory with ONE symbol
# ==========================
print("\nHistory of {0} since {1}".format(one_symbol, startDate))
print("===============================")
try:
    history = getHistory(one_symbol, typ="daily", startDate=startDate, maxRecords=5, session=session)
    for key, val in history.items():
        print("Symbol: {0}".format(key))
        for v in val:
            print("==========================")
            v["timestamp"] = v["timestamp"].isoformat()
            v["tradingDay"] = v["tradingDay"].isoformat()
            print(pp.pprint(v))
except NotImplementedError as err:
    print("getHistory failed: {}".format(err))

# getHistory with SEVERAL symbols
# ===============================
print("\nHistories of {0} since {1}".format(many_symbols, startDate))
try:
    histories = getHistory(many_symbols, typ="daily", startDate=startDate, maxRecords=5, order="desc", session=session)
Beispiel #2
0
quotes = getQuote(symbols, session=session)
print(quotes) # quotes is a Pandas DataFrame
#print(quotes.dtypes)
#print(type(quotes['serverTimestamp'][0])) # should be a pandas.tslib.Timestamp

CONFIG.output_pandas = False
quotes = getQuote(symbols, session=session)
print(quotes) # quotes is a Pandas DataFrame
CONFIG.output_pandas = True


# getHistory with ONE symbol
# ==========================
symbol = 'IBM'
startDate = datetime.date(year=2014, month=9, day=28)
history = getHistory(symbol, typ='daily', startDate=startDate, session=session)
print(history)
print(history.dtypes)
#print(type(history['timestamp'][0])) # should be a pandas.tslib.Timestamp
#print(type(history.index[0])) # should be a pandas.tslib.Timestamp
#print(type(history['tradingDay'][0])) # should be a pandas.tslib.Timestamp


# getHistory with SEVERAL symbols
# ===============================
symbols = ["ZC*1", "IBM", "GOOGL" , "^EURUSD"]
histories = getHistory(symbols, typ='daily', startDate=startDate, session=session)
print(histories)
print(histories.dtypes)
#print(type(histories.index[0])) # should be a pandas.tslib.Timestamp
#print(type(histories['timestamp'][0])) # should be a pandas.tslib.Timestamp