Skip to content

Instantly share code, notes, and snippets.

@krishnavelu krishnavelu/main.py Secret
Last active Jul 10, 2020

Embed
What would you like to do?
Simple Moving average strategy using alice_blue library
import logging
import datetime
import statistics
from time import sleep
from alice_blue import *
# Config
username = 'username'
password = 'password'
api_secret = 'api_secret'
twoFA = 'a'
EMA_CROSS_SCRIP = 'INFY'
logging.basicConfig(level=logging.DEBUG) # Optional for getting debug messages.
# Config
ltp = 0
socket_opened = False
alice = None
def event_handler_quote_update(message):
global ltp
ltp = message['ltp']
def open_callback():
global socket_opened
socket_opened = True
def buy_signal(ins_scrip):
global alice
alice.place_order(transaction_type = TransactionType.Buy,
instrument = ins_scrip,
quantity = 1,
order_type = OrderType.Market,
product_type = ProductType.Intraday,
price = 0.0,
trigger_price = None,
stop_loss = None,
square_off = None,
trailing_sl = None,
is_amo = False)
def sell_signal(ins_scrip):
global alice
alice.place_order(transaction_type = TransactionType.Sell,
instrument = ins_scrip,
quantity = 1,
order_type = OrderType.Market,
product_type = ProductType.Intraday,
price = 0.0,
trigger_price = None,
stop_loss = None,
square_off = None,
trailing_sl = None,
is_amo = False)
def main():
global socket_opened
global alice
global username
global password
global twoFA
global api_secret
global EMA_CROSS_SCRIP
minute_close = []
access_token = AliceBlue.login_and_get_access_token(username=username, password=password, twoFA=twoFA, api_secret=api_secret)
alice = AliceBlue(username=username, password=password, access_token=access_token, master_contracts_to_download=['NSE'])
print(alice.get_balance()) # get balance / margin limits
print(alice.get_profile()) # get profile
print(alice.get_daywise_positions()) # get daywise positions
print(alice.get_netwise_positions()) # get netwise positions
print(alice.get_holding_positions()) # get holding positions
ins_scrip = alice.get_instrument_by_symbol('NSE', EMA_CROSS_SCRIP)
socket_opened = False
alice.start_websocket(subscribe_callback=event_handler_quote_update,
socket_open_callback=open_callback,
run_in_background=True)
while(socket_opened==False): # wait till socket open & then subscribe
pass
alice.subscribe(ins_scrip, LiveFeedType.COMPACT)
current_signal = ''
while True:
if(datetime.datetime.now().second == 0):
minute_close.append(ltp)
if(len(minute_close) > 20):
sma_5 = statistics.mean(minute_close[-5:])
sma_20 = statistics.mean(minute_close[-20:])
if(current_signal != 'buy'):
if(sma_5 > sma_20):
buy_signal(ins_scrip)
current_signal = 'buy'
if(current_signal != 'sell'):
if(sma_5 < sma_20):
sell_signal(ins_scrip)
current_signal = 'sell'
sleep(1)
sleep(0.2) # sleep for 200ms
if(__name__ == '__main__'):
main()
@ahdbala

This comment has been minimized.

Copy link

ahdbala commented Dec 6, 2019

While getting access_token, i get the following error. Username, password, 2Fa and api_secret are correct.

File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\alice_blue\alice_blue.py", line 246, in login_and_get_access_token
code = resp.url[resp.url.index('=')+1:resp.url.index('&')]
ValueError: substring not found

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Dec 7, 2019

Refer issue 22

@vikram477

This comment has been minimized.

Copy link

vikram477 commented Dec 12, 2019

Sir I am unable to get access token in market time(9am-10am) also it give me None all the time . i also check in
There is problem in
if ('OAuth 2.0 Error' in resp.text):
logging.info("OAuth 2.0 Error occurred. Please verify your api_secret")
Please help me out

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Dec 12, 2019

Contact Aliceblue if your api secret is active.
Also refer issue #22

@vikram477

This comment has been minimized.

Copy link

vikram477 commented Dec 13, 2019

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Dec 14, 2019

Contact Aliceblue if your api secret is active.

@RajeshSivadasan

This comment has been minimized.

Copy link

RajeshSivadasan commented Dec 27, 2019

Isn't there a way to get instrument quote besides websocket? In zerodha you have a quote method to just get the ltp

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Dec 27, 2019

No, you’ve to subscribe to get quotes.

@chandramohank82

This comment has been minimized.

Copy link

chandramohank82 commented Feb 5, 2020

Please provide a websockets example of using " ltp" of multiple instruments ( to connect ant front-end application) .

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Feb 5, 2020

Try subscribing multiple instruments and see what you get as response.

@balramzc

This comment has been minimized.

Copy link

balramzc commented Mar 1, 2020

Can you please provide me a Renko with ema strategy to place orders in BankNifty weekly options

@bakarep

This comment has been minimized.

Copy link

bakarep commented Mar 20, 2020

Hi Krishna Sir,
For tick data to be converted to OHLC, I am assuming that I will have to subscribe to the feed from start of the day. What if I am starting my application at 10am ? How can I get OHLC or tick data from start of the day till 10am ?
Is there a plan to provide API to fetch OHLC data ? Anyways this data is present and used by AliceBlue to show charts. cant it be made available through API ?

@balramzc

This comment has been minimized.

Copy link

balramzc commented Mar 21, 2020

Sir , is it possible to get Bid and Ask with this API, instead of LTP.

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Mar 24, 2020

Try different type of LiveFeedType

@PRAKSH24884

This comment has been minimized.

Copy link

PRAKSH24884 commented Mar 27, 2020

sir how to get only ltp of nse bse and future please help

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Apr 2, 2020

nifty_nse_eq = alice.get_instrument_by_symbol('NSE', 'Nifty 50')

Refer issue #25

@PRAKSH24884

This comment has been minimized.

Copy link

PRAKSH24884 commented Apr 2, 2020

sir how to get only ltp of any stock like zerodha please help

@Capital-king

This comment has been minimized.

Copy link

Capital-king commented Apr 10, 2020

Hi Krishna Sir,

For tick data to be converted to OHLC, I am assuming that I will have to subscribe to the feed from start of the day. What if I am starting my application at 10am ? How can I get OHLC or tick data from start of the day till 10am ?
Is there a plan to provide API to fetch OHLC data ? Anyways this data is present and used by AliceBlue to show charts. cant it be made available through API ?

Sir I have the same question asked by @bakarep. TIA

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Apr 12, 2020

sir how to get only ltp of any stock like zerodha please help

Refer this example.

For tick data to be converted to OHLC, I am assuming that I will have to subscribe to the feed from start of the day. What if I am starting my application at 10am ? How can I get OHLC or tick data from start of the day till 10am ?
Is there a plan to provide API to fetch OHLC data ? Anyways this data is present and used by AliceBlue to show charts. cant it be made available through API ?

If you understand what is OHLC data, you can easily reconstruct OHLC from tick data. refer this comment.

@bakarep

This comment has been minimized.

Copy link

bakarep commented Apr 13, 2020

I am getting 'exchange_time_stamp': 1271239885. What is the format of this datetime value ? I checked and it is not unix timestamp.

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Apr 17, 2020

Use this link to convert time stamp.

@bakarep

This comment has been minimized.

Copy link

bakarep commented Apr 17, 2020

The query is not about process of unix to regular time conversion. The query is why I am getting unix time as '1271239885' which corresponds to 04/14/2010 @ 10:11am (UTC) and not 2020?

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Apr 19, 2020

Use this

image

@ckeshav691

This comment has been minimized.

Copy link

ckeshav691 commented May 2, 2020

import time,os,datetime,math
from time import sleep
import logging
import re
from alice_blue import *
import pandas as pd

username = "AAAAAA"
password = "AAAAAAA"
api_secret = "AAAAAAA"
twoFA = "AAAAAA"
access_token = AliceBlue.login_and_get_access_token(username=username,password=password,twoFA=twoFA,api_secret=api_secret)
alice = AliceBlue(username=username,password=password,access_token=access_token,master_contracts_to_download=['NSE'])

print("Master contract loaded succesfully")
print("\n")

