コード例 #1
0
def RunTest():
    submitter = OCOrderSender(attrs['account_id'], attrs['connection_id'])
    while True:
        if GetQuoteId(attrs) == None:
            print "n - new quote"
        else:
            print "x - change quote"
            print "c - cancel quote"
            print "q - quit"
        opt = raw_input("=> ")
        if opt == "c":
            if SendQuoteCancel(submitter, attrs):
                SetQuoteId(attrs, None)
        if opt == "n":
            SendNewQuote(submitter, attrs)
        if opt == "x":
            SendQuoteReplace(submitter, attrs)
        if opt == "q":
            return True
    return False
コード例 #2
0
                },
                {
                    'party_id': "C",
                    'party_role': enums.PARTY_ROLE_ACCOUNT_CODE
                },
                {
                    'party_id': "ML3",
                    'party_role': enums.PARTY_ROLE_ORDER_ENTRY_OPERATOR_ID
                },
                {
                    'party_id': "9",
                    'party_role': enums.PARTY_ROLE_CLEARING_INSTRUCTION
                },
                {
                    'party_id': "TTG",
                    'party_role': enums.PARTY_ROLE_CONTRA_TRADER
                },
            ]
        }]
    }],
    'trans_booked_time':
    1438800308000000000
}
msg = dict_to_protobuf(attrs, NewTradeCapture)

# Submit a new order
submitter = OCOrderSender(account_id, connection_id)
submitter.send(msg)
print '\nSent NewTradeCaptureReport {} on {}\n'.format(report_id,
                                                       submitter.send_topic)
print msg
コード例 #3
0
    'market_id': enums.TT_MARKET_ID_HKEX,
    'connection_id': connection_id,
    'user_id': user_id,
    'account_id': account_id,
    'account': account,
    'quote_id': quote_id,
    'source': enums.SOURCE_PYRATE,
    'appl_id': PYRATE_APPLICATION_ID,
    'ord_type': enums.ORD_TYPE_LIMIT,
    'time_in_force': enums.TIME_IN_FORCE_DAY,
    'sender_location_id': "HKEX",
}
msg = dict_to_protobuf(attrs, NewQuote)

# Submit a new quote
submitter = OCOrderSender(account_id, connection_id)
submitter.send(msg)
print '\nSent NewQuote\n'
# print '\nSent NewQuote {} on {}\n'.format(quote_id, submitter.send_topic)
print msg

# Wait for a response
try:
    wait_topic = 'OR.OC.{}'.format(connection_id)
    msgs = submitter.wait_for_response(Header.MSG_QUOTE_RESPONSE, wait_topic)
    print '\nQuoteResponse(s) received:\n'
    print MessageToString(
        submitter.order_responses[quote_id][-1].order_response)

except:
    print 'Did not receive a QuoteResponse from the OC, make sure its up!!'
コード例 #4
0
        'ord_type': enums.ORD_TYPE_LIMIT,
        'order_qty': 500,
        'time_in_force': enums.TIME_IN_FORCE_IMMEDIATE_OR_CANCEL,
        'market_id': enums.TT_MARKET_ID_ICE,
        'connection_id': connection_id,
        'user_id': user_id,
        'account_id': account_id,
        'account': account,
        'source': enums.SOURCE_PYRATE,
        'appl_id': PYRATE_APPLICATION_ID,
    }],
}
msg = dict_to_protobuf(attrs, NewOrderCross)

# Submit a new order
submitter = OCOrderSender(account_id, connection_id)
submitter.send(msg)
print '\nSent NewOrderCross {} on {}\n'.format(cross_id, submitter.send_topic)
print msg

# Wait for a response
try:
    wait_topic = 'OC.{}'.format(connection_id)
    msgs = submitter.wait_for_response(Header.MSG_EXECUTION_REPORT,
                                       [wait_topic])
    print '\nExecutionReport received:\n'
    print MessageToString(
        submitter.order_responses[order_id][-1].order_response)
except:
    print 'Did not receive a ExecutionReport from the OC, make sure its up!!'