greeksoft 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Greeksoft Technology Pvt Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.2
2
+ Name: greeksoft
3
+ Version: 0.0.1
4
+ Summary: GreekSoft Api Client use for trading purpose
5
+ Author: Greek_dev_Team
6
+ Author-email: greeksoftapi@greeksoft.co.in
7
+ License: MIT License
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: websocket>=0.2.1
11
+ Requires-Dist: requests>=2.32.3
12
+ Requires-Dist: pandas>=1.19.5
13
+ Requires-Dist: websockets>=14.2
14
+ Requires-Dist: websocket-client>=1.8.0
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: license
20
+ Dynamic: requires-dist
21
+ Dynamic: summary
22
+
23
+ # GreekSoft API
24
+ Greeksoft_API is a Python-based project that allows users to subscribe to the Greek token and retrieve the latest tick data. This project helps in authenticating a user, broadcasting tokens, and placing orders in a seamless manner.
25
+
26
+ # Features Authentication:
27
+ By passing a username, session password, and user password, the project authenticates the user.
28
+ # Token Retrieval:
29
+ Retrieves the latest token broadcast.
30
+ # Order Placement:
31
+ Capable of placing orders once authenticated.
32
+
33
+ # Technologies Used
34
+ Python built-in Libs & third party libs (Pandas, numpy,requests,etc.)
35
+ ```
36
+ pip install greeksoft
37
+ ```
38
+
39
+ Usage
40
+ Once installed, you can use the project by importing the Greek_API from the greek_api_client package. Below is an example of how to use the API:
41
+
42
+ ```
43
+ from greeksoft import Greek_API
44
+
45
+ username="username" # String Format
46
+
47
+ session_pwd="session_pwd" #String Format
48
+
49
+ user_pwd="user_pwd" #String Format
50
+
51
+ procli="procli" # for client id procli="2", retail id procli='1'
52
+
53
+ ac_no='ac_no' # if retail id pass account number in String Format.
54
+
55
+ api = Greek_API(username,session_pwd,user_pwd,procli,ac_no) #to authenticate the creadentials passed.
56
+
57
+ token_no='102000000' # string format
58
+
59
+ # Authenticate and fetch the latest token
60
+
61
+ token = api.token_broadcast('token_no','asset_type') # token_no in 'String', asset_type='option' or 'future' or 'equity' in string format.
62
+
63
+ # token=token['data.token'][0] <-- get token no
64
+
65
+ # symbol=token['data.symbol'][0] <-- get symbol name of token passed
66
+
67
+ # time=token['data.ltt'][0] <-- provide the time
68
+
69
+ # strike=token['data.strikeprice'][0] <-- get Strike
70
+
71
+ # option_type=token['data.optiontype'][0] <-- get Option type CE or PE
72
+
73
+ # instrument=token['data.instrument'][0] <-- get instrument type FUTSTK,OPTSTK...
74
+
75
+ # bid_price=token[data.bid][0] <-- get bid price of token passed
76
+
77
+ # ask_price=token['data.ask'][0] <-- get ask price of token passed
78
+
79
+
80
+ # Subscribe with the Greek Token and pass it in list eg:token_list=['','',...] into the declared variable.
81
+
82
+ token_list=['102000000','102000000',...] # Only pass Greek Token.
83
+
84
+ for data in api.get_apollo_resp(token_list): # To get response of tokens passed of list using loop.
85
+ print(data)
86
+
87
+ # Place order passing required paramets, # token_no='102000000', symbol="RELIANCE", qty="minimum_lot" for respective token,
88
+
89
+ # price= value get from bid/ask price from token broadcast against respective token,
90
+
91
+ #buysell= if buy then pass 1 and for sell 2 in integer format,
92
+
93
+ ordtype=1, trigprice=0, strategyname="example" strategy name will be anything as per userinput.
94
+
95
+ var_response=api.place_order(tokenno,symbol,qty,price,buysell,ordtype,trigprice,strategyname) # pass the required parameters
96
+
97
+ print(var_response) # acknowledge the response get from place order function.
98
+ ```
99
+
100
+ ## License
101
+
102
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
103
+
104
+
105
+
106
+
@@ -0,0 +1,84 @@
1
+ # GreekSoft API
2
+ Greeksoft_API is a Python-based project that allows users to subscribe to the Greek token and retrieve the latest tick data. This project helps in authenticating a user, broadcasting tokens, and placing orders in a seamless manner.
3
+
4
+ # Features Authentication:
5
+ By passing a username, session password, and user password, the project authenticates the user.
6
+ # Token Retrieval:
7
+ Retrieves the latest token broadcast.
8
+ # Order Placement:
9
+ Capable of placing orders once authenticated.
10
+
11
+ # Technologies Used
12
+ Python built-in Libs & third party libs (Pandas, numpy,requests,etc.)
13
+ ```
14
+ pip install greeksoft
15
+ ```
16
+
17
+ Usage
18
+ Once installed, you can use the project by importing the Greek_API from the greek_api_client package. Below is an example of how to use the API:
19
+
20
+ ```
21
+ from greeksoft import Greek_API
22
+
23
+ username="username" # String Format
24
+
25
+ session_pwd="session_pwd" #String Format
26
+
27
+ user_pwd="user_pwd" #String Format
28
+
29
+ procli="procli" # for client id procli="2", retail id procli='1'
30
+
31
+ ac_no='ac_no' # if retail id pass account number in String Format.
32
+
33
+ api = Greek_API(username,session_pwd,user_pwd,procli,ac_no) #to authenticate the creadentials passed.
34
+
35
+ token_no='102000000' # string format
36
+
37
+ # Authenticate and fetch the latest token
38
+
39
+ token = api.token_broadcast('token_no','asset_type') # token_no in 'String', asset_type='option' or 'future' or 'equity' in string format.
40
+
41
+ # token=token['data.token'][0] <-- get token no
42
+
43
+ # symbol=token['data.symbol'][0] <-- get symbol name of token passed
44
+
45
+ # time=token['data.ltt'][0] <-- provide the time
46
+
47
+ # strike=token['data.strikeprice'][0] <-- get Strike
48
+
49
+ # option_type=token['data.optiontype'][0] <-- get Option type CE or PE
50
+
51
+ # instrument=token['data.instrument'][0] <-- get instrument type FUTSTK,OPTSTK...
52
+
53
+ # bid_price=token[data.bid][0] <-- get bid price of token passed
54
+
55
+ # ask_price=token['data.ask'][0] <-- get ask price of token passed
56
+
57
+
58
+ # Subscribe with the Greek Token and pass it in list eg:token_list=['','',...] into the declared variable.
59
+
60
+ token_list=['102000000','102000000',...] # Only pass Greek Token.
61
+
62
+ for data in api.get_apollo_resp(token_list): # To get response of tokens passed of list using loop.
63
+ print(data)
64
+
65
+ # Place order passing required paramets, # token_no='102000000', symbol="RELIANCE", qty="minimum_lot" for respective token,
66
+
67
+ # price= value get from bid/ask price from token broadcast against respective token,
68
+
69
+ #buysell= if buy then pass 1 and for sell 2 in integer format,
70
+
71
+ ordtype=1, trigprice=0, strategyname="example" strategy name will be anything as per userinput.
72
+
73
+ var_response=api.place_order(tokenno,symbol,qty,price,buysell,ordtype,trigprice,strategyname) # pass the required parameters
74
+
75
+ print(var_response) # acknowledge the response get from place order function.
76
+ ```
77
+
78
+ ## License
79
+
80
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
81
+
82
+
83
+
84
+
@@ -0,0 +1 @@
1
+ from .greeksoftapi import GreekAPI
@@ -0,0 +1,369 @@
1
+ import pandas as pd
2
+ import requests as req
3
+ import hashlib
4
+ import base64
5
+ import json
6
+ import time
7
+ import threading as mt
8
+ import websocket as wb
9
+ import ssl
10
+
11
+ class GreekAPI:
12
+ def __init__(self, user,s_pwd, pwd,procli,ac_no):
13
+ self.username = user
14
+ self.session_pwd = s_pwd
15
+ self.userpwd = pwd
16
+ self.gscid = self.username
17
+ self.session_id = None
18
+ self.ws_apollo = None
19
+ self.procli=procli
20
+ self.url_session_token ='http://greekapi.greeksoft.in:3001'
21
+ self.is_secure=False
22
+ self.is_base64 = True
23
+ self.rest_ip = "dev.greeksoft.in"
24
+ self.rest_port = "3333"
25
+ self.session_token = self.get_session_token()
26
+ self.ac_no=ac_no
27
+ if self.is_secure :
28
+ self.ssl_verify = False
29
+ self.wbhd = "https://"
30
+ self.wshd = "wss://"
31
+ else:
32
+ self.ssl_verify = False
33
+ self.wbhd = "http://"
34
+ self.wshd = "ws://"
35
+ self.gcid=self.getlogininfo()
36
+ def base64_to_json(self, coded_string):
37
+ string = base64.b64decode(coded_string).decode('utf-8')
38
+ return json.loads(string)
39
+
40
+ def get_session_token(self):
41
+ url = f'{self.url_session_token}/auth/greek/sessiontoken'
42
+ myobj = {
43
+ "username": str(self.username),
44
+ "password": str(self.session_pwd),
45
+ "validFor": str("1d")
46
+ }
47
+
48
+ response = req.post(url, json=myobj)
49
+ response.raise_for_status() # Raise an error for bad responses
50
+
51
+ # Get the session token from the response
52
+ session_token = response.json().get('sessionToken')
53
+
54
+ return session_token
55
+
56
+ def json_to_base64(self, string):
57
+ string = json.dumps(string)
58
+ coded_string = base64.b64encode(string.encode('utf-8'))
59
+ coded_string = repr(coded_string)[2:-1]
60
+ return coded_string
61
+
62
+ def get_url(self,servicename):
63
+ svcname = servicename
64
+ url = self.wbhd+self.rest_ip+ ":"+self.rest_port+"/"+svcname
65
+ return url
66
+ def token_broadcast(self,tokenno, assettype):
67
+ gcid=self.getlogininfo()
68
+ params = {
69
+ "request": {
70
+ "data": {
71
+ "token": tokenno,
72
+ "assetType": assettype,
73
+ "gscid": str(self.username),
74
+ "gcid": str(gcid),
75
+ },
76
+ "svcName": "getQuoteForSingleSymbol_V2",
77
+ "svcGroup": "Markets"
78
+ }
79
+ }
80
+ params = self.json_to_base64(params)
81
+ stoken = self.session_token
82
+ headers = { "Authorization":""+str(stoken) ,"charset": "utf-8", "Content-Type": "application/json" }
83
+ svcname = "getQuoteForSingleSymbol_V2"
84
+ url_neworder = self.get_url(svcname)
85
+ y1 = req.post(url_neworder,data=params,headers=headers ,verify=self.ssl_verify )
86
+ y1 = y1.text
87
+ z1 = self.base64_to_json(y1)
88
+ df_broadcast_response = pd.json_normalize(z1['response'])
89
+ return df_broadcast_response
90
+
91
+ def getlogininfo(self):
92
+ svcname = "getLoginInfo"
93
+ url_getlogininfo = self.get_url(svcname)
94
+ stoken = self.session_token
95
+ headers = { "Authorization":""+str(stoken) ,"charset": "utf-8", "Content-Type": "application/json" }
96
+ svc_req = {
97
+ "request": {
98
+ "svcVersion": "1.0.0",
99
+ "svcGroup": "Login",
100
+ "svcName": "getlogininfo",
101
+ "assetType": "",
102
+ "data": {
103
+ "gscid": str(self.username)
104
+ }
105
+ }
106
+ }
107
+ if self.is_base64 :
108
+ svc_req = self.json_to_base64(svc_req)
109
+ svc_res = req.request("POST",url=url_getlogininfo,data=svc_req,headers=headers,verify=False )
110
+ if self.is_base64 :
111
+ svc_res = svc_res.text
112
+ svc_res = self.base64_to_json(svc_res)
113
+ # print(svc_res)
114
+ gcid = svc_res['response']['data']['gcid']
115
+ return gcid
116
+
117
+ def jlogin_new(self):
118
+ url_jloginnew = f"http://{self.rest_ip}:{self.rest_port}/jloginNew"
119
+ pwdhash = hashlib.md5(self.userpwd.encode()).hexdigest()
120
+ svc_req = {
121
+ "request": {
122
+ "data": {
123
+ "gscid": str(self.username),
124
+ "deviceDetails": "",
125
+ "deviceType": "0",
126
+ "pass": str(pwdhash),
127
+ "transPass": "",
128
+ "userType": "Customer",
129
+ "brokerid": "1",
130
+ "passType": "0",
131
+ "version_no": "1.0.1.10",
132
+ "encryptionType": "1"
133
+ },
134
+ "svcName": "jloginNew",
135
+ "svcGroup": "Login"
136
+ }
137
+ }
138
+
139
+ if self.is_base64:
140
+ svc_req = self.json_to_base64(svc_req)
141
+
142
+ headers = {"Authorization": self.session_token, "charset": "utf-8", "Content-Type": "application/json"}
143
+ svc_res = req.post(url_jloginnew, data=svc_req, headers=headers, verify=False)
144
+ if self.is_base64:
145
+ svc_res = self.base64_to_json(svc_res.text)
146
+
147
+ session_id = svc_res['response']['sessionId']
148
+ self.session_id=session_id
149
+ websocket_broadcast_ip = svc_res['response']['data']['Apollo_IP']
150
+ websocket_broadcast_port = svc_res['response']['data']['Apollo_Port']
151
+ websocket_order_ip = svc_res['response']['data']['Iris_IP']
152
+ return session_id, websocket_broadcast_ip, websocket_broadcast_port, websocket_order_ip
153
+
154
+ def Net_Position_Details_strategywise(self):
155
+ svcname = "getStrategyNameWiseNetPositionDetail?"
156
+ url_neworder = self.get_url(svcname)
157
+ #ord_status = req.get(f"{url_neworder}/{ord_id}")
158
+ text = "gscid={}".format(str(self.username))
159
+
160
+ # text = text.replace('"', '')
161
+ # info = json_to_base64(text)
162
+ coded_string = base64.b64encode(text.encode('utf-8'))
163
+ coded_string = repr(coded_string)[2:-1]
164
+ info = url_neworder + coded_string
165
+
166
+
167
+ # params = {
168
+ # "request": {
169
+ # "FormFactor": "M",
170
+ # "data": {
171
+ # "gcid": str(gcid),
172
+ # "gscid": str(username)
173
+ # },
174
+ # "svcGroup": "portfolio",
175
+ # "svcVersion": "1.0.0",
176
+ # "streaming_type": str(svcname),
177
+ # "request_type": "subscribe"
178
+ # }
179
+ # }
180
+ # params = json_to_base64(params)
181
+ stoken = self.session_token
182
+ headers = { "Authorization":""+str(stoken) ,"charset": "utf-8", "Content-Type": "application/json" }
183
+ y1 = req.request("GET", info, headers=headers ,verify=self.ssl_verify )
184
+ y1 = y1.text
185
+ z1 = self.base64_to_json(y1)
186
+ response = z1
187
+
188
+ return response
189
+
190
+ def send_apollo_resp(self):
191
+ jln = self.jlogin_new()
192
+ session_id = jln[0]
193
+ # bgcid=self.get_gscid_and_stoken()
194
+ gcid=self.gcid
195
+ print(session_id)
196
+ # session_id = jln['response']['sessionId']
197
+ ws_apollo = wb.create_connection(f"ws://{self.rest_ip}:3032", sslopt={"cert_reqs": ssl.CERT_NONE})
198
+ self.ws_apollo=ws_apollo
199
+ apollo_login_req = {"request": {"data": {"gscid": str(self.username),"gcid": str(gcid),"sessionId": str(session_id),"device_type": "0"},"response_format": "json","request_type": "subscribe","streaming_type": "login"}}
200
+ apollo_login_req = self.json_to_base64(apollo_login_req)
201
+ ws_apollo.send( apollo_login_req )
202
+ apollo_login_res = ws_apollo.recv()
203
+ apollo_login_res = self.base64_to_json(apollo_login_res)
204
+ print("Apollo Login Response:", apollo_login_res)
205
+
206
+
207
+ t1 = mt.Thread( target=self.heartbeat_req)
208
+ t1.start()
209
+
210
+
211
+
212
+ def heartbeat_req(self):
213
+ gcid=self.gcid
214
+ ws_apollo = wb.create_connection(f"ws://{self.rest_ip}:3032", sslopt={"cert_reqs": ssl.CERT_NONE})
215
+
216
+ apollo_hb_req = {"request": {"data": {"gcid": str(gcid),"sessionId": str(self.session_id) },"response_format": "json","request_type": "subscribe","streaming_type": "HeartBeat"}}
217
+ apollo_hb_req = self.json_to_base64(apollo_hb_req)
218
+ while True:
219
+ ws_apollo.send( apollo_hb_req )
220
+ time.sleep(20)
221
+
222
+ def thread_function(self,stop_event):
223
+ while not stop_event.is_set():
224
+ apollo_res = self.base64_to_json(self.ws_apollo.recv())
225
+ service_name = apollo_res['response']['svcName']
226
+ streaming = apollo_res['response']['streaming_type']
227
+ if service_name == 'Broadcast' and streaming == 'marketPicture':
228
+ token = apollo_res['response']['data']['symbol']
229
+ # if s1_nifty["symbol"] == token:
230
+ # print("HI")
231
+ # "hi"
232
+
233
+ def subscribe_token(self, token):
234
+ apo_login=self.send_apollo_resp()
235
+ gcid=self.gcid
236
+ self.gscid=self.username
237
+ if self.gscid and self.session_id and len(token)<=50:
238
+ for tkn in token:
239
+ s1_nifty = {"symbol": str(tkn)}
240
+ apollo_subscribe_req_n = {
241
+ "request": {
242
+ "data": {
243
+ "symbols": [s1_nifty]
244
+ },
245
+ "response_format": "json",
246
+ "gscid": str(self.username),
247
+ "gcid": gcid, # Assuming gcid is the same as gscid for this example
248
+ "request_type": "subscribe",
249
+ "streaming_type": "marketPicture"
250
+ }
251
+ }
252
+ apollo_subscribe_req_n = self.json_to_base64(apollo_subscribe_req_n)
253
+ self.ws_apollo.send(apollo_subscribe_req_n)
254
+ print(f"Subscribed to token: {tkn}")
255
+ else:
256
+ print("Cannot subscribe. Session ID or GCID is not set.")
257
+
258
+ def unsubscribe_token(self,token):
259
+ gcid=self.gcid
260
+ username=self.username
261
+ if gcid and username:
262
+ s1_nifty = {"symbol": str(token)}
263
+ apollo_unsubscribe_req_n={
264
+ "request": {
265
+ "data": {
266
+ "symbols": [
267
+ {
268
+ "symbol": [s1_nifty]
269
+ }
270
+ ]
271
+ },
272
+ "response_format": "json",
273
+ "gscid": str(self.username),
274
+ "gcid": gcid,
275
+ "request_type": "unsubscribe",
276
+ "streaming_type": "marketPicture"
277
+ }
278
+ }
279
+ apollo_unsubscribe_req_n = self.json_to_base64(apollo_unsubscribe_req_n)
280
+ self.ws_apollo.send(apollo_unsubscribe_req_n)
281
+ return f"UnSubscribed to token: {token}"
282
+
283
+
284
+ def get_apollo_resp(self,token,req_data):
285
+ subs=self.subscribe_token(token)
286
+ while True:
287
+ apollo_res = self.ws_apollo.recv()
288
+ apollo_res = self.base64_to_json(apollo_res)
289
+ service_name = apollo_res['response']['svcName']
290
+ streaming = apollo_res['response']['streaming_type']
291
+ if service_name == 'Broadcast' and streaming == 'marketPicture':
292
+ # print("Market Picture Data:", apollo_res['response']['data'])
293
+ tkn=apollo_res['response']['data']['symbol']
294
+ sym=apollo_res['response']['data']['name']
295
+ ltp=apollo_res['response']['data']['ltp']
296
+ ltt=apollo_res['response']['data']['ltt']
297
+ bid=apollo_res['response']['data']['bid']
298
+ ask=apollo_res['response']['data']['ask']
299
+ depth=apollo_res['response']['data']['level2']
300
+ app_res=apollo_res['response']['data']
301
+ if req_data =='depth':
302
+ yield tkn,sym,depth,ltt
303
+ elif req_data =='ask/bid':
304
+ yield tkn,sym,bid,ask,ltt
305
+ elif req_data=='allresp':
306
+ yield app_res
307
+ else:
308
+ yield tkn,sym,ltp,ltt
309
+ # time.sleep(0.5)
310
+
311
+
312
+ def place_order(self,tokenno,symbol,lot,qty,price,buysell,ordtype,trigprice,strategyname):
313
+ gcid=self.gcid
314
+ params = {
315
+ "request": {
316
+ "data": {
317
+ "trigger_price": str(trigprice),
318
+ "gtoken": str(tokenno),
319
+ "side": str(buysell),
320
+ "gcid": str(gcid),
321
+ "validity": "0",
322
+ "price": str(price),
323
+ "exchange": "NSE",
324
+ "disclosed_qty": "0",
325
+ "tradeSymbol": str(symbol),
326
+ "lot": str(lot),
327
+ "iprocli":str(self.procli),
328
+ "order_type": str(ordtype),
329
+ "product": "0",
330
+ "qty": str(qty),
331
+ "corderid": "3",
332
+ "amo": "0",
333
+ "AccountNumber":str(self.ac_no),
334
+ "is_restapi":"1",
335
+ "gtdExpiry": 0,
336
+ "is_post_closed": "0",
337
+ "is_preopen_order": "0",
338
+ "isSqOffOrder": "false",
339
+ "offline": "0",
340
+ "strategyName":str(strategyname),
341
+ "strategyNo":"124"
342
+ },
343
+ "response_format": "json",
344
+ "request_type": "subscribe",
345
+ "streaming_type": "NewOrderRequest"
346
+ }
347
+ }
348
+
349
+ if self.procli != "1":
350
+ # Remove 'AccountNumber' and 'is_restapi' from the data dictionary if procli is not "1"
351
+ del params["request"]["data"]["AccountNumber"]
352
+ del params["request"]["data"]["is_restapi"]
353
+
354
+ params = self.json_to_base64(params)
355
+ stoken = self.get_session_token()
356
+ headers = { "Authorization":""+str(stoken) ,"charset": "utf-8", "Content-Type": "application/json" }
357
+ svcname = "NewOrderRequest"
358
+ url_neworder = self.get_url(svcname)
359
+ y1 = req.post(url_neworder,data=params,headers=headers ,verify=self.ssl_verify )
360
+ y1 = y1.text
361
+ z1 = self.base64_to_json(y1)
362
+ df_order_response = pd.json_normalize(z1['response'])
363
+ return df_order_response
364
+
365
+
366
+ def close_connection(self):
367
+ if self.ws_apollo:
368
+ self.ws_apollo.close()
369
+ print("WebSocket connection closed.")
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.2
2
+ Name: greeksoft
3
+ Version: 0.0.1
4
+ Summary: GreekSoft Api Client use for trading purpose
5
+ Author: Greek_dev_Team
6
+ Author-email: greeksoftapi@greeksoft.co.in
7
+ License: MIT License
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: websocket>=0.2.1
11
+ Requires-Dist: requests>=2.32.3
12
+ Requires-Dist: pandas>=1.19.5
13
+ Requires-Dist: websockets>=14.2
14
+ Requires-Dist: websocket-client>=1.8.0
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: license
20
+ Dynamic: requires-dist
21
+ Dynamic: summary
22
+
23
+ # GreekSoft API
24
+ Greeksoft_API is a Python-based project that allows users to subscribe to the Greek token and retrieve the latest tick data. This project helps in authenticating a user, broadcasting tokens, and placing orders in a seamless manner.
25
+
26
+ # Features Authentication:
27
+ By passing a username, session password, and user password, the project authenticates the user.
28
+ # Token Retrieval:
29
+ Retrieves the latest token broadcast.
30
+ # Order Placement:
31
+ Capable of placing orders once authenticated.
32
+
33
+ # Technologies Used
34
+ Python built-in Libs & third party libs (Pandas, numpy,requests,etc.)
35
+ ```
36
+ pip install greeksoft
37
+ ```
38
+
39
+ Usage
40
+ Once installed, you can use the project by importing the Greek_API from the greek_api_client package. Below is an example of how to use the API:
41
+
42
+ ```
43
+ from greeksoft import Greek_API
44
+
45
+ username="username" # String Format
46
+
47
+ session_pwd="session_pwd" #String Format
48
+
49
+ user_pwd="user_pwd" #String Format
50
+
51
+ procli="procli" # for client id procli="2", retail id procli='1'
52
+
53
+ ac_no='ac_no' # if retail id pass account number in String Format.
54
+
55
+ api = Greek_API(username,session_pwd,user_pwd,procli,ac_no) #to authenticate the creadentials passed.
56
+
57
+ token_no='102000000' # string format
58
+
59
+ # Authenticate and fetch the latest token
60
+
61
+ token = api.token_broadcast('token_no','asset_type') # token_no in 'String', asset_type='option' or 'future' or 'equity' in string format.
62
+
63
+ # token=token['data.token'][0] <-- get token no
64
+
65
+ # symbol=token['data.symbol'][0] <-- get symbol name of token passed
66
+
67
+ # time=token['data.ltt'][0] <-- provide the time
68
+
69
+ # strike=token['data.strikeprice'][0] <-- get Strike
70
+
71
+ # option_type=token['data.optiontype'][0] <-- get Option type CE or PE
72
+
73
+ # instrument=token['data.instrument'][0] <-- get instrument type FUTSTK,OPTSTK...
74
+
75
+ # bid_price=token[data.bid][0] <-- get bid price of token passed
76
+
77
+ # ask_price=token['data.ask'][0] <-- get ask price of token passed
78
+
79
+
80
+ # Subscribe with the Greek Token and pass it in list eg:token_list=['','',...] into the declared variable.
81
+
82
+ token_list=['102000000','102000000',...] # Only pass Greek Token.
83
+
84
+ for data in api.get_apollo_resp(token_list): # To get response of tokens passed of list using loop.
85
+ print(data)
86
+
87
+ # Place order passing required paramets, # token_no='102000000', symbol="RELIANCE", qty="minimum_lot" for respective token,
88
+
89
+ # price= value get from bid/ask price from token broadcast against respective token,
90
+
91
+ #buysell= if buy then pass 1 and for sell 2 in integer format,
92
+
93
+ ordtype=1, trigprice=0, strategyname="example" strategy name will be anything as per userinput.
94
+
95
+ var_response=api.place_order(tokenno,symbol,qty,price,buysell,ordtype,trigprice,strategyname) # pass the required parameters
96
+
97
+ print(var_response) # acknowledge the response get from place order function.
98
+ ```
99
+
100
+ ## License
101
+
102
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
103
+
104
+
105
+
106
+
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ greeksoft/__init__.py
5
+ greeksoft/greeksoftapi.py
6
+ greeksoft.egg-info/PKG-INFO
7
+ greeksoft.egg-info/SOURCES.txt
8
+ greeksoft.egg-info/dependency_links.txt
9
+ greeksoft.egg-info/requires.txt
10
+ greeksoft.egg-info/top_level.txt
@@ -0,0 +1,5 @@
1
+ websocket>=0.2.1
2
+ requests>=2.32.3
3
+ pandas>=1.19.5
4
+ websockets>=14.2
5
+ websocket-client>=1.8.0
@@ -0,0 +1 @@
1
+ greeksoft
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,25 @@
1
+ import pathlib
2
+ from platform import python_version
3
+
4
+ from setuptools import setup,find_packages
5
+
6
+ setup(name="greeksoft",
7
+ version='0.0.1',
8
+ description="GreekSoft Api Client use for trading purpose",
9
+ long_description=pathlib.Path("README.md").read_text(),
10
+ long_description_content_type='text/markdown',
11
+ author="Greek_dev_Team",
12
+ author_email='greeksoftapi@greeksoft.co.in',
13
+ license="MIT License",
14
+ packages=find_packages(),
15
+ install_requires=[
16
+ 'websocket>=0.2.1',
17
+ 'requests>=2.32.3',
18
+ 'pandas>=1.19.5',
19
+ 'websockets>=14.2',
20
+ 'websocket-client>=1.8.0'
21
+ ],
22
+ python_version="=>3.10",
23
+ include_package_data=True,
24
+
25
+ )