print("Getting Profile Details ")
print("\n")
profile = alice.get_profile()
profile_data=(profile['data'])
exchange = profile_data['exchanges']
print("Name: ",profile_data['name']," Client Id: ",profile_data['login_id']," Pan card: ",profile_data["pan_number"],"Exchange : ",exchange[1])
print("\n")
balance = alice.get_balance()
balance_data = balance['data']
cash_position = balance_data['cash_positions']
print("Balance available is : ",cash_position[0]['utilized']['var_margin'])

print("Wait for breakout Time\n")

socket_opened = False
token = 0
open_price=0
high_price=0
low_price=0
close_price=0

def event_handler_quote_update(message):
global token
global open_price
global high_price
global close_price
global low_price
token = message['token']
open_price = message['open']
high_price = message['high']
low_price = message['low']
close_price = message['close']

def open_callback():
global socket_opened
socket_opened = True

alice.start_websocket(subscribe_callback=event_handler_quote_update,
socket_open_callback=open_callback,
run_in_background=True)
while(socket_opened==False):
pass
alice.subscribe(alice.get_instrument_by_symbol("NSE","ONGC"), LiveFeedType.FULL_SNAPQUOTE)
print(token,open_price,high_price,low_price,close_price)
sleep(10)
Sir why when printing values give the 0 value but when we do this with datetime.datetime.now().second==0 in loop as you have done ,it gives right value.

@ckeshav691

This comment has been minimized.

Copy link

ckeshav691 commented May 2, 2020

import time,os,datetime,math
from time import sleep
import logging
import re
from alice_blue import *
import pandas as pd

username = "AAAAAA"
password = "AAAAAAA"
api_secret = "AAAAAAA"
twoFA = "AAAAAA"
access_token = AliceBlue.login_and_get_access_token(username=username,password=password,twoFA=twoFA,api_secret=api_secret)
alice = AliceBlue(username=username,password=password,access_token=access_token,master_contracts_to_download=['NSE'])

print("Master contract loaded succesfully")
print("\n")

print("Getting Profile Details ")
print("\n")
profile = alice.get_profile()
profile_data=(profile['data'])
exchange = profile_data['exchanges']
print("Name: ",profile_data['name']," Client Id: ",profile_data['login_id']," Pan card: ",profile_data["pan_number"],"Exchange : ",exchange[1])
print("\n")
balance = alice.get_balance()
balance_data = balance['data']
cash_position = balance_data['cash_positions']
print("Balance available is : ",cash_position[0]['utilized']['var_margin'])

print("Wait for breakout Time\n")

socket_opened = False
token = 0
open_price=0
high_price=0
low_price=0
close_price=0

def event_handler_quote_update(message):
global token
global open_price
global high_price
global close_price
global low_price
token = message['token']
open_price = message['open']
high_price = message['high']
low_price = message['low']
close_price = message['close']

def open_callback():
global socket_opened
socket_opened = True

alice.start_websocket(subscribe_callback=event_handler_quote_update,
socket_open_callback=open_callback,
run_in_background=True)
while(socket_opened==False):
pass
alice.subscribe(alice.get_instrument_by_symbol("NSE","ONGC"), LiveFeedType.FULL_SNAPQUOTE)
print(token,open_price,high_price,low_price,close_price)
sleep(10)
Sir why when printing values give the 0 value but when we do this with datetime.datetime.now().second==0 in loop as you have done ,it gives right value.

Hey sir, i solved the issue i put down sleep before print and worked.

@Niranjan-Koppolu

This comment has been minimized.

Copy link

Niranjan-Koppolu commented May 6, 2020

2 things..
#1 how to get balance available for trading? is this right? print(alice.get_balance()['data']['cash_positions'][0]['net'])
#2 if i want to screen say 25 scripts every hour once, how to do? sleep(3600) didnt looping also is always 'message' is the passing param? how to capture and pass through.

@Niranjan-Koppolu

This comment has been minimized.

Copy link

Niranjan-Koppolu commented May 7, 2020

2 things..
#1 how to get balance available for trading? is this right? print(alice.get_balance()['data']['cash_positions'][0]['net'])
#2 if i want to screen say 25 scripts every hour once, how to do? sleep(3600) didnt looping also is always 'message' is the passing param? how to capture and pass through.

