Algofox option intgration
import requests
signal=0
def Cover_order_algofox(symbol, quantity, direction="COVER", product="MIS", order_typ="MARKET",
strategy="PRO1", signal=signal, price=None, trigger=None, sll_price=None):
req = requests.get('https://api.algofox.in')
# algfx = json.loads(req)
print(req)
req = requests.post(url='https://api.algofox.in/api/Trade/v1/authenticate',
json={"username": "admin125", "password": "admin125",
"role": "USER"})
t = req.json()
print(t)
algofox_token = t['data']['token']
headers = "Bearer " + algofox_token
headers = {"Authorization": headers}
print(headers)
# print(symbol,quantity, direction,product,order_typ)
# print(headers,direction,product,quantity,order_typ)
# print()
data = {
"signalId": int(signal),
"triggerPrice": 0,
"price": 0 if order_typ == "MARKET" else price,
"symbol": symbol,
"signalType": direction,
"orderType": order_typ,
"productType": product,
"instrumentType": "EQ",
"quantity": str(quantity),
"strategy": strategy,
}
print(data)
req = requests.post(url='http://api.algofox.in/api/Trade/v1/placeorder', json=data, headers=headers)
print(req)
print(req.text)
signal=signal+1
def Short_order_algofox(symbol, quantity, direction="SHORT", product="MIS", order_typ="MARKET",
strategy="PRO1", signal=signal, price=None, trigger=None, sll_price=None):
req = requests.get('https://api.algofox.in')
# algfx = json.loads(req)
print(req)
req = requests.post(url='https://api.algofox.in/api/Trade/v1/authenticate',
json={"username": "admin125", "password": "admin125",
"role": "USER"})
t = req.json()
print(t)
algofox_token = t['data']['token']
headers = "Bearer " + algofox_token
headers = {"Authorization": headers}
print(headers)
# print(symbol,quantity, direction,product,order_typ)
# print(headers,direction,product,quantity,order_typ)
# print()
data = {
"signalId": int(signal),
"triggerPrice": 0,
"price": 0 if order_typ == "MARKET" else price,
"symbol": symbol,
"signalType": direction,
"orderType": order_typ,
"productType": product,
"instrumentType": "EQ",
"quantity": str(quantity),
"strategy": strategy,
}
print(data)
req = requests.post(url='http://api.algofox.in/api/Trade/v1/placeorder', json=data, headers=headers)
print(req)
print(req.text)
signal = signal + 1
def Sell_order_algofox(symbol, quantity, direction="SELL", product="MIS", order_typ="MARKET",
strategy="PRO1", signal=signal, price=None, trigger=None, sll_price=None):
req = requests.get('https://api.algofox.in')
# algfx = json.loads(req)
print(req)
req = requests.post(url='https://api.algofox.in/api/Trade/v1/authenticate',
json={"username": "admin125", "password": "admin125",
"role": "USER"})
t = req.json()
print(t)
algofox_token = t['data']['token']
headers = "Bearer " + algofox_token
headers = {"Authorization": headers}
print(headers)
# print(symbol,quantity, direction,product,order_typ)
# print(headers,direction,product,quantity,order_typ)
# print()
data = {
"signalId": int(signal),
"triggerPrice": 0,
"price": 0 if order_typ == "MARKET" else price,
"symbol": symbol,
"signalType": direction,
"orderType": order_typ,
"productType": product,
"instrumentType": "EQ",
"quantity": str(quantity),
"strategy": strategy,
}
print(data)
req = requests.post(url='http://api.algofox.in/api/Trade/v1/placeorder', json=data, headers=headers)
print(req)
print(req.text)
signal = signal + 1
def Buy_order_algofox(symbol, quantity, direction="BUY",product="MIS",order_typ="MARKET",strategy="PRO1",signal=signal,price=None,trigger=None,sll_price=None):
req = requests.get('https://api.algofox.in')
# algfx = json.loads(req)
print(req)
req = requests.post(url='https://api.algofox.in/api/Trade/v1/authenticate',
json={"username": "admin125", "password": "admin125",
"role": "USER"})
t = req.json()
print(t)
algofox_token = t['data']['token']
headers="Bearer "+algofox_token
headers={"Authorization": headers}
print(headers)
# print(symbol,quantity, direction,product,order_typ)
#print(headers,direction,product,quantity,order_typ)
# print()
data = {
"signalId": int(signal),
"triggerPrice": 0,
"price": 0 if order_typ == "MARKET" else price,
"symbol": symbol,
"signalType": direction,
"orderType": order_typ,
"productType": product,
"instrumentType": "EQ",
"quantity": str(quantity),
"strategy": strategy,
}
print(data)
req = requests.post(url='http://api.algofox.in/api/Trade/v1/placeorder', json=data, headers=headers)
print(req)
print(req.text)
signal = signal + 1
Comments
Post a Comment