Skip to content

Commit

Permalink
upgrade 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Emerson Pedroso committed Feb 25, 2021
1 parent 2f73ae5 commit 3996e45
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 27 deletions.
45 changes: 37 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,17 @@ mt.cancel_all()
mt.close_all()
```

#### History fromDate toDate
# History Dataframe Ready

#### History from Date to Date Dataframe

```python
symbol = "EURUSD"
timeframe = "M1"
fromDate = "24/02/2021"
toDate = "24/02/2021"

history = mt.history(symbol,timeframe,fromDate,toDate)
history = mt.historyDataframe(symbol,timeframe,fromDate,toDate)
print(history)

open high low close volume spread
Expand Down Expand Up @@ -186,14 +188,14 @@ date

```

#### Short History
#### Short History Dataframe

```python

symbol = "EURUSD"
timeframe = "M1"

history = mt.Shorthistory(symbol,timeframe,1)
history = mt.ShorthistoryDataframe(symbol,timeframe,10)
print(history)

open high low close volume spread
Expand Down Expand Up @@ -238,7 +240,7 @@ date

```

#### History multiple symbol merged DataFrame
# History multiple symbol merged DataFrame

```python
from ejtraderMT import Metatrader
Expand All @@ -251,7 +253,7 @@ timeframe = "M1"
fromDate = "01/01/2021"
toDate = "10/01/2021"

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

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


data = api.ShorthistoryDataFrame(symbol,symbols,timeframe,10)
data = api.ShorthistoryMultiDataFrame(symbol,symbols,timeframe,10)


print(data)
Expand All @@ -304,7 +306,34 @@ date

```

#### Live data and streaming events
# history dictionary "array"

#### Short History from Date to Date dict

```python
symbol = "EURUSD"
timeframe = "M1"


history = mt.Shorthistory(symbol,timeframe,10)
print(history)
```

#### History fromDate toDate dict

```python
symbol = "EURUSD"
timeframe = "M1"
fromDate = "24/02/2021"
toDate = "24/02/2021"

history = mt.history(symbol,timeframe,fromDate,toDate)
print(history)


```

# Live data and streaming events

```python
from ejtraderMT import Metatrader
Expand Down
37 changes: 27 additions & 10 deletions ejtraderMT/api/platafrom.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,31 @@ def positions(self):
def orders(self):
return json.loads(json.dumps(self.api.Command(action="ORDERS")))


def Shorthistory(self, symbol, chartTF, fromDate, toDate):

if(chartTF == 'TICK'):
data = json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=datetime.utcnow().timestamp() - (fromDate * 60))))
self.api.Command(action="RESET")
else:
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)))))
self.api.Command(action="RESET")
return data


def history(self, symbol, chartTF, fromDate, toDate):

if(chartTF == 'TICK'):
data = json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=convertDate(fromDate), toDate=convertDate(toDate))))
self.api.Command(action="RESET")
else:
data = json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=convertDate(fromDate), toDate=convertDate(toDate))))
self.api.Command(action="RESET")
return data


def historyDataFrame(self, symbol, chartTF, fromDate, toDate):

if(chartTF == 'TICK'):
data = json.loads(json.dumps(self.api.Command(action="HISTORY", actionType="DATA", symbol=symbol, chartTF=chartTF, fromDate=convertDate(fromDate), toDate=convertDate(toDate))))
data_frame = pd.DataFrame(data['data'], columns=['date', 'bid', 'ask'])
Expand Down Expand Up @@ -347,7 +370,7 @@ def timeframe_to_sec(self, timeframe):
return TIMECANDLE[timeframe]


def Shorthistory(self, symbol, chartTF, fromDate):
def ShorthistoryDataframe(self, symbol, chartTF, fromDate):

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



def historyDataFrame(self, symbol, symbols, chartTF, fromDate, toDate):
def historyMultiDataFrame(self, symbol, symbols, chartTF, fromDate, toDate):
actives = symbols
main = pd.DataFrame()
current = pd.DataFrame()
Expand Down Expand Up @@ -405,7 +428,7 @@ def historyDataFrame(self, symbol, symbols, chartTF, fromDate, toDate):
main = main.loc[~main.index.duplicated(keep = 'first')]
return main

def ShorthistoryDataFrame(self, symbol, symbols, chartTF, fromDate):
def ShorthistoryMultiDataFrame(self, symbol, symbols, chartTF, fromDate):
actives = symbols
main = pd.DataFrame()
current = pd.DataFrame()
Expand Down Expand Up @@ -446,13 +469,7 @@ def ShorthistoryDataFrame(self, symbol, symbols, chartTF, fromDate):
return main


def live(self,symbol, chartTF):
self.api.Command(action="RESET")
for active in symbol:
self.api.Command(action="CONFIG", symbol=active, chartTF=chartTF)
print(f'subscribed : {active}')
time.sleep(1)





Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def requirements(filename):

setup(
name='ejtraderMT',
version='1.0.0',
version='1.0.2',
packages=find_packages(),
url='https://ejtrader_mt.readthedocs.io/',
download_url='https://ejtrader.com',
Expand Down
2 changes: 1 addition & 1 deletion test/MultipleDataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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

api.


print(data)

2 changes: 1 addition & 1 deletion test/ShortMultipleDataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
timeframe = "M1"


data = api.ShorthistoryDataFrame(symbol,symbols,timeframe,10)
data = api.ShorthistoryDataFrame(symbol,symbols,timeframe,3)


print(data)
Expand Down
6 changes: 2 additions & 4 deletions test/MultipleDataframe copy.py → test/dicthistory.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from ejtraderMT import Metatrader



api = Metatrader()

symbol = "EURUSD"
symbols = [symbol,"GBPUSD","AUDUSD"]
timeframe = "M1"
fromDate = "01/01/2021"
toDate = "10/01/2021"
toDate = "01/02/2021"

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


print(data)
Expand Down
4 changes: 2 additions & 2 deletions test/main.py → test/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def event():
event = connect.recv_json()
print(event)




t = Thread(target=price, daemon=True)
t.start()
Expand Down

0 comments on commit 3996e45

Please sign in to comment.