CCXT implementation
This commit is contained in:
1 parent
380407c27c
commit
1c24e10e83
3 files changed
+74
-2
No files matched your search
@@ -0,0 +1,55 @@
|
||||
function newCCXTFunctions () {
|
||||
thisObject = {
|
||||
addMissingExchanges: addMissingExchanges,
|
||||
addMissingAssets: addMissingAssets,
|
||||
addMissingMarkets: addMissingMarkets
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function addMissingExchanges (node, functionLibraryUiObjectsFromNodes) {
|
||||
currentExchanges = new Map()
|
||||
for (let j = 0; j < node.exchanges.length; j++) {
|
||||
let exchange = node.exchanges[j]
|
||||
let codeName = loadPropertyFromNodeConfig(exchange.payload, 'codeName')
|
||||
currentExchanges.set(codeName, exchange)
|
||||
}
|
||||
for (let i = 0; i < ccxt.exchanges.length; i++) {
|
||||
let exchangeId = ccxt.exchanges[i]
|
||||
let existingExchange = currentExchanges.get(exchangeId)
|
||||
if (existingExchange === undefined) {
|
||||
const exchangeClass = ccxt[exchangeId]
|
||||
const exchangeConstructorParams = {
|
||||
'timeout': 30000,
|
||||
'enableRateLimit': true,
|
||||
verbose: false
|
||||
}
|
||||
|
||||
let ccxtExchange = new exchangeClass(exchangeConstructorParams)
|
||||
|
||||
if (ccxtExchange.has.fetchOHLCV === true) {
|
||||
if (ccxtExchange.timeframes['1m'] !== undefined) {
|
||||
let newExchange = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Crypto Exchange')
|
||||
newExchange.name = ccxtExchange.name
|
||||
newExchange.code = '{ \n\"codeName\": \"' + ccxtExchange.id + '\"\n}'
|
||||
newExchange.payload.floatingObject.collapseToggle()
|
||||
newExchange.exchangeAssets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newExchange.exchangeMarkets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newExchange.exchangeAccounts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newExchange.exchangeAssets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
|
||||
newExchange.exchangeMarkets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
|
||||
newExchange.exchangeAccounts.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_025X
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addMissingAssets (node, functionLibraryUiObjectsFromNodes) {
|
||||
|
||||
}
|
||||
|
||||
function addMissingMarkets (node, functionLibraryUiObjectsFromNodes) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ function newWorkspace () {
|
||||
let functionLibraryShortcutKeys = newShortcutKeys()
|
||||
let functionLibraryOnFocus = newOnFocus()
|
||||
let functionLibrarySuperScripts = newSuperScriptsFunctions()
|
||||
let functionLibraryCCXTFunctions = newCCXTFunctions()
|
||||
|
||||
thisObject.nodeChildren = newNodeChildren()
|
||||
|
||||
@@ -88,7 +89,7 @@ function newWorkspace () {
|
||||
functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode)
|
||||
thisObject.enabled = true
|
||||
|
||||
setInterval(saveWorkspace, 30000)
|
||||
setInterval(saveWorkspace, 10000)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
|
||||
}
|
||||
@@ -370,6 +371,22 @@ function newWorkspace () {
|
||||
functionLibraryTaskFunctions.stopAllExchangeTasks(payload.node, functionLibraryProtocolNode)
|
||||
}
|
||||
break
|
||||
case 'Add Missing Crypto Exchanges':
|
||||
{
|
||||
functionLibraryCCXTFunctions.addMissingExchanges(payload.node, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
break
|
||||
case 'Add Missing Assets':
|
||||
{
|
||||
functionLibraryCCXTFunctions.addMissingAssets(payload.node, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
break
|
||||
case 'Add Missing Markets':
|
||||
{
|
||||
functionLibraryCCXTFunctions.addMissingMarkets(payload.node, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
break
|
||||
|
||||
case 'Run Session':
|
||||
{
|
||||
functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, callBackFunction)
|
||||
|
||||
@@ -84,7 +84,7 @@ function newUiObjectConstructor () {
|
||||
for (let j = 0; j < menuItems.length; j++) {
|
||||
let item = menuItems[j]
|
||||
item.angle = undefined
|
||||
if (item.action.indexOf('Add ') >= 0 && item.action.indexOf('Missing') >= 0) {
|
||||
if (item.action.indexOf('Add Missing Children') >= 0) {
|
||||
item.action = 'Add Missing Children'
|
||||
}
|
||||
if (item.action.indexOf('Delete ') >= 0) {
|
||||
|
||||
Reference in new issue
Block a user