Skip to content

Commit

Permalink
Merge pull request #50 from hANSIc99/dev
Browse files Browse the repository at this point in the history
v1.8 ready

- CCXT: Fixed bug querying OHLCV data
- CCXT Methods: Fixed bug when applying data limit querying OHLCV
  • Loading branch information
hANSIc99 authored Aug 27, 2021
2 parents 233c111 + ab47e5b commit 79ccc4a
Show file tree
Hide file tree
Showing 22 changed files with 4,921 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.8

CCXT: Fixed bug querying OHLCV data
CCXT Methods: Fixed bug when applying data limit querying OHLCV


1.7

Added SetPersist type
Expand Down
4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ RUN /usr/bin/python3 -m pip install pylint==2.7.4
###################################


COPY dist/Pythonic-1.7.tar.gz /
COPY dist/Pythonic-1.8.tar.gz /

RUN /usr/bin/python3 -m pip install /Pythonic-1.7.tar.gz

RUN rm Pythonic-1.7.tar.gz
RUN rm Pythonic-1.8.tar.gz

###################################
# #
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ The credentials for login at Cockpit are:
Open your favorite WebAssembly compatible web browser and navigate to...


- [http://1270.0.01:7000/](http://127.0.0.1:7000/) ... to open the GUI
- [http://1270.0.01:7000/log](http://127.0.0.1:7000/log) ... to get an overview of available log files
- [http://1270.0.01:7000/2021_03_15.txt](http://127.0.0.1:7000/2021_03_15.txt) ... to open the actual log file of 15. March 2021 (requested date must be available)
- [http://1270.0.01:7000/generic_python_73594528.py](http://127.0.0.1:7000/generic_python_73594528.py) ... to download a specific *\*.py*-file
- [http://1270.0.01:7000/current_config.json](http://127.0.0.1:7000/current_config.json) ... to download the grid configuration file
- [http://1270.0.01:8000/](http://127.0.0.01:8000/) ... to open code server (VS Code in browser - **container and Raspberry Pi only**)
- [http://1270.0.01:9090/](http://127.0.0.01:9090/) ... to open Cockpit system manager (**Raspberry Pi image only**)
- [http://127.0.0.1:7000/](http://127.0.0.1:7000/) ... to open the GUI
- [http://127.0.0.1:7000/log](http://127.0.0.1:7000/log) ... to get an overview of available log files
- [http://127.0.0.1:7000/2021_03_15.txt](http://127.0.0.1:7000/2021_03_15.txt) ... to open the actual log file of 15. March 2021 (requested date must be available)
- [http://127.0.0.1:7000/generic_python_73594528.py](http://127.0.0.1:7000/generic_python_73594528.py) ... to download a specific *\*.py*-file
- [http://127.0.0.1:7000/current_config.json](http://127.0.0.1:7000/current_config.json) ... to download the grid configuration file
- [http://127.0.0.1:8000/](http://127.0.0.01:8000/) ... to open code server (VS Code in browser - **container and Raspberry Pi only**)
- [http://127.0.0.1:9090/](http://127.0.0.01:9090/) ... to open Cockpit system manager (**Raspberry Pi image only**)



## Editing elements
Expand Down
9 changes: 9 additions & 0 deletions TODOS
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
General:

CCXT Method: Remove large if-else areas for parsing config

Python: Add type hints

Check if the 'inline'-keyword can be applied to some loops
(page 146 C++ Der Programmierer)

Expand All @@ -10,3 +14,8 @@ Add the possibility to pass arbitrary number of keyword arguments or
to build a dictionary from within the editor


element_types.py
execute_ex() :
- Signaliye an exception in the GUI
- Remove return value as it is not processed

Binary file added dist/Pythonic-1.8.tar.gz
Binary file not shown.
Binary file added dist/PythonicRPI-1.8.tar.gz
Binary file not shown.
89 changes: 89 additions & 0 deletions examples/trading_bot_crossing_ema/ccxt_6f9efe59.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import time, queue
import ccxt
try:
from element_types import Record, Function, ProcCMD, GuiCMD
except ImportError:
from Pythonic.element_types import Record, Function, ProcCMD, GuiCMD

class Element(Function):

def __init__(self, id, config, inputData, return_queue, cmd_queue):
super().__init__(id, config, inputData, return_queue, cmd_queue)


def execute(self):


#####################################
# #
# REFERENCE IMPLEMENTATION #
# #
#####################################


specificConfig = self.config.get('SpecificConfig')

if not specificConfig:

recordDone = Record(None, message='Trigger: {:04d}'.format(self.config['Identifier']))
self.return_queue.put(recordDone)
return


eId = None
pubKey = None
prvKey = None


for attrs in specificConfig:
if attrs['Name'] == 'ExchangeId':
eId = attrs['Data']
if attrs['Name'] == 'PubKey':
pubKey = attrs['Data']
elif attrs['Name'] == 'PrvKey':
prvKey = attrs['Data']


exchangeClass = getattr(ccxt, eId)
if pubKey and prvKey:

exchange = exchangeClass( {
'apiKey' : pubKey,
'secret' : prvKey,
'enableRateLimit' : True
})

else:
exchange = exchangeClass( {'enableRateLimit' : True})

method = getattr(exchange, self.inputData['method'])

kwargs = None
params = None

if not 'kwargs' in self.inputData:

data = method()

elif not 'params' in self.inputData:

kwargs = self.inputData['kwargs']
data = method(**kwargs)

else:

kwargs = self.inputData['kwargs']
params = self.inputData['params']

if params != '':
data = method(**kwargs, params=params)
else:
data = method(**kwargs)


recordDone = Record(data, '{}() successfull'.format(self.inputData['method']))
self.return_queue.put(recordDone)




196 changes: 196 additions & 0 deletions examples/trading_bot_crossing_ema/ccxt_method_7e1cda6c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import time, queue
try:
from element_types import Record, Function, ProcCMD, GuiCMD
except ImportError:
from Pythonic.element_types import Record, Function, ProcCMD, GuiCMD

class Element(Function):

def __init__(self, id, config, inputData, return_queue, cmd_queue):
super().__init__(id, config, inputData, return_queue, cmd_queue)


def execute(self):


#####################################
# #
# REFERENCE IMPLEMENTATION #
# #
#####################################
specificConfig = self.config.get('SpecificConfig')

if not specificConfig:

recordDone = Record(None, message='Trigger: {:04d}'.format(self.config['Identifier']))
self.return_queue.put(recordDone)
return

baseAPI = None
pubMethod = None
prvMethod = None
orderType = None
side = None
pubSymbol = None
prvSymbol = None
symbols = None
timeframe = None
limit = None
amount = None
price = None
address = None
params = None

for attrs in specificConfig:
if attrs['Name'] == 'BaseApi':
baseAPI = attrs['Data']
if attrs['Name'] == 'Public Methods':
pubMethod = attrs['Data']
elif attrs['Name'] == 'Private Methods':
prvMethod = attrs['Data']
elif attrs['Name'] == 'Order Types':
orderType = attrs['Data']
elif attrs['Name'] == 'Side':
side = attrs['Data']
elif attrs['Name'] == 'SymbolPublic':
pubSymbol = attrs['Data']
elif attrs['Name'] == 'SymbolPrivate':
prvSymbol = attrs['Data']
elif attrs['Name'] == 'Timeframe':
timeframe = attrs['Data']
elif attrs['Name'] == 'LimitData':
limit = attrs['Data']
elif attrs['Name'] == 'Tickers':
symbols = attrs['Data']
elif attrs['Name'] == 'Amount':
amount = attrs['Data']
elif attrs['Name'] == 'Price':
price = attrs['Data']
elif attrs['Name'] == 'Address':
address = attrs['Data']
elif attrs['Name'] == 'Parameter':
params = attrs['Data']

#########################################
# #
# The execution exits immediately #
# after providing output data #
# #
#########################################

if baseAPI == 'Public':
methodName = pubMethod
symbol = pubSymbol
else:
methodName = prvMethod
symbol = prvSymbol


if methodName == 'create order' and orderType == 'Market':

methodName = methodName.replace(" ", "_")

apiCall = {
'method' : methodName,
'kwargs' : {
'symbol' : symbol,
'type' : orderType,
'side' : side,
'amount' : amount
}
}

elif methodName == 'create order' and orderType == 'Limit':

methodName = methodName.replace(" ", "_")

apiCall = {
'method' : methodName,
'kwargs' : {
'symbol' : symbol,
'type' : orderType,
'side' : side,
'amount' : amount,
'price' : price
}
}

elif methodName == 'create order' :

methodName = methodName.replace(" ", "_")

apiCall = {
'method' : methodName,
'params' : params,
'kwargs' : {
'symbol' : symbol,
'type' : orderType,
'side' : side,
'amount' : amount,
'price' : price
}
}

elif methodName == 'fetch orders' or \
methodName == 'fetch open orders' or \
methodName == 'fetch closed orders' or \
methodName == 'fetch my trades' or \
methodName == 'fetch trades' or \
methodName == 'fetch order book' or \
methodName == 'fetch ticker':


methodName = methodName.replace(" ", "_")

apiCall = {
'method' : methodName,
'kwargs' : {
'symbol' : symbol
}
}

elif methodName == 'fetch tickers':


methodName = methodName.replace(" ", "_")
apiCall = {
'method' : methodName,
'kwargs' : {
'symbols' : symbols
}
}

elif methodName == 'withdraw':

apiCall = {
'method' : methodName,
'kwargs' : {
'code' : symbol,
'amount' : amount,
'address' : address
}
}

elif methodName == 'fetch OHLCV':

methodName = methodName.replace(" ", "_").lower()

apiCall = {
'method' : methodName,
'kwargs' : {
'symbol' : symbol,
'timeframe' : timeframe,
'limit' : int(limit)
}
}

else:

methodName = methodName.replace(" ", "_")

apiCall = {
'method' : methodName
}

recordDone = Record(apiCall)
self.return_queue.put(recordDone)
Loading

0 comments on commit 79ccc4a

Please sign in to comment.