Skip to main content

SDK for e2t OMS

Project description

API de Python para Market Data y Order Routing

Descripción

Esta API de Python permite:

  • Obtener información de Market Data de IBKR y BYMA.
  • Enviar, remplazar y/o cancelar órdenes al mercado para IBKR y BYMA.

La API está diseñada para ser rápida, eficiente y fácil de usar, utilizando Google Protocol Buffers para la comunicación.

Instalación

Instalar las dependencias:

pip install e2tapi

Uso

Market Data

BYMA

En el siguiente ejemplo, un código simple se conecta a E2T a través de su API e2tapi. Inicialmente, envía una orden, recibe el Reporte de Ejecución, luego la reemplaza y finalmente, después de un segundo, la cancela:

from e2t.mktdata.E2T_MDG_BYMA import E2T_MDG_BYMA
import sys

class MyMktDataByma(E2T_MDG_BYMA):
    def __init__(self):
        super().__init__()

    def snapshot(self, message):
        print(message)

    def bid(self, securityID, type, px, qty):
        print(securityID, type, px, qty)

    def offer(self, securityID, type, px, qty):
        print(securityID, type, px, qty)

    def last(self, securityID, type, date, time, lastPx, lastQty, buyer, seller):
        print(securityID, type, date, time, lastPx, lastQty, buyer, seller)

    def open(self, securityID, type, value):
        print(securityID, type, value)

    def close(self, securityID, type, value):
        print(securityID, type, value)

    def high(self, securityID, type, value):
        print(securityID, type, value)

    def low(self, securityID, type, value):
        print(securityID, type, value)

    def imbalance(self, securityID, type, value):
        print(securityID, type, value)

    def volume(self, securityID, type, value):
        print(securityID, type, value)

    def amount(self, securityID, type, value):
        print(securityID, type, value)

    def staticRefPx(self, securityID, type, value):
        print(securityID, type, value)

    def prevClose(self, securityID, type, value):
        print(securityID, type, value)

    def turnover(self, securityID, type, value):
        print(securityID, type, value)

    def totalTrades(self, securityID, type, value):
        print(securityID, type, value)

    def lowLmtPx(self, securityID, type, value):
        print(securityID, type, value)

    def highLmtPx(self, securityID, type, value):
        print(securityID, type, value)

    def bid2(self, securityID, type, px, qty):
        print(securityID, type, px, qty)

    def offer2(self, securityID, type, px, qty):
        print(securityID, type, px, qty)

    def bid3(self, securityID, type, px, qty):
        print(securityID, type, px, qty)

    def offer3(self, securityID, type, px, qty):
        print(securityID, type, px, qty)

    def bid4(self, securityID, type, px, qty):
        print(securityID, type, px, qty)

    def offer4(self, securityID, type, px, qty):
        print(securityID, type, px, qty)

    def bid5(self, securityID, type, px, qty):
        print(securityID, type, px, qty)

    def offer5(self, securityID, type, px, qty):
        print(securityID, type, px, qty)


def main():
    mktDataByma = MyMktDataByma()
    mktDataByma.connect("127.0.0.1", 2206)
    # Solicitar Market Data
    '''
    mktDataByma.send_mktdata_req( securityID, bid, offer, last, open, close, high, low, imbalance, volume, amount, staticRefPx, prevClose, turnover, totalTrades, LimitPx, bid2, offer2, bid3, offer3, bid4, offer4, bid5, offer5)
    '''
    securityID = 'AAPL-0003-C-CT-ARS'  # Cambiar esto al símbolo deseado
    mktDataByma.send_mktdata_req(securityID, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True)
    try:
        while True:
            pass
    except KeyboardInterrupt:
        print('Saliendo ...')
        sys.exit(0)


if __name__ == "__main__":
    main()

Order Routing

BYMA

En el siguiente ejemplo un código simple se conecta a E2T mediante su API e2tapi. Inicialmente envía una orden, recibe el Reporte de ejecución para luego reemplazar esa misma orden y despues de un segundo cancelarla

import time
from e2t.oms.E2T_OMS_BYMA import E2T_OMS_BYMA