understood that websockets working only in python IDLE. not in windows command prompt.above issues resolved.

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented May 9, 2020

You should get live data for both. Check on market time.

@akashrajcashrayz

This comment has been minimized.

Copy link

akashrajcashrayz commented May 11, 2020

You should get live data for both. Check on market time.
thanku sir but can we get both stock data simultaniously on single tick?

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented May 12, 2020

No, it comes from server.

@akashrajcashrayz

This comment has been minimized.

Copy link

akashrajcashrayz commented May 12, 2020

thanku sir for your help

@akashrajcashrayz

This comment has been minimized.

Copy link

akashrajcashrayz commented May 13, 2020

SIR in documentation their is basket order i copy and pasted the same code but getting float error`order1 = { "instrument" : alice.get_instrument_by_symbol('NSE', 'INFY'),

        "order_type"        : OrderType.Market,
        "quantity"          : 1,
        "transaction_type"  : TransactionType.Buy,
        "product_type"      : ProductType.Delivery}

order2 = { "instrument" : alice.get_instrument_by_symbol('NSE', 'SBIN'),
"order_type" : OrderType.Limit,
"quantity" : 2,
"price" : 280.00,
"transaction_type" : TransactionType.Sell,
"product_type" : ProductType.Intraday}
order = [order1, order2]
print(alice.place_basket_order(order))

####### THIS IS ERROR

File "C:\Users\AKASH RAJ.virtualenvs\untitled2\lib\site-packages\alice_blue\alice_blue.py", line 574, in place_basket_order
raise TypeError("Element price in orders should be of type float")
TypeError: Element price in orders should be of type float
`

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented May 17, 2020

This will be solved issue #99

@akashrajcashrayz

This comment has been minimized.

Copy link

akashrajcashrayz commented May 18, 2020

GETTING ERROR WHILE GETTING RESPONSE OF BSE
` line 692, in subscribe
raise TypeError("Required parameter instrument not of type Instrument")
TypeError: Required parameter instrument not of type Instrument
logging.basicConfig(level=logging.DEBUG) # Optional for getting debug messages.

Config

access_token = AliceBlue.login_and_get_access_token(username=username, password=password, twoFA=twoFA,
api_secret=api_secret)
alice = AliceBlue(username=username, password=password, access_token=access_token,
master_contracts_to_download=['NSE','BSE'])
socket_opened = False
def event_handler_quote_update(message):
global ltp
ltp = message['ltp']
print(f"quote update {message}")

def open_callback():
global socket_opened
socket_opened = True

alice.start_websocket(subscribe_callback=event_handler_quote_update,
socket_open_callback=open_callback,
run_in_background=True)
while(socket_opened==False):
pass
alice.subscribe(alice.get_instrument_by_symbol('BSE', 'ONGC'), LiveFeedType.MARKET_DATA)
while True:
print(ltp)
`

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented May 19, 2020

Don’t combine subscribe and get_instrument() when your scrip is new.
First find the scrip using get_instrument or search_instrument. And the subscribe.

@akashrajcashrayz

This comment has been minimized.

Copy link

akashrajcashrayz commented May 21, 2020

sir in basket order in BSE
it always execute trade in limit type not in market type
order2 = {"instrument": alice.get_instrument_by_symbol('BSE', f"{instru} A"),
"order_type": OrderType.Market,
"quantity": 1,
"transaction_type": TransactionType.Buy,
"product_type": ProductType.Intraday}

@akashrajcashrayz

This comment has been minimized.

Copy link

akashrajcashrayz commented May 22, 2020

what is the code for IOC type order?

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented May 24, 2020

There is no IOC available.

@Chawdavijay

This comment has been minimized.

Copy link

Chawdavijay commented May 27, 2020

Sir,
How can i add multiple stock in above strategy.
Where and what should I have to change..?

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented May 30, 2020

This is just an example, understand this example and create your own strategy/application.

@bhushanjawle

This comment has been minimized.

Copy link

bhushanjawle commented Jun 2, 2020

Thank you for this example code @krishnavelu. Clarifies entire flow.

@pavndutt

This comment has been minimized.

Copy link

pavndutt commented Jun 3, 2020

