Skip to content

Commit 3996e45

Browse files
author
Emerson Pedroso
committed
upgrade 1.0.2
1 parent 2f73ae5 commit 3996e45

File tree

7 files changed

+71
-27
lines changed

7 files changed

+71
-27
lines changed

README.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,17 @@ mt.cancel_all()
133133
mt.close_all()
134134
```
135135

136-
#### History fromDate toDate
136+
# History Dataframe Ready
137+
138+
#### History from Date to Date Dataframe
137139

138140
```python
139141
symbol = "EURUSD"
140142
timeframe = "M1"
141143
fromDate = "24/02/2021"
142144
toDate = "24/02/2021"
143145

144-
history = mt.history(symbol,timeframe,fromDate,toDate)
146+
history = mt.historyDataframe(symbol,timeframe,fromDate,toDate)
145147
print(history)
146148

147149
open high low close volume spread
@@ -186,14 +188,14 @@ date
186188

187189
```
188190

189-
#### Short History
191+
#### Short History Dataframe
190192

191193
```python
192194

193195
symbol = "EURUSD"
194196
timeframe = "M1"
195197

196-
history = mt.Shorthistory(symbol,timeframe,1)
198+
history = mt.ShorthistoryDataframe(symbol,timeframe,10)
197199
print(history)
198200

199201
open high low close volume spread
@@ -238,7 +240,7 @@ date
238240

239241
```
240242

241-
#### History multiple symbol merged DataFrame
243+
# History multiple symbol merged DataFrame
242244

243245
```python
244246
from ejtraderMT import Metatrader
@@ -251,7 +253,7 @@ timeframe = "M1"
251253
fromDate = "01/01/2021"
252254
toDate = "10/01/2021"
253255

254-
data = api.historyDataFrame(symbol,symbols,timeframe,fromDate,toDate)
256+
data = api.historyMultiDataFrame(symbol,symbols,timeframe,fromDate,toDate)
255257

256258
print(data)
257259
open high low close volume spread OPENGBPUSD HIGHGBPUSD LOWGBPUSD CLOSEGBPUSD VOLUMEGBPUSD SPREADGBPUSD OPENAUDUSD HIGHAUDUSD LOWAUDUSD CLOSEAUDUSD VOLUMEAUDUSD SPREADAUDUSD
@@ -283,7 +285,7 @@ symbols = [symbol,"GBPUSD","AUDUSD"]
283285
timeframe = "M1"
284286

285287

286-
data = api.ShorthistoryDataFrame(symbol,symbols,timeframe,10)
288+
data = api.ShorthistoryMultiDataFrame(symbol,symbols,timeframe,10)
287289

288290

289291
print(data)
@@ -304,7 +306,34 @@ date
304306

305307
```
306308

307-
#### Live data and streaming events
309+
# history dictionary "array"
310+
311+
#### Short History from Date to Date dict
312+
313+
```python
314+
symbol = "EURUSD"
315+
timeframe = "M1"
316+
317+
318+
history = mt.Shorthistory(symbol,timeframe,10)
319+
print(history)
320+
```
321+
322+
#### History fromDate toDate dict
323+
324+
```python
325+
symbol = "EURUSD"
326+
timeframe = "M1"
327+
fromDate = "24/02/2021"
328+
toDate = "24/02/2021"
329+
330+
history = mt.history(symbol,timeframe,fromDate,toDate)
331+
print(history)
332+
333+
334+
```
335+
336+
# Live data and streaming events
308337

309338
```python
310339
from ejtraderMT import Metatrader

ejtraderMT/api/platafrom.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,31 @@ def positions(self):
317317
def orders(self):
318318
return json.loads(json.dumps(self.api.Command(action="ORDERS")))
319319

320+
321+
def Shorthistory(self, symbol, chartTF, fromDate, toDate):
322+
323+
if(chartTF == 'TICK'):
324+
data = json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=datetime.utcnow().timestamp() - (fromDate * 60))))
325+
self.api.Command(action="RESET")
326+
else:
327+
data = json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=datetime.utcnow().timestamp() - (fromDate * (self.timeframe_to_sec(chartTF) * 60)))))
328+
self.api.Command(action="RESET")
329+
return data
330+
331+
320332
def history(self, symbol, chartTF, fromDate, toDate):
321333

334+
if(chartTF == 'TICK'):
335+
data = json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=convertDate(fromDate), toDate=convertDate(toDate))))
336+
self.api.Command(action="RESET")
337+
else:
338+
data = json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=convertDate(fromDate), toDate=convertDate(toDate))))
339+
self.api.Command(action="RESET")
340+
return data
341+
342+
343+
def historyDataFrame(self, symbol, chartTF, fromDate, toDate):
344+
322345
if(chartTF == 'TICK'):
323346
data = json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=convertDate(fromDate), toDate=convertDate(toDate))))
324347
data_frame = pd.DataFrame(data['data'], columns=['date', 'bid', 'ask'])
@@ -347,7 +370,7 @@ def timeframe_to_sec(self, timeframe):
347370
return TIMECANDLE[timeframe]
348371

349372

350-
def Shorthistory(self, symbol, chartTF, fromDate):
373+
def ShorthistoryDataframe(self, symbol, chartTF, fromDate):
351374

352375
if(chartTF == 'TICK'):
353376
data = json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=datetime.utcnow().timestamp() - (fromDate * 60))))
@@ -365,7 +388,7 @@ def Shorthistory(self, symbol, chartTF, fromDate):
365388

366389

367390

368-
def historyDataFrame(self, symbol, symbols, chartTF, fromDate, toDate):
391+
def historyMultiDataFrame(self, symbol, symbols, chartTF, fromDate, toDate):
369392
actives = symbols
370393
main = pd.DataFrame()
371394
current = pd.DataFrame()
@@ -405,7 +428,7 @@ def historyDataFrame(self, symbol, symbols, chartTF, fromDate, toDate):
405428
main = main.loc[~main.index.duplicated(keep = 'first')]
406429
return main
407430

408-
def ShorthistoryDataFrame(self, symbol, symbols, chartTF, fromDate):
431+
def ShorthistoryMultiDataFrame(self, symbol, symbols, chartTF, fromDate):
409432
actives = symbols
410433
main = pd.DataFrame()
411434
current = pd.DataFrame()
@@ -446,13 +469,7 @@ def ShorthistoryDataFrame(self, symbol, symbols, chartTF, fromDate):
446469
return main
447470

448471

449-
def live(self,symbol, chartTF):
450-
self.api.Command(action="RESET")
451-
for active in symbol:
452-
self.api.Command(action="CONFIG", symbol=active, chartTF=chartTF)
453-
print(f'subscribed : {active}')
454-
time.sleep(1)
455-
472+
456473

457474

458475

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def requirements(filename):
1717

1818
setup(
1919
name='ejtraderMT',
20-
version='1.0.0',
20+
version='1.0.2',
2121
packages=find_packages(),
2222
url='https://ejtrader_mt.readthedocs.io/',
2323
download_url='https://ejtrader.com',

test/MultipleDataframe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
data = api.historyDataFrame(symbol,symbols,timeframe,fromDate,toDate)
1313

14-
api.
14+
1515

1616
print(data)
1717

test/ShortMultipleDataframe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
timeframe = "M1"
1010

1111

12-
data = api.ShorthistoryDataFrame(symbol,symbols,timeframe,10)
12+
data = api.ShorthistoryDataFrame(symbol,symbols,timeframe,3)
1313

1414

1515
print(data)

test/MultipleDataframe copy.py renamed to test/dicthistory.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
from ejtraderMT import Metatrader
22

33

4-
54
api = Metatrader()
65

76
symbol = "EURUSD"
8-
symbols = [symbol,"GBPUSD","AUDUSD"]
97
timeframe = "M1"
108
fromDate = "01/01/2021"
11-
toDate = "10/01/2021"
9+
toDate = "01/02/2021"
1210

13-
data = api.historyDataFrame(symbol,symbols,timeframe,fromDate,toDate)
11+
data = api.history(symbol,timeframe,fromDate,toDate)
1412

1513

1614
print(data)

test/main.py renamed to test/live.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def event():
2929
event = connect.recv_json()
3030
print(event)
3131

32-
33-
32+
33+
3434

3535
t = Thread(target=price, daemon=True)
3636
t.start()

0 commit comments

Comments
 (0)