class MyOMSByma(E2T_OMS_BYMA):
    def __init__(self):
        super().__init__()

    def status(self, clOrdID, orderID, quantity, price, live, cumQty, leavesQty, avgPx, lastPx):
        print("\n--- STATUS ---")
        print(f"clOrdID: {clOrdID}")
        print(f"orderID: {orderID}")
        print(f"quantity: {quantity}")
        print(f"price: {price}")
        print(f"live: {live}")
        print(f"cumQty: {cumQty}")
        print(f"leavesQty: {leavesQty}")
        print(f"avgPx: {avgPx}")
        print(f"lastPx: {lastPx}")
        self.clOrdID = clOrdID

    def reject(self, idRef, reason):
        print("\n--- REJECT ---")
        print(f"idRef: {idRef}")
        print(f"reason: {reason}")

    def trade(self, orderId, execId, time, lastQty, lastPx, avgPx, cumQty):
        print("\n--- TRADE ---")
        print(f"orderId: {orderId}")
        print(f"execId: {execId}")
        print(f"time: {time}")
        print(f"lastQty: {lastQty}")
        print(f"lastPx: {lastPx}")
        print(f"avgPx: {avgPx}")
        print(f"cumQty: {cumQty}")


if __name__ == "__main__":
    # Establecer conexión con el OMS

    oms = MyOMSByma()
    oms.connect('127.0.0.1', 2211)

    time.sleep(1)

    # NEW LIMIT ORDER - BUY APPLE 10 @ 100

    '''
    oms.send_limit_order(side, securityID, quantity, price, timeInForce, expireTime, settlType, account,display)
    '''
    oms.send_limit_order('1', 'AAPL-0002-C-CT-ARS', 10, 100, '0', '', '',
                         '555', 0)

    time.sleep(1)

    # NEW REPLACE ORDER - BUY APPLE 20 @ 150

    '''
    oms.send_limit_replace(origClOrdID, quantity, price, expireTime, account, display)
    '''
    oms.send_limit_replace(oms.clOrdID, 20, 150, '', '555', 0)

    time.sleep(1)

    # NEW CANCEL ORDER - BUY APPLE 20 @ 150

    '''
    oms.send_limit_cancel(origClOrdID)
    '''
    oms.send_limit_cancel(oms.clOrdID)

    time.sleep(1)

Licencia

Derechos de autor (c) [2024] [Event2trading]

Todos los derechos reservados.

Se concede permiso a cualquier persona que obtenga una copia de este software y de la documentación asociada a utilizar el software sin restricciones, incluido el derecho a utilizar, copiar, modificar y fusionar el software, sujeto a las siguientes condiciones:

El aviso de copyright anterior y este aviso de permiso se incluirán en todas las copias o partes sustanciales del software.

El software se proporciona "tal cual", sin garantía de ningún tipo, expresa o implícita, incluidas, entre otras, las garantías de comerciabilidad, idoneidad para un propósito particular y no infracción. En ningún caso los autores o titulares de derechos de autor serán responsables de ningún reclamo, daño o responsabilidad, ya sea en una acción de contrato, agravio o de otro tipo, que surja de, fuera de o en relación con el software o el uso u otros tratos en el software.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

e2tapi-1.0.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

e2tapi-1.0.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file e2tapi-1.0.0.tar.gz.

File metadata

  • Download URL: e2tapi-1.0.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for e2tapi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d8d1bd71b74aff4b4f2757a32901f8e87cba567f0b37a6875fb15a9ca31c1dce
MD5 34a5255bc4cf4f83da73f23ea9eeac57
BLAKE2b-256 4956516d279c3e63ca3ee5d88ba1e5a00a987757701613ad8d33efab727ed825

See more details on using hashes here.

File details

Details for the file e2tapi-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: e2tapi-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for e2tapi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 122aba60c3a1caa5e62d9099ae7418bd3676887a23031208e378da5291896a94
MD5 95943920728d923cadfaf1f7d1a97e6b
BLAKE2b-256 6537aefed2529b62c91e53b306c1e25359fbf73f0b6b8674f0fe89decb8ce432

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page