mtcli 3.8.0.dev5__tar.gz → 3.8.0.dev7__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.
Files changed (82) hide show
  1. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/PKG-INFO +1 -1
  2. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/database.py +1 -0
  3. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/marketdata/tick_repository.py +52 -9
  4. mtcli-3.8.0.dev7/mtcli/migrations/005_tick_price_compression.py +59 -0
  5. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/pyproject.toml +1 -1
  6. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/LICENSE +0 -0
  7. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/README.md +0 -0
  8. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/__init__.py +0 -0
  9. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/cli.py +0 -0
  10. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/commands/__init__.py +0 -0
  11. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/commands/bars.py +0 -0
  12. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/commands/conf.py +0 -0
  13. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/commands/doctor.py +0 -0
  14. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/commands/migrate.py +0 -0
  15. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/commands/ticks.py +0 -0
  16. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/conecta.py +0 -0
  17. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/conf.py +0 -0
  18. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/config_registre.py +0 -0
  19. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/data/__init__.py +0 -0
  20. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/data/base.py +0 -0
  21. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/data/csv.py +0 -0
  22. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/data/mt5.py +0 -0
  23. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/domain/__init__.py +0 -0
  24. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/domain/timeframe.py +0 -0
  25. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/logger.py +0 -0
  26. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/marketdata/__init__.py +0 -0
  27. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/marketdata/tick_cache.py +0 -0
  28. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/marketdata/tick_engine.py +0 -0
  29. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/migrations/001_initial_schema.py +0 -0
  30. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/migrations/002_ticks_time_msc.py +0 -0
  31. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/migrations/003_optimize_ticks_without_rowid.py +0 -0
  32. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/migrations/004_ticks_pk_time_msc.py +0 -0
  33. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/migrations/__init__.py +0 -0
  34. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/migrations/runner.py +0 -0
  35. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/models/__init__.py +0 -0
  36. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/models/bar_model.py +0 -0
  37. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/models/bars_model.py +0 -0
  38. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/models/chart_model.py +0 -0
  39. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/models/conf_model.py +0 -0
  40. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/models/consecutive_bars_model.py +0 -0
  41. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/models/rates_model.py +0 -0
  42. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/models/signals_model.py +0 -0
  43. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/models/unconsecutive_bar_model.py +0 -0
  44. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/mt5_context.py +0 -0
  45. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugin.py +0 -0
  46. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugin_loader.py +0 -0
  47. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugin_manager.py +0 -0
  48. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/__init__.py +0 -0
  49. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/exemplo.py-dist +0 -0
  50. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/media_movel/__init__.py +0 -0
  51. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/media_movel/cli.py +0 -0
  52. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/media_movel/conf.py +0 -0
  53. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/media_movel/models/__init__.py +0 -0
  54. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/media_movel/models/model_media_movel.py +0 -0
  55. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/media_movel/tests/__init__.py +0 -0
  56. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/media_movel/tests/test_mm.py +0 -0
  57. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/media_movel/tests/test_model_media_movel.py +0 -0
  58. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/range_medio/__init__.py +0 -0
  59. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/range_medio/cli.py +0 -0
  60. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/range_medio/conf.py +0 -0
  61. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/range_medio/models/__init__.py +0 -0
  62. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/range_medio/models/average_range_model.py +0 -0
  63. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/range_medio/tests/__init__.py +0 -0
  64. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/range_medio/tests/test_rm.py +0 -0
  65. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/volume_medio/__init__.py +0 -0
  66. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/volume_medio/cli.py +0 -0
  67. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/volume_medio/conf.py +0 -0
  68. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/volume_medio/models/__init__.py +0 -0
  69. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/volume_medio/models/model_average_volume.py +0 -0
  70. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/volume_medio/tests/__init__.py +0 -0
  71. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/plugins/volume_medio/tests/test_vm.py +0 -0
  72. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/__init__.py +0 -0
  73. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/close_view.py +0 -0
  74. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/full_view.py +0 -0
  75. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/high_view.py +0 -0
  76. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/low_view.py +0 -0
  77. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/min_view.py +0 -0
  78. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/open_view.py +0 -0
  79. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/ranges_view.py +0 -0
  80. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/rates_view.py +0 -0
  81. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/vars_view.py +0 -0
  82. {mtcli-3.8.0.dev5 → mtcli-3.8.0.dev7}/mtcli/views/volumes_view.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mtcli
3
- Version: 3.8.0.dev5
3
+ Version: 3.8.0.dev7
4
4
  Summary: Aplicativo CLI para exibir gráficos do MetaTrader 5 screen reader friendly
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -44,6 +44,7 @@ def get_connection():
44
44
  conn.execute("PRAGMA mmap_size=268435456")
45
45
  conn.execute("PRAGMA cache_size=-200000")
46
46
  conn.execute("PRAGMA journal_size_limit=67108864")
47
+ conn.execute("PRAGMA read_uncommitted = TRUE")
47
48
 
48
49
  # checkpoint automático
49
50
  conn.execute("PRAGMA wal_autocheckpoint=1000")
@@ -6,6 +6,9 @@ Responsável por:
6
6
  - persistência de ticks
7
7
  - sincronização histórica
8
8
  - consultas rápidas
