Exemplo n.º 1
0
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
                elif "LAST_TRD_PRC" in str(enum):
Exemplo n.º 2
0
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()


Exemplo n.º 3
0
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:
Exemplo n.º 4
0
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

if pricey is None:
Exemplo n.º 5
0
    "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:
    products = priceSession.getProducts(prodName=product,
                                        prodType=aenums.TT_PROD_OPTION)
    if len(products) == 0:
        missing_products.append(product)
    else:
        contract_counter = 0
        contracts = priceSession.getContracts(products)
        for contract in contracts:
            if contract_counter <= 1:
                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
Exemplo n.º 6
0
from random import randint
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[0]
ordSrv = Manager().getOrderServer()
priceSrv = Manager().getPriceServer()
product_list = [
    "EY",
]
# 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"]
for product in product_list:
    products = priceSession.getProducts(prodName=product)
    contracts = priceSession.getContracts(products)
    contract = contracts[1]  #(randint(0, len(contracts)-1))]
    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
    if pricey is None:
        pricey = 300
    depth_level = 1
    while depth_level <= 150:
        orderParams = dict(
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")