jgtfx2console 0.4.4__py3-none-any.whl → 0.4.17__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
jgtfx2console/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2023 Jean Guillaume Isabelle
1
+ # Copyright 2024 Jean Guillaume Isabelle
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -42,6 +42,6 @@ with warnings.catch_warnings():
42
42
  # your code here
43
43
 
44
44
 
45
- __version__ = "0.4.4"
45
+ __version__ = "0.4.17"
46
46
 
47
47
 
@@ -43,7 +43,7 @@ connection = os.getenv('connection')
43
43
  quotes_count = os.getenv('quotes_count')
44
44
 
45
45
  #from jgtpy import jgtcommon as jgtcomm,iprops
46
- from jgtutils import jgtcommon as jgtcomm,iprops
46
+ from jgtutils import jgtcommon as jgtcomm,iprops,jgtconstants as c
47
47
 
48
48
  ##import jgtcommon as jgtcomm,iprops
49
49
 
@@ -63,6 +63,7 @@ def parse_args():
63
63
  jgtcomm.add_tlid_range_argument(parser)
64
64
  #jgtcomm.add_date_arguments(parser)
65
65
  jgtcomm.add_max_bars_arguments(parser)
66
+ jgtcomm.add_keepbidask_argument(parser)
66
67
  args = parser.parse_args()
67
68
  return args
68
69
 
@@ -72,6 +73,13 @@ def main():
72
73
  str_user_id = user_id#args.l
73
74
  str_password = password#args.p
74
75
  str_url = url#args.u
76
+
77
+ keep_bid_ask = args.keepbidask
78
+
79
+ #env variable bypass if env exist JGT_KEEP_BID_ASK=1, keep_bid_ask = True
80
+ if os.getenv("JGT_KEEP_BID_ASK","0") == "1":
81
+ keep_bid_ask = True
82
+
75
83
  using_tlid = False
76
84
  if args.tlidrange is not None:
77
85
  using_tlid= True
@@ -120,10 +128,15 @@ def main():
120
128
  print("{0:s}, {1:,.5f}, {2:,.5f}".format(
121
129
  pd.to_datetime(str(row['Date'])).strftime(date_format), row['Bid'], row['Ask']))
122
130
  else:
123
- print("Date, Open, High, Low, Close, Median, Volume")
131
+ csv_header_OHLC = "Date,Open,High,Low,Close,Median,Volume"
132
+ csv_header_OHLCBIDASK="Date,BidOpen,BidHigh,BidLow,BidClose,AskOpen,AskHigh,AskLow,AskClose,Volume,Open,High,Low,Close,Median"
133
+ csv_header=csv_header_OHLC
134
+ if keep_bid_ask:
135
+ csv_header=csv_header_OHLCBIDASK
136
+ print(csv_header)
124
137
  rounder = lpip+1
125
138
  for row in history:
126
- print(format_output(rounder,row,rounder,date_format))
139
+ print(format_output(rounder,row,rounder,date_format,keep_bid_ask=keep_bid_ask))
127
140
 
128
141
  # print("{0:s},{1:.5f},{2:.5f},{3:.5f},{4:.5f},{5:.5f},{6:d}".format(
129
142
  # pd.to_datetime(str(row['Date'])).strftime(date_format), open_price, high_price,
@@ -135,15 +148,20 @@ def main():
135
148
  except Exception as e:
136
149
  jgtcomm.print_exception(e)
137
150
 
138
- def format_output(nb_decimal, row, rounder, date_format = '%Y-%m-%d %H:%M:%S'):
139
- open_price = round(((row['BidOpen'] + row['AskOpen']) / 2), rounder)
140
- high_price = round(((row['BidHigh'] + row['AskHigh']) / 2), rounder)
141
- low_price = round(((row['BidLow'] + row['AskLow']) / 2), rounder)
142
- close_price = round(((row['BidClose'] + row['AskClose']) / 2), rounder)
151
+ def format_output(nb_decimal, row, rounder, date_format = '%Y-%m-%d %H:%M:%S',keep_bid_ask=False):
152
+ open_price = round(((row[c.BIDOPEN] + row[c.ASKOPEN]) / 2), rounder)
153
+ high_price = round(((row[c.BIDHIGH] + row[c.ASKHIGH]) / 2), rounder)
154
+ low_price = round(((row[c.BIDLOW] + row[c.ASKLOW]) / 2), rounder)
155
+ close_price = round(((row[c.BIDCLOSE] + row[c.ASKCLOSE]) / 2), rounder)
143
156
  median = round(((high_price + low_price) / 2), rounder)