Sir, in 2fa variable what should i fill, i have 5 answers

@akashrajcashrayz

This comment has been minimized.

Copy link

akashrajcashrayz commented Jun 4, 2020

Sir, in 2fa variable what should i fill, i have 5 answers

u need to set all the answers again and this time u need to give "a " in all the answers
for example:- what is brand of your watch?
answer ; - a
in 2fa = 'a' it automatically answer 'a' for all questions which asked from you that's it

@mahendran8888

This comment has been minimized.

Copy link

mahendran8888 commented Jun 19, 2020

I am getting following error after I modify the program to my access token. How to resolve this.

DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): ant.aliceblueonline.com:443
DEBUG:urllib3.connectionpool:https://ant.aliceblueonline.com:443 "GET /api/v2/profile HTTP/1.1" 200 None
INFO:alice_blue.alice_blue:Downloading master contracts for exchange: NSE
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): ant.aliceblueonline.com:443
DEBUG:urllib3.connectionpool:https://ant.aliceblueonline.com:443 "GET /api/v2/contracts.json?exchanges=NSE HTTP/1.1" 200 None
INFO:alice_blue.alice_blue:Downloading master contracts for exchange: BSE
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): ant.aliceblueonline.com:443
DEBUG:urllib3.connectionpool:https://ant.aliceblueonline.com:443 "GET /api/v2/contracts.json?exchanges=BSE HTTP/1.1" 200 None

@mahendran8888

This comment has been minimized.

Copy link

mahendran8888 commented Jun 19, 2020

Thank you for your code Krishna velu, Thanks again.

@mahendran8888

This comment has been minimized.

Copy link

mahendran8888 commented Jun 23, 2020

Could you please make below logic for buy or sell signals where above program execute the buy sell order every minute.

(Prev_1min_SMA_5 <Prev_1min_SMA_20) & (SMA_5>SMA_20))
Buy Signal
(Prev_1min_SMA_5 >Prev_1min_SMA_20) & (SMA_5<SMA_20))
Sell Signal

@mahendran8888

This comment has been minimized.

Copy link

mahendran8888 commented Jun 23, 2020

INFY-EQNSE Buy MKT 1 0 10:20:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:19:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:18:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:17:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:16:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:15:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:14:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:13:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:12:57 Rejected
INFY-EQNSE Buy MKT 1 0 10:11:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:10:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:09:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:08:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:07:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:06:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:05:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:04:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:03:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:02:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:01:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:00:56 Rejected
INFY-EQNSE Sell MKT 1 0 9:59:56 Rejected
INFY-EQNSE Sell MKT 1 0 9:58:56 Rejected
INFY-EQNSE Buy MKT 1 0 9:57:56 Rejected
INFY-EQNSE Buy MKT 1 0 9:56:56 Rejected
INFY-EQNSE Buy MKT 1 0 9:55:56 Rejected
@mahendran8888

This comment has been minimized.

Copy link

mahendran8888 commented Jun 23, 2020

the given program executed correctly without error and need some logic correction as below if you need my suggestion

(Prev_1min_SMA_5 <Prev_1min_SMA_20) & (SMA_5>SMA_20))
Buy Signal
(Prev_1min_SMA_5 >Prev_1min_SMA_20) & (SMA_5<SMA_20))
Sell Signal

@mahendran8888

This comment has been minimized.

Copy link

mahendran8888 commented Jun 23, 2020

If you apply above said logic this will exactly work as an indicator works as I have tested my side with excel sheet, but this program executing buy sell orders every minute irrespective of actual required logic.

@mahendran8888

This comment has been minimized.

Copy link

mahendran8888 commented Jun 23, 2020

still the time program out put as below

    Type       Status
