-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from hANSIc99/dev
v1.8 ready - CCXT: Fixed bug querying OHLCV data - CCXT Methods: Fixed bug when applying data limit querying OHLCV
- Loading branch information
Showing
22 changed files
with
4,921 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
196
examples/trading_bot_crossing_ema/ccxt_method_7e1cda6c.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.