Select Page

You can use Python Sample Code for Sending Signals. Therefore Integrating Python with APIBridge is extremely easy. You just need to execute the following Pyhton v3 code for placing orders. For the syntax/protocol/parameters sent to APIBridge, Please refer here.

import socket
# client code to connect with API bridge
HOST = '127.0.0.1'  # The server's hostname or IP address
PORT = 30001    # The port used by the server

 #ID,Type,Symbol,OrderType|ProductType,TrigPrice,Price,Qty,InstrumentName,StrategyTag"
    # Symbol = Symbol | Expiry | Strike | OptionType
    # TrigPrice = TrigPrice | StopLoss | SquareOff | TrailingTicks
    # StrategyTag = StrategyTag | Port
signals = ["1,SE,SBIN,M|MIS,1,180,1,EQ,STG1", "1,SE,RELIANCE,L|MIS,1,180,1,EQ,STG1" , "1,SE,HDFC,L|MIS,1,1200,100,EQ,STG1", "1,SE,INFY|30MAY2019|130|PE,L|MIS,1,2000,50,OPTSTK,STG1"]
for x in signals:
    print(x)
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        s.connect((HOST, PORT)) 
        s.sendall(bytes(x+" ",'utf-8'))