-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from upstox/v3-websocket
init commit for v3 websocket
- Loading branch information
Showing
12 changed files
with
729 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
access_token = "" | ||
access_token = "" | ||
|
||
|
||
sample_instrument_key = [ | ||
"NSE_EQ|INE528G01035", "NSE_EQ|INE399C01030", "BSE_EQ|INE055E01034", "NCD_FO|14245", "NSE_EQ|INE169A01031", | ||
"NSE_EQ|INE437A01024", "NSE_EQ|INE044A01036", "NSE_EQ|INE868B01028", "NSE_EQ|INE202E08219", "NSE_EQ|INE044A01036", | ||
"NSE_EQ|INE257A01026", "NSE_EQ|INE155A01022", "BSE_EQ|INE040A08575", "BSE_EQ|INE040A08567", "NSE_EQ|INE084A01016", | ||
"NSE_EQ|INE121A01024", "NSE_EQ|INE0OGZ15015", "BSE_EQ|INE0OGZ15015", "NSE_EQ|INE364U01010", "NSE_EQ|INE765G01017", | ||
"NSE_EQ|INE239A01024", "BSE_EQ|INE721A07SI5", "NSE_EQ|INE832A01018", "NSE_EQ|INE127D01025", "BCD_FO|2119087", | ||
"BSE_EQ|IN2920210480", "NSE_EQ|INE726G01019", "NSE_FO|114127", "NSE_EQ|INE340Z01019", "NSE_FO|114126", | ||
"NSE_FO|114125", "NSE_FO|114128", "NSE_EQ|IN2120230163", "NSE_FO|38516", "NSE_FO|114133", "NSE_FO|114132", | ||
"BSE_EQ|INE338I14GR3", "BSE_EQ|INE360L01017", "MCX_FO|431658", "MCX_FO|431657", "BSE_EQ|INE896W08020", | ||
"MCX_FO|431656", "BSE_EQ|INE214D01021", "NSE_EQ|IN4920240186", "NSE_EQ|INF789F01GW9", "NSE_EQ|INE0CJF01024", | ||
"NSE_EQ|IN2120230189", "BSE_EQ|INE896W08012", "MCX_FO|431668", "MCX_FO|431667", "MCX_FO|431666", | ||
"BSE_EQ|IN001129C021", "NSE_EQ|IN4920240194", "NSE_EQ|INE389Z07054", "BSE_EQ|INE748A01016", "BSE_EQ|IN000942C036", | ||
"BSE_EQ|INE148I07SM6", "NSE_EQ|INF789F01GV1", "NSE_EQ|INE128A01029", "NSE_EQ|IN2120230197", "NSE_FO|128727", | ||
"NSE_FO|128726", "NSE_FO|128729", "NSE_FO|128728", "BSE_EQ|INE03W107090", "BSE_EQ|INE148I07RY3", | ||
"BSE_EQ|INE651J07689", "BSE_FO|1172370", "BSE_FO|1172372", "BSE_FO|1172375", "NSE_EQ|IN2220230022", | ||
"NSE_EQ|INE508G01029", "NSE_FO|114077", "NSE_FO|114078", "NSE_FO|114079", "NSE_FO|114080", "NSE_FO|114081", | ||
"NSE_FO|38584", "NSE_FO|38585", "NSE_FO|38591", "NSE_FO|38592", "NSE_FO|38599" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import upstox_client | ||
import data_token | ||
|
||
configuration = upstox_client.Configuration() | ||
configuration.access_token = data_token.access_token | ||
instruments = data_token.sample_instrument_key | ||
streamer = upstox_client.MarketDataStreamerV3( | ||
upstox_client.ApiClient(configuration), instrumentKeys=instruments[0:70], mode="option_greeks") | ||
|
||
streamer.auto_reconnect(True, 5, 10) | ||
|
||
|
||
def on_open(): | ||
print("on open message") | ||
|
||
|
||
def close(a, b): | ||
print(f"on close message {a}") | ||
|
||
|
||
def message(data): | ||
print(f"on message message{data}") | ||
|
||
|
||
def error(er): | ||
print(f"on error message= {er}") | ||
|
||
|
||
def reconnecting(data): | ||
print(f"reconnecting event= {data}") | ||
|
||
|
||
streamer.on("open", on_open) | ||
streamer.on("message", message) | ||
streamer.on("close", close) | ||
streamer.on("reconnecting", reconnecting) | ||
streamer.on("error", error) | ||
streamer.connect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.