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:
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
import time from pyrate.ttapi.manager import Manager from pyrate.ttapi.order import TTAPIOrder from ttapi import aenums, cppclient priceSession = Manager().getPriceSession() orderSession0 = Manager().getOrderFillSessions()[-1] orderSession1 = Manager().getOrderFillSessions()[-1] custDefaults0 = Manager().getCustomers() custDefaults1 = Manager().getCustomers()[0] ordSrv = Manager().getOrderServer() priceSrv = Manager().getPriceServer() create_depth = False1 products = priceSession.getProducts(prodName="JGBM", prodType=aenums.TT_PROD_FUTURE) product = products[0] contracts = priceSession.getContracts(product) contract = contracts[1] pricey = None settlement_price = None acct_types = [] for aenum in dir(aenums): if "ACCT" in aenum: if "GIVEUP_3" not in aenum and "REQUEST" not in aenum: if not any(acct in aenum for acct in [ "_4", "_5", "_6", "_7", "_8", "_9", "GIVEUP_3", "REQUEST", "MARKETMAKER", "UNALLOCATED", "CLEARING", "CUSTOMER", "MEMBER", "OTHER", "NONE" ]): acct_types.append(aenum) giveup_field_vals = ["GU", ""]
import time from pyrate.builder import Builder from pyrate.ttapi.manager import Manager from pyrate.ttapi.order import TTAPIOrder from ttapi import aenums, cppclient from captain.controlled import controlled_name_type, ControlledName from captain.lib.controlled_types import Tif priceSession = Manager().getPriceSession() orderSession = Manager().getOrderFillSession() allCustDefaults = Manager().getCustomers() custDefaults = allCustDefaults[0] ordSrv = Manager().getOrderServer() priceSrv = Manager().getPriceServer() product_list = [ "MCH", ] products = priceSession.getProducts(prodName=product_list[0], prodType=aenums.TT_PROD_FUTURE) product = products[0] contracts = priceSession.getContracts(products, contractKeys=[ "397224", ]) contract = contracts[0] pricey = None for enum, price in priceSession.getPrices(contract).items(): if "SETTL" in str(enum): pricey = price.value elif "LAST_TRD_PRC" in str(enum): pricey = price.value elif "OPEN_PRC" in str(enum): pricey = price.value
import time import pyscreenshot from pyrate.ttapi.manager import Manager from pyrate.ttapi.order import TTAPIOrder from ttapi import aenums, cppclient priceSession = Manager().getPriceSession() orderSession = Manager().getOrderFillSession() allCustDefaults = Manager().getCustomers() ordSrv = Manager().getOrderServer() priceSrv = Manager().getPriceServer() products = priceSession.getProducts(prodName='JGBM', prodType=aenums.TT_PROD_FUTURE) product = products[0] contracts = priceSession.getContracts( product) #, contractKeys="FUT_NK225M_1704") contract = contracts[2] custDefaults = allCustDefaults[-1] run_now = True prev_trading_status = None curr_trading_status = None pricey = None while run_now is True: time.sleep(5) try: for enum, price in priceSession.getPrices(contract).items(): if "SETTL" in str(enum): pricey = price.value elif "LAST_TRD_PRC" in str(enum): pricey = price.value elif "OPEN_PRC" in str(enum): pricey = price.value
import time import random from pyrate.builder import Builder from pyrate.ttapi.manager import Manager from pyrate.ttapi.order import TTAPIOrder from ttapi import aenums, cppclient 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='CN', prodType=aenums.TT_PROD_FUTURE) custDefaults = allCustDefaults[0] while True: for product in products: pricey = None found_price = None if "STOCK" not in str(product.prod_type): if "FUTURE" not in str(product.prod_type): pricey = 3 contracts = priceSession.getContracts( product, contractKeys=["CNM18", "CNN18"]) for contract in contracts: for enum, price in priceSession.getPrices(contract).items(): if "SETTL" in str(enum): found_price = price.value elif "LAST_TRD_PRC" in str(enum): found_price = price.value
import time from pyrate.builder import Builder from pyrate.ttapi.manager import Manager from pyrate.ttapi.order import TTAPIOrder from ttapi import aenums, cppclient from captain.controlled import controlled_name_type, ControlledName from captain.lib.controlled_types import Tif priceSession = Manager().getPriceSession() orderSession = Manager().getOrderFillSession() allCustDefaults = Manager().getCustomers() custDefaults = allCustDefaults[0] ordSrv = Manager().getOrderServer() priceSrv = Manager().getPriceServer() missing_products = [] # product_list = ["CH", "EY", "FB", "GD", "ID", "IN", "INB", "ING", "INI", "IU", "JG", "MD", "MY", "ND", "NS", "NU", "PH", "SGP", "ST", "TH", "TU", "TW", "UJ", "UY"] product_list = [ "A50", "AAC", "ABC", "ACC", "AIA", "ALC", "ALI", "AMC", "AVI", "BAI", "BCL", "BCM", "BEA", "BOC", "BYD", "CCB", "CCC", "CCE", "CCS", "CDA", "CGN", "CHB", "CHO", "CHQ", "CHT", "CHU", "CIT", "CKH", "CKP", "CLI", "CLP", "CMB", "CNC", "COG", "COL", "CPA", "CPC", "CPI", "CRC", "CRG", "CRL", "CRR", "CS3", "CSA", "CSB", "CSE", "CTB", "CTC", "CTS", "CTY", "DFM", "DIG", "ESP", "EVG", "FIA", "FIH", "FOS", "GAC", "GAH", "GLX", "GOM", "GWM", "HAI", "HCF", "HEC", "HEH", "HEX", "HGN", "HKB", "HKE", "HKG", "HLB", "HLD", "HNP", "HSB", "ICB", "JXC", "KLE", "KSO", "LEN", "LIF", "LNK", "MEN", "MGM", "MSB", "MTA", "MTR", "NBM", "NCL", "NWD", "PAI", "PEC", "PIC", "PIN", "PLE", "POL", "RFP", "SAN", "SHK", "SMC", "SNO", "SOA", "SOH", "STC", "SUN", "SWA", "TCH", "TRF", "WHB", "WHL", "WWC", "XAB", "XBC", "XCC", "XIC", "YZC", "ZJM" ] # product_list = ["PTCD", "TBGA", "TBGO", "TBKE", "TGAB", "TGCN", "TGSB", "TLGA", "TLGO", "TLKE"] for product in product_list:
import datetime import time from pyrate.builder import Builder from pyrate.ttapi.manager import Manager from pyrate.ttapi.order import TTAPIOrder from pyrate.ttapi.customer import TTAPICustomer from ttapi import aenums, cppclient from ttapi.client.type_converters import date2_ttDate from captain.controlled import controlled_name_type, ControlledName from captain.lib.controlled_types import Tif priceSession = Manager().getPriceSession() orderSession = Manager().getOrderFillSession() custDefaults = Manager().getCustomer() ordSrv = Manager().getOrderServer() priceSrv = Manager().getPriceServer() tiffies = ('GTD', 'GTC', 'GTDATE') # 'GIS')#, 'FOK') restr = (None, aenums.TT_FOK_ORDER_RES, aenums.TT_IOC_ORDER_RES) products = priceSession.getProducts(prodType=aenums.TT_PROD_FUTURE, prodName="EY") time.sleep(60) for product in products: contracts = priceSession.getContracts( product, contractKeys=["EYZ18", "EYH19", "EYM19"]) for contract in contracts: 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 = 100
if time.localtime()[3] == 10 and time.localtime()[4] == 29: while scrnshot_count <= 6: time.sleep(15) pyscreenshot.grab_to_file(r"C:\tt\dayend_test_" + str(scrnshot_count) + ".png") scrnshot_count += 1 break else: time.sleep(20) import time import pyscreenshot from pyrate.ttapi.manager import Manager priceSession = Manager().getPriceSession() priceSrv = Manager().getPriceServer() while True: if time.localtime()[3] == 7 and time.localtime()[4] in range(0, 5): pyscreenshot.grab_to_file(r"C:\tt\screenshot_start_subscribe_" + "-".join([str(time.localtime()[3]), str(time.localtime()[4]), str(time.localtime()[5])]) + ".png") products = priceSession.getProducts() for product in products: contracts = priceSession.getContracts(product) for contract in contracts: print contract pricedata = priceSession.getPrices(contract, timeout=90) pyscreenshot.grab_to_file(r"C:\tt\screenshot_end_subscribe_" + "-".join([str(time.localtime()[3]), str(time.localtime()[4]), str(time.localtime()[5])]) + ".png") time.sleep(360) python
import time import pyscreenshot from pyrate.ttapi.manager import Manager from pyrate.ttapi.order import TTAPIOrder from ttapi import aenums, cppclient priceSession = Manager().getPriceSession() orderSession = Manager().getOrderFillSession() allCustDefaults = Manager().getCustomers() custDefaults = allCustDefaults[-1] ordSrv = Manager().getOrderServer() priceSrv = Manager().getPriceServer() max_detailed_depth = 3 prev_trading_status = None curr_trading_status = None pricey = 20600 products = priceSession.getProducts(prodName='NK', prodType=aenums.TT_PROD_FUTURE) product = products[0] contracts = priceSession.getContracts(product, contractKeys=["NKN19", "NKQ19"]) while True: while curr_trading_status == prev_trading_status: for contract in contracts: try: for enum, price in priceSession.getPrices(contract).items(): if "SRS_STATUS" in str(enum): curr_trading_status = price.value except: pass time.sleep(15) orderSession.deleteMyOrders() for contract in contracts:
import time import pyscreenshot from pyrate.ttapi.manager import Manager priceSession = Manager().getPriceSession() allCustDefaults = Manager().getCustomers() ordSrv = Manager().getOrderServer() priceSrv = Manager().getPriceServer() products = priceSession.getProducts(prodName='CRUD') product = products[0] contracts = priceSession.getContracts(product) contract = contracts[0] run_now = True prev_trading_status = None curr_trading_status = None pricey = None screenshot_counter = 100 print "Contract:", contract while run_now is True: time.sleep(5) try: for enum, price in priceSession.getPrices(contract).items(): if "SRS_STATUS" in str(enum): curr_trading_status = price.value if prev_trading_status is None: prev_trading_status = price.value except: pass screenshot_counter = 100 if curr_trading_status == prev_trading_status else 1 while screenshot_counter <= 5: print "CHECK:", prev_trading_status, curr_trading_status pyscreenshot.grab_to_file(r"C:\tt\screenshot_" + str(curr_trading_status) + "_" + "-".join([str(time.localtime()[3]), str(time.localtime()[4]), str(time.localtime()[5])]) + ".png")