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)
Customized Interactive Historical OHLC Candlestick Chart Using Delta Exchange API:
For Instructions Follow the Video then go For the Code Input:
import requests
import pandas as pd
from datetime import datetime, timedelta
import mplfinance as mpf
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':'15m',
'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']).sort_values('time')
df['time']=pd.to_datetime(df['time'],unit='s')
df['time']=df['time'].dt.tz_localize('UTC').dt.tz_convert('Asia/Kolkata')
df.set_index('time',inplace=True)
mpf.plot(df,type='candle',volume=False,style='charles',title='BTCUSD 15-Minute Candlestick Chart')
Customized Interactive Historical OHLC Candlestick Chart Using API Part2:
For Instructions of Connecting Chart GUI Follow the Video then go For the Code Input:
import requests
import pandas as pd
from datetime import datetime, timedelta
import mplfinance as mpf
import toga
from toga.style import Pack
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':'5m',
'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']).sort_values('time')
df['time']=pd.to_datetime(df['time'],unit='s')
df['time']=df['time'].dt.tz_localize('UTC').dt.tz_convert('Asia/Kolkata')
df.set_index('time',inplace=True)
mpf.plot(df,type='candle',volume=False,style='charles',title='BTCUSD 5-Minute Candlestick Chart',savefig=dict(fname='btc_chart.png',dpi=150,pad_inches=0.25,bbox_inches='tight'))
class ChartApp(toga.App):
def startup(self):
self.main_window=toga.MainWindow(title=self.formal_name)
image=toga.Image('btc_chart.png')
image_view=toga.ImageView(image=image,style=Pack(padding=10))
self.main_window.content=image_view
self.main_window.show()
def main():
return ChartApp('BTCUSD','369')
main().main_loop()
Customized Interactive Historical OHLC Candlestick Chart Using API Part3:
For Instructions of Charts Cache Follow the Video then go For the Code Input:
import requests
import pandas as pd
from datetime import datetime, timedelta
import mplfinance as mpf
import toga
from toga.style import Pack
import os
import matplotlib
matplotlib.use("Agg")
class ChartApp(toga.App):
def fetch_candlestic_data(self,symbol):
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':symbol,
'resolution':self.resolution,
'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']).sort_values('time')
df['time']=pd.to_datetime(df['time'],unit='s')
df['time']=df['time'].dt.tz_localize('UTC').dt.tz_convert('Asia/Kolkata')
df.set_index('time',inplace=True)
return df
def startup(self):
symbol='BTCUSD'
self.resolution='5m'
df=self.fetch_candlestic_data(symbol)
os.makedirs(self.paths.cache,exist_ok=True)
chart_path=os.path.join(self.paths.cache,f'{symbol}_{self.resolution}_chart.png')
mpf.plot(df,type='candle',volume=False,style='charles',title=f'{symbol} {self.resolution} Candlestick Chart',savefig=dict(fname=chart_path,dpi=150))
self.main_window=toga.MainWindow(title=self.formal_name)
image=toga.Image(chart_path)
image_view=toga.ImageView(image=image,style=Pack(padding=10))
self.main_window.content=image_view
self.main_window.show()
def main():
return ChartApp('BTCUSD','369')
main().main_loop()