Symbol Qty Price Time
INFY-EQNSE Sell MKT 1 0 10:50:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:49:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:48:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:47:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:46:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:45:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:44:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:43:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:42:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:41:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:40:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:39:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:38:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:37:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:36:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:35:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:34:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:33:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:32:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:31:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:30:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:29:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:28:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:27:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:26:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:25:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:24:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:23:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:22:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:21:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:20:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:19:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:18:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:17:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:16:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:15:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:14:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:13:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:12:57 Rejected
INFY-EQNSE Buy MKT 1 0 10:11:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:10:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:09:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:08:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:07:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:06:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:05:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:04:56 Rejected
INFY-EQNSE Buy MKT 1 0 10:03:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:02:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:01:56 Rejected
INFY-EQNSE Sell MKT 1 0 10:00:56 Rejected
INFY-EQNSE Sell MKT 1 0 9:59:56 Rejected
INFY-EQNSE Sell MKT 1 0 9:58:56 Rejected
INFY-EQNSE Buy MKT 1 0 9:57:56 Rejected
INFY-EQNSE Buy MKT 1 0 9:56:56 Rejected
INFY-EQNSE Buy MKT 1 0 9:55:56 Rejected
@Chawdavijay

This comment has been minimized.

Copy link

Chawdavijay commented Jun 23, 2020

https://gist.github.com/krishnavelu/e0df312ccf5f022edb1823461ff4230e#gistcomment-3323865

@krishnavelu sir
I have tried to understand but unfortunately I can't understand where to add other stock names😔

It would be great help from you if guide me to where and what change can make me use this strategy in multiple stocks

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Jun 23, 2020

@Chawdavijay Learn python.

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Jun 23, 2020

@mahendran888 this is just an example strategy to demonstrate how to use this library and make out different strategies. Not for actual trading.

@Chawdavijay

This comment has been minimized.

Copy link

Chawdavijay commented Jun 23, 2020

https://gist.github.com/krishnavelu/e0df312ccf5f022edb1823461ff4230e#gistcomment-3351569

@krishnavelu
I'll learn python

But as of now can you please let me know how can i get net M2M profit of all stock which traded for the day.

@akashrajcashrayz

This comment has been minimized.

Copy link

akashrajcashrayz commented Jun 26, 2020

sir in basket order in BSE
it always execute trade in limit type not in market type
order2 = {"instrument": alice.get_instrument_by_symbol('BSE', f"{instru} A"),
"order_type": OrderType.Market,
"quantity": 1,
"transaction_type": TransactionType.Buy,
"product_type": ProductType.Intraday}

sir plz help me out with this

@akashrajcashrayz

This comment has been minimized.

Copy link

akashrajcashrayz commented Jun 26, 2020

sir it takes 2 second delay in trade after execution.is this normal?
and what is the minimum delay?

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Jun 28, 2020

execution time depends on multiple factors. You cannot determine.

@balramzc

This comment has been minimized.

Copy link

balramzc commented Jul 1, 2020

Sir,

Please give some code snippet for getting access token by checking market status message. Because while running my app in vps i need to get the access token automatically when the market opens the next day.

Can we get access token at about 8:50 or before 9:00

Thanks

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Jul 2, 2020

Do you know how to get access token?
If not read this document
Remaing is application part. You’ve to figure out yourself.

@yashpalsinha

This comment has been minimized.

Copy link

yashpalsinha commented Jul 2, 2020

Hello sir in every minute order is placing how can solve that
Help me

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Jul 3, 2020

Use the latest code. You won't get every minute order.

@yashpalsinha

This comment has been minimized.

Copy link

yashpalsinha commented Jul 3, 2020

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Jul 3, 2020

What is macd? and what is this example strategy's name? what is sma? what is ema?

@yashpalsinha

This comment has been minimized.

Copy link

yashpalsinha commented Jul 3, 2020

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Jul 3, 2020

That means, you know how to do it yourself.

@yashpalsinha

This comment has been minimized.

Copy link

yashpalsinha commented Jul 3, 2020

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Jul 3, 2020

So you don’t know programming and want to give full control of your money account to that program and lose everything?
Learn programming, learn python.

@yashpalsinha

This comment has been minimized.

Copy link

yashpalsinha commented Jul 3, 2020

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Jul 3, 2020

Learn python.

@mahendran8888

This comment has been minimized.

Copy link

mahendran8888 commented Jul 10, 2020

Krishna velu you can give small example to have multiple instruments with sma5 and sma20, same. This will help us to know where to do what. I have tried to use pandas and list but failed last two weeks.

@krishnavelu

This comment has been minimized.

Copy link
Owner Author

krishnavelu commented Jul 10, 2020

Learn python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.