144
- dt_formatted=pd.to_datetime(str(row['Date'])).strftime(date_format)
157
+ dt_formatted=pd.to_datetime(str(row[c.DATE])).strftime(date_format)
145
158
  #print("dt formatted: " + dt_formatted)
146
- formatted_string = f"{dt_formatted},{open_price:.{nb_decimal}f},{high_price:.{nb_decimal}f},{low_price:.{nb_decimal}f},{close_price:.{nb_decimal}f},{median:.{nb_decimal}f},{row['Volume']:d}"
159
+ #if keep_bid_ask:Date,BidOpen,BidHigh,BidLow,BidClose,AskOpen,AskHigh,AskLow,AskClose,Volume,Open,High,Low,Close,Median
160
+ if keep_bid_ask:
161
+ formatted_string = f"{dt_formatted},{row[c.BIDOPEN]:.{nb_decimal}f},{row[c.BIDHIGH]:.{nb_decimal}f},{row[c.BIDLOW]:.{nb_decimal}f},{row[c.BIDCLOSE]:.{nb_decimal}f},{row[c.ASKOPEN]:.{nb_decimal}f},{row[c.ASKHIGH]:.{nb_decimal}f},{row[c.ASKLOW]:.{nb_decimal}f},{row[c.ASKCLOSE]:.{nb_decimal}f},{row[c.VOLUME]:d},{open_price:.{nb_decimal}f},{high_price:.{nb_decimal}f},{low_price:.{nb_decimal}f},{close_price:.{nb_decimal}f},{median:.{nb_decimal}f}"
162
+ else:
163
+ formatted_string = f"{dt_formatted},{open_price:.{nb_decimal}f},{high_price:.{nb_decimal}f},{low_price:.{nb_decimal}f},{close_price:.{nb_decimal}f},{median:.{nb_decimal}f},{row['Volume']:d}"
164
+
147
165
  return formatted_string
148
166
 
149
167
  def format_output1(nb_decimal, row, rounder,date_format = '%Y-%m-%d %H:%M:%S'):
@@ -1,14 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jgtfx2console
3
- Version: 0.4.4
3
+ Version: 0.4.17
4
4
  Summary: PDS Services
5
5
  Home-page: https://github.com/jgwill/jgtfx2console
6
6
  Author: GUillaume Isabelle
7
7
  Author-email: Guillaume Isabelle <jgi@jgwill.com>
8
- License: MIT
9
8
  Project-URL: Homepage, https://github.com/jgwill/jgtfx2console
10
9
  Project-URL: Bug Tracker, https://github.com/jgwill/jgtfx2console/issues
11
- Keywords: data
12
10
  Classifier: Programming Language :: Python :: 3
13
11
  Classifier: License :: OSI Approved :: MIT License
14
12
  Classifier: Operating System :: OS Independent
@@ -17,9 +15,8 @@ Description-Content-Type: text/markdown
17
15
  License-File: LICENSE
18
16
  Requires-Dist: pandas >=0.25.1
19
17
  Requires-Dist: python-dotenv >=0.19.2
20
- Requires-Dist: jgtutils >=0.1.38
18
+ Requires-Dist: jgtutils >=0.1.67
21
19
  Requires-Dist: tlid
22
- Requires-Dist: flask
23
20
  Provides-Extra: dev
24
21
  Requires-Dist: flake8 <3.7.0,>=3.6.0 ; extra == 'dev'
25
22
  Requires-Dist: isort <4.4.0,>=4.3.4 ; extra == 'dev'
@@ -1,5 +1,5 @@
1
- jgtfx2console/__init__.py,sha256=gC3JXMdLTNI_CS3mG6wBHEMqNdMyWlD66TGD_uT77S8,1610
2
- jgtfx2console/fxcli2console.py,sha256=rq6LQ2PBanrxWOWUKYdF_nVp3Oj3cXV8ils3AvfOwu4,6180
1
+ jgtfx2console/__init__.py,sha256=x1KH4rgWBuGLrNsvCAytY9Ju4s2tLTibHP-0EN01gqg,1611
2
+ jgtfx2console/fxcli2console.py,sha256=oI4d01jkXNriP2tF8aHcdep_r2YORWMfSnysrIHEAqQ,7426
3
3
  jgtfx2console/forexconnect/EachRowListener.py,sha256=jbRaSqhHtoaRnEnLGoUmVLvE6VPt-WXYtglRPzK440k,1649
4
4
  jgtfx2console/forexconnect/ForexConnect.py,sha256=Yf6AcLdgMSD8rd1s2DTIJPfzJ7BljIaZy_8vTfPfSOI,25755
5
5
  jgtfx2console/forexconnect/LiveHistory.py,sha256=saGkZ8ZUWRclcusG1vg12H4flpQWXKIMXCdQ5qM5cOo,9925
@@ -29,9 +29,9 @@ jgtfx2console/forexconnect/lib/linux/libpython3.7m.so,sha256=UQzwU5QcaVnwQdt2yXi
29
29
  jgtfx2console/forexconnect/lib/linux/libquotesmgr2.so.2.8,sha256=QIUMvjI-4m3YX3N23Pad9TIhYbmk17raTTW0gyrElkM,1245248
30
30
  jgtfx2console/forexconnect/lib/linux/libsqlite3.8.so,sha256=aqjV6ZcluDkzyr_bbWQCOHt9uitLvp7uPS-53Z3toQk,641120
31
31
  jgtfx2console/forexconnect/lib/linux/requirements.txt,sha256=62zntle4oq_jlsvrAK1bbfgYvAcRPtVHkGYu_eWiRZs,77
32
- jgtfx2console-0.4.4.dist-info/LICENSE,sha256=uCA_HysYVK9qIMbDEFjcDYhCoKTg19AJhKhM71EKSGA,1086
33
- jgtfx2console-0.4.4.dist-info/METADATA,sha256=gCalRCtL4EXb1Qwis7SS0SoeTXwd-IezldBK4u4qFOo,2249
34
- jgtfx2console-0.4.4.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
35
- jgtfx2console-0.4.4.dist-info/entry_points.txt,sha256=Jm1hD4oYLEKFNd6w7Ky7saQnSZGgbh6IEI7rpqCuMVs,67
36
- jgtfx2console-0.4.4.dist-info/top_level.txt,sha256=PBNCBgqX42I7ctUTX9FcTnIX0utvgRqzuflefzZ30D8,14
37
- jgtfx2console-0.4.4.dist-info/RECORD,,
32
+ jgtfx2console-0.4.17.dist-info/LICENSE,sha256=uCA_HysYVK9qIMbDEFjcDYhCoKTg19AJhKhM71EKSGA,1086
33
+ jgtfx2console-0.4.17.dist-info/METADATA,sha256=ldlSfmkt0Cfz0jqlka2M1_j40Vbx3TYokLtwxGOzkZg,2201
34
+ jgtfx2console-0.4.17.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
35
+ jgtfx2console-0.4.17.dist-info/entry_points.txt,sha256=Jm1hD4oYLEKFNd6w7Ky7saQnSZGgbh6IEI7rpqCuMVs,67
36
+ jgtfx2console-0.4.17.dist-info/top_level.txt,sha256=PBNCBgqX42I7ctUTX9FcTnIX0utvgRqzuflefzZ30D8,14
37
+ jgtfx2console-0.4.17.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5