Delta Exchange API in Python

Delta Exchange India Trade API and Ticker in Python:

Trade Futures & Options on Bitcoin and Ether Elevate your F&O trading with 24/7 open markets, efficient margining and INR settlement

Open Online Delta Exchange India Trading Account Fill the Form with Details as Required.

Visit Delta Exchange India

GET Customized Price | Trade Alert in Telegram Using AWS Lambda:

For Instructions Follow the Video then go For the Code Input:


import requests 
import pandas as pd  
from datetime import datetime, timedelta 
import json
config=open('token_chat_id.txt','r').read()
config=json.loads(config)
token=config['token']
chat_id=config['chat_id']
tele_url=f'https://api.telegram.org/bot{token}'  

base_url="https://api.india.delta.exchange"
url=f"{base_url}/v2/history/candles"
end=int(datetime.now().timestamp())
start=int((datetime.now()-timedelta(days=1)).timestamp())
params={
    'symbol':'BTCUSD',
    'resolution':'1m',
    'start':start,
    'end':end
}
r=requests.get(url,params=params)
data=r.json().get('result',[])
df=pd.DataFrame(data,columns=['time','open','high','low','close','volume'])
if df['close'].iloc[-1] < df['open'].iloc[-1]:
    Candle='RED'
    msg=f"'BTCUSD',{Candle},{df['close'].iloc[-1]},{df['open'].iloc[-1]}"
send_alert=requests.get(f'{tele_url}/sendMessage?chat_id={chat_id}&text={msg}').json()['result']['text']
print(send_alert)

Generate API Key:


For Instructions Follow the Video then go For the Code Input:


CMD:pip install delta-rest-client


import json
from delta_rest_client import DeltaRestClient
config=open('delta.txt','r').read()
config=json.loads(config)
api_key=config['api_key']
api_secret=config['api_secret']


delta_client = DeltaRestClient(
  base_url='https://api.india.delta.exchange',
  api_key=api_key,
  api_secret=api_secret
)
response = delta_client.get_ticker('C-BTC-94400-280425')
print(response['mark_price'])

Get Product ID for Crypto Trading Symbol Using Delta Exchange API in Python:


For Instructions Follow the Video then go For the Code Input:



import json
from delta_rest_client import DeltaRestClient
config=open('delta.txt','r').read()
config=json.loads(config)
api_key=config['api_key']
api_secret=config['api_secret']


delta_client = DeltaRestClient(
  base_url='https://api.india.delta.exchange',
  api_key=api_key,
  api_secret=api_secret
)
response = delta_client.get_ticker('C-BTC-103800-190525')
print(response['product_id'])

How to Place Orders in Delta Exchange using Python API:


For Instructions Follow the Video then go For the Code Input:



import json
from delta_rest_client import DeltaRestClient
from delta_rest_client import OrderType
config=open('delta.txt','r').read()
config=json.loads(config)
api_key=config['api_key']
api_secret=config['api_secret']


delta_client = DeltaRestClient(
  base_url='https://api.india.delta.exchange',
  api_key=api_key,
  api_secret=api_secret
)
response = delta_client.get_ticker('BTCUSD')
product_id=response['product_id']
mark_price=round(float(response['mark_price'])-10,1)
order_response=delta_client.place_order(product_id=product_id,
  side='buy',
  size=1,
  limit_price=mark_price,
  order_type=OrderType.LIMIT)
print(order_response)

GET Historical OHLC Candles Utilizing Delta Exchange API in Python:


For Instructions Follow the Video then go For the Code Input:



import requests 
import pandas as pd  
from datetime import datetime, timedelta 

base_url="https://api.india.delta.exchange"
url=f"{base_url}/v2/history/candles"
end=int(datetime.now().timestamp())
start=int((datetime.now()-timedelta(days=1)).timestamp())
params={
    'symbol':'BTCUSD',
    'resolution':'1m',
    'start':start,
    'end':end
}
r=requests.get(url,params=params)
data=r.json().get('result',[])
df=pd.DataFrame(data,columns=['time','open','high','low','close','volume'])
print(df)