Order Placement - Custom Buttons
The custom buttons work similarly to the branded buttons. The only difference being that you will be creating your own custom HTML buttons which will be displayed to the user.
Install Plugin
You need to include the FYERS API Connect JS script in your website / app.
- This needs to be included inside the
- Preferably just before closing the body tag
- This needs to be included just once in your web page
<script src="https://api-connect-docs.fyers.in/fyers-lib.js"></script>
Buy Order
The custom buttons work similarly to the branded buttons. The only difference being that you will be creating your own custom HTML buttons which will be displayed to the user.
<!--A custom button--!>
<button id="custom-button">Buy 1 stock</button>
<script>
Fyers.ready(function(){
var fyers = new Fyers("API_KEY")
fyers.add({
"symbol": "NSE:RELIANCE-EQ",
"quantity": 4,
"order_type": "LIMIT",
"transaction_type": "BUY",
"product":"INTRADAY",
"disclosed_quantity":0,
"price":200
});
// link stocks to this custom button
fyers.link("#custom-button");
})
</script>
Sell Order
The custom buttons work similarly to the branded buttons. The only difference being that you will be creating your own custom HTML buttons which will be displayed to the user.
<!--A custom button--!>
<button id="custom-button">Sell 1 stock</button>
<script>
Fyers.ready(function(){
var fyers = new Fyers("API_KEY")
fyers.add({
"symbol": "NSE:RELIANCE-EQ",
"quantity": 1,
"order_type": "LIMIT",
"transaction_type": "SELL",
"product":"INTRADAY",
"disclosed_quantity":0,
"price":200
});
// link stocks to this custom button
fyers.link("#custom-button");
})
</script>
Basket Order
The custom buttons work similarly to the branded buttons. The only difference being that you will be creating your own custom HTML buttons which will be displayed to the user.
<!--A custom button--!>
<button id="custom-button">Trade 2 stocks</button>
<script>
Fyers.ready(function(){
var fyers = new Fyers("API_KEY")
fyers.add({
"symbol": "NSE:RELIANCE-EQ",
"quantity": 1,
"order_type": "LIMIT",
"transaction_type": "BUY",
"product":"INTRADAY",
"disclosed_quantity":0,
"price":200
});
fyers.add({
"symbol": "NSE:SBIN-EQ",
"quantity": 1,
"order_type": "LIMIT",
"transaction_type": "SELL",
"product":"INTRADAY",
"disclosed_quantity":0,
"price":200
});
// link stocks to this custom button
fyers.link("#custom-button");
})
</script>