import time import pyscreenshot from pyrate.builder import Builder from pyrate.ttapi.predicates import CallbackType from pyrate.ttapi.manager import Manager from pyrate.ttapi.order import TTAPIOrder from ttapi import aenums, cppclient from pyrate.exceptions import TimeoutError from captain.controlled import controlled_name_type, ControlledName from captain.lib.controlled_types import Tif priceSession = Manager().getPriceSession() orderSession = Manager().getOrderFillSession() allCustDefaults = Manager().getCustomers() ordSrv = Manager().getOrderServer() priceSrv = Manager().getPriceServer() products = priceSession.getProducts(prodName='HSI', prodType=aenums.TT_PROD_FUTURE) product = products[0] contracts = priceSession.getContracts(product) contract = contracts[3] custDefaults = allCustDefaults[0] run_now = True prev_trading_status = None curr_trading_status = None pricey = None while run_now is True: try: if not priceSession.feed_down: for enum, price in priceSession.getPrices(contract).items(): if "SETTL" in str(enum): pricey = price.value
from pyrate.ttapi.manager import Manager from pyrate.ttapi.order import TTAPIOrder from ttapi import aenums, cppclient priceSession = Manager().getPriceSession() priceSrv = Manager().getPriceServer() products = priceSession.getProducts() missing_agile = [] for product in products: contracts = priceSession.getContracts(product) for contract in contracts: if 1080 not in contract.RetrieveAttachmentIDs(): missing_agile.append(" ".join([product.prod_chr, str(product.prod_type).replace("TT_PROD_", ""), contract.seriesKey, "\n"])) if len(missing_agile) > 0: logfile = open(r"c:\tt\agile_text.log", "w") print "\n\n\nThe following contracts are missing the agile attachment:\n\n" for instrument in missing_agile: logfile.write(instrument) logfile.close()
from pyrate.ttapi.manager import Manager from pyrate.ttapi.order import TTAPIOrder from ttapi import aenums, cppclient priceSession = Manager().getPriceSession() orderSession0 = Manager().getOrderFillSessions()[0] orderSession1 = Manager().getOrderFillSessions()[-1] custDefaults0 = Manager().getCustomers()[0] custDefaults1 = Manager().getCustomers()[0] ordSrv = Manager().getOrderServer() priceSrv = Manager().getPriceServer() create_depth = True prod_list = ["ZARB", "ZADS", "ZAL", "ZAXS", "ZBHA", "ZBHE", "ZBHF", "ZBOB", "ZBPC", "ZCBK", "ZCEN", "ZCIP", "ZCOA", "ZDEW", "ZDLF", "ZHCL", "ZHDB", "ZHDF", "ZHND", "ZHPC", "ZHUV", "ZICI", "ZIDE", "ZIHF", "ZIIB", "ZINF", "ZITC", "ZJST", "ZJUS", "ZKMB", "ZLIC", "ZLPC", "ZLT", "ZMM", "ZMSI", "ZONG", "ZPNB", "ZRCA", "ZRCO", "ZREC", "ZREL", "ZRIL", "ZSBI", "ZSUN", "ZTAT", "ZTCS", "ZTTD", "ZTTM", "ZUNB", "ZYES"] prod_type_list = ["FUTURE", ]#"FSPREAD"] # , "OPTIONS", "OSTRATEGY"] for instrument in prod_list: products = priceSession.getProducts(prodName=instrument) for product in products: print product if any(prod_type in str(product.prod_type) for prod_type in prod_type_list): contracts = priceSession.getContracts(product) for contract in contracts: print contract if len(contract.seriesKey) < 35: pricey = None settlement_price = None for enum, price in priceSession.getPrices(contract).items(): if "SETTL" in str(enum): settlement_price = price.value if settlement_price is None: if "FUTURE" in str(product): settlement_price = 30000 else: