jgtfx2console 0.4.27__py3-none-any.whl → 0.5.15__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. jgtfx2console/LiveChartDataExport.py +2 -2
  2. jgtfx2console/__init__.py +1 -1
  3. jgtfx2console/common_samples/BatchOrderMonitor.py +84 -0
  4. jgtfx2console/common_samples/OrderMonitor.py +171 -0
  5. jgtfx2console/common_samples/OrderMonitorNetting.py +195 -0
  6. jgtfx2console/common_samples/TableListenerContainer.py +197 -0
  7. jgtfx2console/common_samples/__init__.py +23 -0
  8. jgtfx2console/common_samples/common.py +219 -0
  9. jgtfx2console/config_generator.py +12 -5
  10. jgtfx2console/forexconnect/ForexConnect.py +7 -2
  11. jgtfx2console/forexconnect/_fix_import.sh +3 -0
  12. jgtfx2console/forexconnect/lib/windows/ForexConnect.dll +0 -0
  13. jgtfx2console/forexconnect/lib/windows/__init__.py +0 -0
  14. jgtfx2console/forexconnect/lib/windows/_depend_on.txt +11 -0
  15. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-console-l1-1-0.dll +0 -0
  16. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-datetime-l1-1-0.dll +0 -0
  17. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-debug-l1-1-0.dll +0 -0
  18. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-errorhandling-l1-1-0.dll +0 -0
  19. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-file-l1-1-0.dll +0 -0
  20. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-file-l1-2-0.dll +0 -0
  21. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-file-l2-1-0.dll +0 -0
  22. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-handle-l1-1-0.dll +0 -0
  23. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-heap-l1-1-0.dll +0 -0
  24. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-interlocked-l1-1-0.dll +0 -0
  25. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-libraryloader-l1-1-0.dll +0 -0
  26. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-localization-l1-2-0.dll +0 -0
  27. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-memory-l1-1-0.dll +0 -0
  28. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-namedpipe-l1-1-0.dll +0 -0
  29. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-processenvironment-l1-1-0.dll +0 -0
  30. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-processthreads-l1-1-0.dll +0 -0
  31. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-processthreads-l1-1-1.dll +0 -0
  32. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-profile-l1-1-0.dll +0 -0
  33. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-rtlsupport-l1-1-0.dll +0 -0
  34. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-string-l1-1-0.dll +0 -0
  35. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-synch-l1-1-0.dll +0 -0
  36. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-synch-l1-2-0.dll +0 -0
  37. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-sysinfo-l1-1-0.dll +0 -0
  38. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-timezone-l1-1-0.dll +0 -0
  39. jgtfx2console/forexconnect/lib/windows/api-ms-win-core-util-l1-1-0.dll +0 -0
  40. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-conio-l1-1-0.dll +0 -0
  41. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-convert-l1-1-0.dll +0 -0
  42. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-environment-l1-1-0.dll +0 -0
  43. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-filesystem-l1-1-0.dll +0 -0
  44. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-heap-l1-1-0.dll +0 -0
  45. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-locale-l1-1-0.dll +0 -0
  46. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-math-l1-1-0.dll +0 -0
  47. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-multibyte-l1-1-0.dll +0 -0
  48. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-private-l1-1-0.dll +0 -0
  49. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-process-l1-1-0.dll +0 -0
  50. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-runtime-l1-1-0.dll +0 -0
  51. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-stdio-l1-1-0.dll +0 -0
  52. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-string-l1-1-0.dll +0 -0
  53. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-time-l1-1-0.dll +0 -0
  54. jgtfx2console/forexconnect/lib/windows/api-ms-win-crt-utility-l1-1-0.dll +0 -0
  55. jgtfx2console/forexconnect/lib/windows/cacert.pem +3314 -0
  56. jgtfx2console/forexconnect/lib/windows/concrt140.dll +0 -0
  57. jgtfx2console/forexconnect/lib/windows/fxcorepy.pyd +0 -0
  58. jgtfx2console/forexconnect/lib/windows/fxmsg.dll +0 -0
  59. jgtfx2console/forexconnect/lib/windows/fxtp.dll +0 -0
  60. jgtfx2console/forexconnect/lib/windows/gscurl.dll +0 -0
  61. jgtfx2console/forexconnect/lib/windows/gsexpat.dll +0 -0
  62. jgtfx2console/forexconnect/lib/windows/gslibeay32.dll +0 -0
  63. jgtfx2console/forexconnect/lib/windows/gsssleay32.dll +0 -0
  64. jgtfx2console/forexconnect/lib/windows/gstool3.dll +0 -0
  65. jgtfx2console/forexconnect/lib/windows/gszlib.dll +0 -0
  66. jgtfx2console/forexconnect/lib/windows/httplib.dll +0 -0
  67. jgtfx2console/forexconnect/lib/windows/log4cplus.dll +0 -0
  68. jgtfx2console/forexconnect/lib/windows/msvcp140.dll +0 -0
  69. jgtfx2console/forexconnect/lib/windows/pdas.dll +0 -0
  70. jgtfx2console/forexconnect/lib/windows/pricehistorymgr.dll +0 -0
  71. jgtfx2console/forexconnect/lib/windows/python3.dll +0 -0
  72. jgtfx2console/forexconnect/lib/windows/quotesmgr2.dll +0 -0
  73. jgtfx2console/forexconnect/lib/windows/requirements.txt +5 -0
  74. jgtfx2console/forexconnect/lib/windows/sqlite3.8.dll +0 -0
  75. jgtfx2console/forexconnect/lib/windows/ucrtbase.dll +0 -0
  76. jgtfx2console/forexconnect/lib/windows/vccorlib140.dll +0 -0
  77. jgtfx2console/forexconnect/lib/windows/vcruntime140.dll +0 -0
  78. jgtfx2console/fxcli2console.py +12 -7
  79. {jgtfx2console-0.4.27.dist-info → jgtfx2console-0.5.15.dist-info}/METADATA +18 -21
  80. jgtfx2console-0.5.15.dist-info/RECORD +112 -0
  81. {jgtfx2console-0.4.27.dist-info → jgtfx2console-0.5.15.dist-info}/WHEEL +1 -1
  82. jgtfx2console-0.5.15.dist-info/entry_points.txt +2 -0
  83. jgtfx2console-0.4.27.dist-info/RECORD +0 -39
  84. jgtfx2console-0.4.27.dist-info/entry_points.txt +0 -4
  85. {jgtfx2console-0.4.27.dist-info → jgtfx2console-0.5.15.dist-info}/LICENSE +0 -0
  86. {jgtfx2console-0.4.27.dist-info → jgtfx2console-0.5.15.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,23 @@
1
+ # Copyright 2019 Gehtsoft USA LLC
2
+
3
+ # Licensed under the license derived from the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://fxcodebase.com/licenses/open-source/license.html
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ from common_samples.BatchOrderMonitor import BatchOrderMonitor
17
+ from common_samples.OrderMonitor import OrderMonitor
18
+ from common_samples.OrderMonitorNetting import OrderMonitorNetting
19
+ from common_samples.TableListenerContainer import TableListenerContainer
20
+ from common_samples.common import add_main_arguments, add_instrument_timeframe_arguments, \
21
+ add_candle_open_price_mode_argument, add_direction_rate_lots_arguments, add_account_arguments, \
22
+ valid_datetime, add_date_arguments, add_report_date_arguments, add_max_bars_arguments, add_bars_arguments, \
23
+ print_exception, session_status_changed, diff_month, convert_timeframe_to_seconds
@@ -0,0 +1,219 @@
1
+ # Copyright 2019 Gehtsoft USA LLC
2
+
3
+ # Licensed under the license derived from the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://fxcodebase.com/licenses/open-source/license.html
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import logging
17
+ import __main__
18
+ import datetime
19
+ import traceback
20
+ import argparse
21
+ import sys
22
+
23
+ from forexconnect import fxcorepy
24
+
25
+ logging.basicConfig(filename='{0}.log'.format(__main__.__file__), level=logging.INFO,
26
+ format='%(asctime)s %(levelname)s %(message)s', datefmt='%m.%d.%Y %H:%M:%S')
27
+ console = logging.StreamHandler(sys.stdout)
28
+ console.setLevel(logging.INFO)
29
+ logging.getLogger('').addHandler(console)
30
+
31
+
32
+ def add_main_arguments(parser: argparse.ArgumentParser):
33
+ parser.add_argument('-l',
34
+ metavar="LOGIN",
35
+ required=True,
36
+ help='Your user name.')
37
+
38
+ parser.add_argument('-p',
39
+ metavar="PASSWORD",
40
+ required=True,
41
+ help='Your password.')
42
+
43
+ parser.add_argument('-u',
44
+ metavar="URL",
45
+ required=True,
46
+ help='The server URL. For example,\
47
+ http://www.fxcorporate.com/Hosts.jsp.')
48
+
49
+ parser.add_argument('-c',
50
+ metavar="CONNECTION",
51
+ required=True,
52
+ help='The connection name. For example, \
53
+ "Demo" or "Real".')
54
+
55
+ parser.add_argument('-session',
56
+ help='The database name. Required only for users who\
57
+ have accounts in more than one database.\
58
+ Optional parameter.')
59
+
60
+ parser.add_argument('-pin',
61
+ help='Your pin code. Required only for users who have \
62
+ a pin. Optional parameter.')
63
+
64
+ def add_candle_open_price_mode_argument(parser: argparse.ArgumentParser):
65
+ parser.add_argument('-o',
66
+ metavar="CANDLE_OPEN_PRICE_MODE",
67
+ default="prev_close",
68
+ help='Ability to set the open price candles mode. \
69
+ Possible values are first_tick, prev_close. For more information see description \
70
+ of O2GCandleOpenPriceMode enumeration. Optional parameter.')
71
+
72
+ def add_instrument_timeframe_arguments(parser: argparse.ArgumentParser, timeframe: bool = True):
73
+ parser.add_argument('-i',
74
+ metavar="INSTRUMENT",
75
+ default="EUR/USD",
76
+ help='An instrument which you want to use in sample. \
77
+ For example, "EUR/USD".')
78
+
79
+ if timeframe:
80
+ parser.add_argument('-timeframe',
81
+ metavar="TIMEFRAME",
82
+ default="m1",
83
+ help='Time period which forms a single candle. \
84
+ For example, m1 - for 1 minute, H1 - for 1 hour.')
85
+
86
+
87
+ def add_direction_rate_lots_arguments(parser: argparse.ArgumentParser, direction: bool = True, rate: bool = True,
88
+ lots: bool = True):
89
+ if direction:
90
+ parser.add_argument('-d', metavar="TYPE", required=True,
91
+ help='The order direction. Possible values are: B - buy, S - sell.')
92
+ if rate:
93
+ parser.add_argument('-r', metavar="RATE", required=True, type=float,
94
+ help='Desired price of an entry order.')
95
+ if lots:
96
+ parser.add_argument('-lots', metavar="LOTS", default=1, type=int,
97
+ help='Trade amount in lots.')
98
+
99
+
100
+ def add_account_arguments(parser: argparse.ArgumentParser):
101
+ parser.add_argument('-account', metavar="ACCOUNT",
102
+ help='An account which you want to use in sample.')
103
+
104
+
105
+ def valid_datetime(check_future: bool):
106
+ def _valid_datetime(str_datetime: str):
107
+ date_format = '%m.%d.%Y %H:%M:%S'
108
+ try:
109
+ result = datetime.datetime.strptime(str_datetime, date_format).replace(
110
+ tzinfo=datetime.timezone.utc)
111
+ if check_future and result > datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc):
112
+ msg = "'{0}' is in the future".format(str_datetime)
113
+ raise argparse.ArgumentTypeError(msg)
114
+ return result
115
+ except ValueError:
116
+ now = datetime.datetime.now()
117
+ msg = "The date '{0}' is invalid. The valid data format is '{1}'. Example: '{2}'".format(
118
+ str_datetime, date_format, now.strftime(date_format))
119
+ raise argparse.ArgumentTypeError(msg)
120
+ return _valid_datetime
121
+
122
+
123
+ def add_date_arguments(parser: argparse.ArgumentParser, date_from: bool = True, date_to: bool = True):
124
+ if date_from:
125
+ parser.add_argument('-datefrom',
126
+ metavar="\"m.d.Y H:M:S\"",
127
+ help='Date/time from which you want to receive\
128
+ historical prices. If you leave this argument as it \
129
+ is, it will mean from last trading day. Format is \
130
+ "m.d.Y H:M:S". Optional parameter.',
131
+ type=valid_datetime(True)
132
+ )
133
+ if date_to:
134
+ parser.add_argument('-dateto',
135
+ metavar="\"m.d.Y H:M:S\"",
136
+ help='Datetime until which you want to receive \
137
+ historical prices. If you leave this argument as it is, \
138
+ it will mean to now. Format is "m.d.Y H:M:S". \
139
+ Optional parameter.',
140
+ type=valid_datetime(False)
141
+ )
142
+
143
+
144
+ def add_report_date_arguments(parser: argparse.ArgumentParser, date_from: bool = True, date_to: bool = True):
145
+ if date_from:
146
+ parser.add_argument('-datefrom',
147
+ metavar="\"m.d.Y H:M:S\"",
148
+ help='Datetime from which you want to receive\
149
+ combo account statement report. If you leave this argument as it \
150
+ is, it will mean from last month. Format is \
151
+ "m.d.Y H:M:S". Optional parameter.',
152
+ type=valid_datetime(True)
153
+ )
154
+ if date_to:
155
+ parser.add_argument('-dateto',
156
+ metavar="\"m.d.Y H:M:S\"",
157
+ help='Datetime until which you want to receive \
158
+ combo account statement report. If you leave this argument as it is, \
159
+ it will mean to now. Format is "m.d.Y H:M:S". \
160
+ Optional parameter.',
161
+ type=valid_datetime(True)
162
+ )
163
+
164
+
165
+ def add_max_bars_arguments(parser: argparse.ArgumentParser):
166
+ parser.add_argument('-quotescount',
167
+ metavar="MAX",
168
+ default=0,
169
+ type=int,
170
+ help='Max number of bars. 0 - Not limited')
171
+
172
+
173
+ def add_bars_arguments(parser: argparse.ArgumentParser):
174
+ parser.add_argument('-bars',
175
+ metavar="COUNT",
176
+ default=3,
177
+ type=int,
178
+ help='Build COUNT bars. Optional parameter.')
179
+
180
+
181
+ def print_exception(exception: Exception):
182
+ logging.error("Exception: {0}\n{1}".format(exception, traceback.format_exc()))
183
+
184
+
185
+ # function for print available descriptors
186
+ def session_status_changed(session: fxcorepy.O2GSession,
187
+ status: fxcorepy.AO2GSessionStatus.O2GSessionStatus):
188
+ logging.info("Status: " + str(status))
189
+ if status == fxcorepy.AO2GSessionStatus.O2GSessionStatus.TRADING_SESSION_REQUESTED:
190
+ descriptors = session.trading_session_descriptors
191
+ logging.info("Session descriptors:")
192
+ logging.info(" {0:>7} | {1:>7} | {2:>30} | {3:>7}\n".format("id", "name", "description", "requires pin"))
193
+ for desc in descriptors:
194
+ logging.info(" {0:>7} | {1:>7} | {2:>30} | {3:>7}\n".format(desc.id, desc.name,
195
+ desc.description,
196
+ str(desc.requires_pin)))
197
+
198
+
199
+ def diff_month(year: int, month: int, date2: datetime):
200
+ return (year - date2.year) * 12 + month - date2.month
201
+
202
+
203
+ def convert_timeframe_to_seconds(unit: fxcorepy.O2GTimeFrameUnit, size: int):
204
+ current_unit = unit
205
+ current_size = size
206
+ step = 1
207
+ if current_unit == fxcorepy.O2GTimeFrameUnit.MIN:
208
+ step = 60 # leads to seconds
209
+ elif current_unit == fxcorepy.O2GTimeFrameUnit.HOUR:
210
+ step = 60*60
211
+ elif current_unit == fxcorepy.O2GTimeFrameUnit.DAY:
212
+ step = 60*60*24
213
+ elif current_unit == fxcorepy.O2GTimeFrameUnit.WEEK:
214
+ step = 60*60*24*7
215
+ elif current_unit == fxcorepy.O2GTimeFrameUnit.MONTH:
216
+ step = 60 * 60 * 24 * 30
217
+ elif current_unit == fxcorepy.O2GTimeFrameUnit.TICK:
218
+ step = 1
219
+ return step * current_size
@@ -4,11 +4,18 @@ import argparse
4
4
  import os
5
5
  import xml.etree.ElementTree as ET
6
6
 
7
- def generate_config(instruments, timeframes, nb_bar=500, default_headers="DateTime,Bid Open,Bid Close,Ask High,Ask Low,Volume", data_dir=None):
7
+ def generate_config(instruments, timeframes, nb_bar=500, default_headers="DateTime,Bid Open,Bid Close,Ask High,Ask Low,Volume", data_dir=None,dt_sep=' ',tz_default='UTC'):
8
8
  # Split the CSV strings into lists
9
9
  instruments = instruments.split(',')
10
10
  timeframes = timeframes.split(',')
11
11
 
12
+ if dt_sep == '' or dt_sep == 'space' or dt_sep == '0':
13
+ dt_sep = ' '
14
+
15
+ if dt_sep == 'tab':
16
+ dt_sep = ' '
17
+
18
+
12
19
  # Create the root element
13
20
  config = ET.Element('configuration')
14
21
 
@@ -25,7 +32,7 @@ def generate_config(instruments, timeframes, nb_bar=500, default_headers="DateTi
25
32
  ET.SubElement(settings, 'SessionID').text = ''
26
33
  ET.SubElement(settings, 'Pin').text = ''
27
34
  ET.SubElement(settings, 'Delimiter').text = ','
28
- ET.SubElement(settings, 'DateTimeSeparator').text = ' '
35
+ ET.SubElement(settings, 'DateTimeSeparator').text = dt_sep
29
36
  ET.SubElement(settings, 'FormatDecimalPlaces').text = 'Y'
30
37
  ET.SubElement(settings, 'Timezone').text = 'UTC'
31
38
 
@@ -46,9 +53,9 @@ def generate_config(instruments, timeframes, nb_bar=500, default_headers="DateTi
46
53
  def main():
47
54
  import argparse
48
55
  parser = argparse.ArgumentParser(description='Generate a configuration file for the ptoLiveChartDataExport')
49
- parser.add_argument('-i','--instruments', help='The list of instruments to export (comma-separated)')
50
- parser.add_argument('-t','--timeframes', help='The list of timeframes to export (comma-separated)')
51
- parser.add_argument('-o','--outxml', type=str,default="jgtfxliveconfig.xml", help='Output XML file')
56
+ parser.add_argument('-i','--instruments', help='The list of instruments to export (comma-separated)', required=True)
57
+ parser.add_argument('-t','--timeframes', help='The list of timeframes to export (comma-separated)', required=True)
58
+ parser.add_argument('-o','--outxml', type=str,default="fxliveconfig.xml", help='Output XML file')
52
59
 
53
60
  #data_dir = os.getenv('JGTPY_DATA') or if --data_dir
54
61
  parser.add_argument('-d','--data_dir', help='The directory where the data will be saved')
@@ -468,8 +468,13 @@ class ForexConnect:
468
468
  if os.path.isdir(var_jgt_dir) and os.access(var_jgt_dir, os.W_OK):
469
469
  history_dir = os.path.join(var_jgt_dir,"History")
470
470
  else:
471
- history_dir = os.path.join(os.getcwd(), "History")
472
- print("using ./History, might want to create : sudo mkdir -p -m 777 " + var_jgt_dir)
471
+ #try to create in $HOME/.cache/jgt/History
472
+ history_dir = os.path.join(os.path.expanduser("~"), ".cache", "jgt", "History")
473
+ try:
474
+ os.makedirs(history_dir, exist_ok=True)
475
+ except:
476
+ history_dir = os.path.join(os.getcwd(), "History")
477
+ print("using ./History, might want to create : sudo mkdir -p -m 777 " + var_jgt_dir)
473
478
 
474
479
  self._com = fxcorepy.PriceHistoryCommunicatorFactory.create_communicator(
475
480
  self._session, history_dir)
@@ -0,0 +1,3 @@
1
+ for f in *py;do sed -i 's/from forexconnect\./from ./g' $f;done
2
+ for f in *py;do sed -i 's/from forexconnect/from ./g' $f;done
3
+
File without changes
@@ -0,0 +1,11 @@
1
+ ForexConnect.dll
2
+ quotesmgr2.dll
3
+ pricehistorymgr.dll
4
+ USER32.dll
5
+ MSVCP140.dll
6
+ python37.dll
7
+ VCRUNTIME140.dll
8
+ api-ms-win-crt-runtime-l1-1-0.dll
9
+ api-ms-win-crt-stdio-l1-1-0.dll
10
+ api-ms-win-crt-heap-l1-1-0.dll
11
+ KERNEL32.dll