Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fetch methods to get orders, positions, holdings, quote and LTP of stocks #41

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,7 @@ FodyWeavers.xsd
/IntelliTrader/output/request_token.txt
/IntelliTrader/output/bse_instruments.csv
/IntelliTrader/output
/IntelliTrader/src/output/access_token_2123.txt
/IntelliTrader/src/output/request_token_2123.txt
/IntelliTrader/src/output/access_token_2108.txt
/IntelliTrader/src/output/request_token_2108.txt
2 changes: 1 addition & 1 deletion IntelliTrader/IntelliTrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@

help = Helper(connection_kit)
fetch = Fetch(connection_kit)
orders = Orders(connection_kit)
orders = Orders(connection_kit)
96 changes: 54 additions & 42 deletions IntelliTrader/Notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ minute : 60 days
day : 2000 days


#variety
# regular Regular order
# amo After Market Order
# co Cover Order ?
# iceberg Iceberg Order ?
# auction Auction Order ?
variety
regular Regular order
amo After Market Order
co Cover Order ?
iceberg Iceberg Order ?
auction Auction Order ?


#order_type
# MARKET Market order
# LIMIT Limit order
# SL Stoploss order ?
# SL-M Stoploss-market order ?
order_type
MARKET Market order
LIMIT Limit order
SL Stoploss order ?
SL-M Stoploss-market order ?

#product
# CNC Cash & Carry for equity ?
# NRML Normal for futures and options ?
# MIS Margin Intraday Squareoff for futures and options ?
product
CNC Cash & Carry for equity ?
NRML Normal for futures and options ?
MIS Margin Intraday Squareoff for futures and options ?

if transaction == 'buy':
transaction_type = self.prop['kite'].TRANSACTION_TYPE_BUY
Expand All @@ -55,30 +55,42 @@ else:
self.prop['log'].error("The order placement does not have a specified action to buy or sell.")
exit()

#order_single = [{
# "exchange":exchange,
# "tradingsymbol": symbol,
# "transaction_type": self.prop['kite'].transaction,
# "quantity": quantity,
# "order_type": otype,
# "product": product,
# "price": price,
#}]

#order_oco = [{
# "exchange":"NSE",
# "tradingsymbol": "SBIN",
# "transaction_type": self.prop['kite'].transaction,
# "quantity": 1,
# "order_type": "LIMIT",
# "product": "CNC",
# "price": price
# },{
# "exchange":"NSE",
# "tradingsymbol": "SBIN",
# "transaction_type": self.prop['kite'].TRANSACTION_TYPE_SELL,
# "quantity": 1,
# "order_type": "LIMIT",
# "product": "CNC",
# "price": 480
#}]
order_single = [{
"exchange":exchange,
"tradingsymbol": symbol,
"transaction_type": self.prop['kite'].transaction,
"quantity": quantity,
"order_type": otype,
"product": product,
"price": price,
}]

order_oco = [{
"exchange":"NSE",
"tradingsymbol": "SBIN",
"transaction_type": self.prop['kite'].transaction,
"quantity": 1,
"order_type": "LIMIT",
"product": "CNC",
"price": price
},{
"exchange":"NSE",
"tradingsymbol": "SBIN",
"transaction_type": self.prop['kite'].TRANSACTION_TYPE_SELL,
"quantity": 1,
"order_type": "LIMIT",
"product": "CNC",
"price": 480
}]


res = fetch.fetch_quote('NSE', 'AAVAS')

res = fetch.fetch_ltp('NSE', 'AAVAS')

res = fetch.fetch_positions()

res = fetch.fetch_holdings()

res = fetch.fetch_orders()
logging.info(res)
24 changes: 23 additions & 1 deletion IntelliTrader/src/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,27 @@ def fetch_ohlc_extended(self, exchange, symbol, period_start, interval):
Helper.write_csv_output('historical_' + exchange + '_' + symbol + '_' + str(lookback_period_threshold) + '.csv', data)
return data

# Fetch quote
def fetch_quote(self, exchange, symbol):
quote = self.prop['kite'].quote(exchange+':'+symbol)
return quote


# Fetchltp
def fetch_ltp(self, exchange, symbol):
last_traded_price = self.prop['kite'].ltp(exchange+':'+symbol)
return last_traded_price

# Fetch orders
def fetch_orders(self):
orders = self.prop['kite'].orders()
return orders

# Fetch positions
def fetch_positions(self):
positions = self.prop['kite'].positions()
return positions

# Fetch holdings
def fetch_holdings(self):
holdings = self.prop['kite'].holdings()
return holdings
1 change: 0 additions & 1 deletion IntelliTrader/src/output/access_token_2108.txt

This file was deleted.

1 change: 0 additions & 1 deletion IntelliTrader/src/output/request_token_2108.txt

This file was deleted.