9
+
10
+ Implementa compressão de preços:
11
+ preço_real = preço_armazenado / 100
9
12
  """
10
13
 
11
14
  import MetaTrader5 as mt5
@@ -20,6 +23,7 @@ from mtcli.mt5_context import mt5_conexao
20
23
  class TickRepository:
21
24
 
22
25
  RANGE_WINDOW_MINUTES = 10
26
+ PRICE_SCALE = 100
23
27
 
24
28
  def __init__(self):
25
29
 
@@ -93,15 +97,16 @@ class TickRepository:
93
97
 
94
98
  cursor = self.conn.cursor()
95
99
 
100
+ scale = self.PRICE_SCALE
101
+
96
102
  data = [
97
103
  (
98
104
  symbol,
99
- int(t["time"]),
100
105
  int(t["time_msc"]),
101
- float(t["bid"]),
102
- float(t["ask"]),
103
- float(t["last"]),
104
- float(t["volume"]),
106
+ int(t["bid"] * scale),
107
+ int(t["ask"] * scale),
108
+ int(t["last"] * scale),
109
+ int(t["volume"]),
105
110
  int(t["flags"]),
106
111
  )
107
112
  for t in ticks
@@ -110,9 +115,15 @@ class TickRepository:
110
115
  cursor.executemany(
111
116
  """
112
117
  INSERT INTO ticks(
113
- symbol,time,time_msc,bid,ask,last,volume,flags
118
+ symbol,
119
+ time_msc,
120
+ bid,
121
+ ask,
122
+ last,
123
+ volume,
124
+ flags
114
125
  )
115
- VALUES (?,?,?,?,?,?,?,?)
126
+ VALUES (?,?,?,?,?,?,?)
116
127
  ON CONFLICT(symbol,time_msc) DO NOTHING
117
128
  """,
118
129
  data,
@@ -141,9 +152,24 @@ class TickRepository:
141
152
 
142
153
  rows = cursor.fetchall()
143
154
 
155
+ if not rows:
156
+ return []
157
+
144
158
  rows.reverse()
145
159
 
146
- return rows
160
+ scale = self.PRICE_SCALE
161
+
162
+ return [
163
+ (
164
+ r[0],
165
+ r[1] / scale,
166
+ r[2] / scale,
167
+ r[3] / scale,
168
+ r[4],
169
+ r[5],
170
+ )
171
+ for r in rows
172
+ ]
147
173
 
148
174
  def get_ticks_between(self, symbol, start_msc, end_msc):
149
175
 
@@ -160,7 +186,24 @@ class TickRepository:
160
186
  (symbol, start_msc, end_msc),
161
187
  )
162
188
 
163
- return cursor.fetchall()
189
+ rows = cursor.fetchall()
190
+
191
+ if not rows:
192
+ return []
193
+
194
+ scale = self.PRICE_SCALE
195
+
196
+ return [
197
+ (
198
+ r[0],
199
+ r[1] / scale,
200
+ r[2] / scale,
201
+ r[3] / scale,
202
+ r[4],
203
+ r[5],
204
+ )
205
+ for r in rows
206
+ ]
164
207
 
165
208
  # ==========================================================
166
209
  # UTIL
@@ -0,0 +1,59 @@
1
+ def upgrade(conn):
2
+
3
+ cursor = conn.execute("""
4
+ SELECT sql
5
+ FROM sqlite_master
6
+ WHERE type='table'
7
+ AND name='ticks'
8
+ """)
9
+
10
+ row = cursor.fetchone()
11
+
12
+ if not row:
13
+ return
14
+
15
+ if "bid INTEGER" in row[0]:
16
+ return
17
+
18
+ print("Applying tick compression...")
19
+
20
+ conn.execute("PRAGMA foreign_keys=OFF")
21
+
22
+ conn.execute("""
23
+ CREATE TABLE ticks_new(
24
+ symbol TEXT NOT NULL,
25
+ time_msc INTEGER NOT NULL,
26
+ bid INTEGER,
27
+ ask INTEGER,
28
+ last INTEGER,
29
+ volume INTEGER,
30
+ flags INTEGER,
31
+ PRIMARY KEY(symbol,time_msc)
32
+ ) WITHOUT ROWID
33
+ """)
34
+
35
+ conn.execute("""
36
+ INSERT INTO ticks_new
37
+ SELECT
38
+ symbol,
39
+ time_msc,
40
+ CAST(bid*100 AS INTEGER),
41
+ CAST(ask*100 AS INTEGER),
42
+ CAST(last*100 AS INTEGER),
43
+ CAST(volume AS INTEGER),
44
+ flags
45
+ FROM ticks
46
+ """)
47
+
48
+ conn.execute("DROP TABLE ticks")
49
+
50
+ conn.execute("ALTER TABLE ticks_new RENAME TO ticks")
51
+
52
+ conn.execute("""
53
+ CREATE INDEX idx_ticks_symbol_time_msc
54
+ ON ticks(symbol,time_msc)
55
+ """)
56
+
57
+ conn.commit()
58
+
59
+ print("Tick compression applied.")
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mtcli"
3
- version = "3.8.0.dev5"
3
+ version = "3.8.0.dev7"
4
4
  description = "Aplicativo CLI para exibir gráficos do MetaTrader 5 screen reader friendly"
5
5
  authors = [
6
6
  {name = "Valmir França",email = "vfranca3@gmail.com"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes