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'))
This python code does not work for me. HEre is the output
S:\perl64\lambda\scripts>python ALGOJI.py
Traceback (most recent call last):
File “ALGOJI.py”, line 7, in
s.connect((HOST, PORT))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine acti
vely refused it
S:\perl64\lambda\scripts>