Skip to content

Commit

Permalink
Improvement: API Changes to Support Twitter Social Sentiment
Browse files Browse the repository at this point in the history
  • Loading branch information
Smidy13 committed Jul 24, 2022
1 parent f74e1f6 commit 0860caf
Show file tree
Hide file tree
Showing 9 changed files with 366 additions and 127 deletions.

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Projects/Foundations/Schemas/App-Schema/Api/apis.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
"actionProject": "Visual-Scripting",
"relatedUiObjectProject": "Foundations"
},
{
"action": "Add UI Object",
"label": "Add API Authorization Key",
"relatedUiObject": "API Authorization Key",
"iconPathOn": "exchange-account-key",
"iconPathOff": "exchange-account-key",
"actionFunction": "payload.executeAction",
"actionProject": "Visual-Scripting",
"relatedUiObjectProject": "Foundations"
},
{
"action": "Delete UI Object",
"actionProject": "Visual-Scripting",
Expand All @@ -45,6 +55,11 @@
"name": "web3API",
"type": "node",
"childType": "Web3 API"
},
{
"name": "apiAuthorizationKey",
"type": "node",
"childType": "API Authorization Key"
}
],
"isPersonalData": true
Expand Down
37 changes: 37 additions & 0 deletions Projects/Foundations/Schemas/App-Schema/api-authorization-key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"type": "API Authorization Key",
"menuItems": [
{
"action": "Configure",
"label": "Configure",
"iconPathOn": "configuration",
"iconPathOff": "configuration",
"dontShowAtFullscreen": true,
"actionFunction": "uiObject.configEditor.activate"
},
{
"action": "Delete UI Object",
"actionProject": "Visual-Scripting",
"askConfirmation": true,
"confirmationLabel": "Confirm to Delete",
"label": "Delete",
"iconPathOn": "delete-entity",
"iconPathOff": "delete-entity",
"actionFunction": "payload.executeAction"
}
],
"editors": {
"config": true
},
"initialValues": {
"config": "{ \n \"api_key\": \"\",\n \"api_key_secret\": \"\",\n \"bearer_token\": \"\"\n}"
},
"addLeftIcons": true,
"level": 1,
"attachingRules": {
"compatibleTypes": "->APIs->"
},
"propertyNameAtParent": "apiAuthorizationKey",
"isPersonalData": true,
"icon": "exchange-account-key"
}
2 changes: 1 addition & 1 deletion Projects/Foundations/Schemas/App-Schema/key-reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"compatibleTypes": "->Task->"
},
"referencingRules": {
"compatibleTypes": "->Exchange Account Key->"
"compatibleTypes": "->Exchange Account Key->API Authorization Key->"
},
"propertyNameAtParent": "keyReference"
}
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun
if (property.config.isString === true) {
fileContent = fileContent + propertySeparator + '"' + element[property.config.codeName] + '"'
} else {
fileContent = fileContent + propertySeparator + element[property.config.codeName]
fileContent = fileContent + propertySeparator + JSON.stringify(element[property.config.codeName])
}
propertySeparator = ","
}
Expand Down Expand Up @@ -497,6 +497,9 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun
else if (property.config.isBoolean === true) {
outputElement[property.config.codeName] = false // Default Value
}
else if (property.config.isArray === true) {
outputElement[property.config.codeName] = [] // Default Value
}
else {
outputElement[property.config.codeName] = 0 // Default Value
}
Expand Down Expand Up @@ -568,6 +571,7 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun
aggregationMethodMax()
aggregationMethodSum()
aggregationMethodAvg()
aggregationMethodConcat()

saveElement = true

Expand Down Expand Up @@ -610,9 +614,13 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun
*/
for (let j = 0; j < node.outputDataset.referenceParent.parentNode.record.properties.length; j++) {
let property = node.outputDataset.referenceParent.parentNode.record.properties[j]
if (property.config.aggregationMethod === 'Min' || saveElement === false) {
if (outputElement[property.config.codeName] === 0) { // Set initial value if default value is present
outputElement[property.config.codeName] = record.map.get(property.config.codeName)
if (property.config.aggregationMethod === 'Min') {
if (saveElement === false) {
if (outputElement[property.config.codeName] === 0) { // Set initial value if default value is present
outputElement[property.config.codeName] = record.map.get(property.config.codeName)
} else if (record.map.get(property.config.codeName) < outputElement[property.config.codeName]) {
outputElement[property.config.codeName] = record.map.get(property.config.codeName)
}
} else if (record.map.get(property.config.codeName) < outputElement[property.config.codeName]) {
outputElement[property.config.codeName] = record.map.get(property.config.codeName)
}
Expand Down Expand Up @@ -667,6 +675,18 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun
}
}
}

function aggregationMethodConcat() {
/*
This is the Concat type of aggregation.
*/
for (let j = 0; j < node.outputDataset.referenceParent.parentNode.record.properties.length; j++) {
let property = node.outputDataset.referenceParent.parentNode.record.properties[j]
if (property.config.aggregationMethod === 'Concat') {
outputElement[property.config.codeName] = outputElement[property.config.codeName].concat(record.map.get(property.config.codeName))
}
}
}
}
}
if (saveElement === true) { // then we have a valid element, otherwise it means there were no elements to fill this one in its time range.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function newFoundationsFunctionLibraryTaskFunctions() {
'Learning Bot Instance->' +
'Sensor Process Instance->Time Frames Filter->API Data Fetcher Process Instance->Indicator Process Instance->Study Process Instance->Trading Process Instance->Portfolio Process Instance->Learning Process Instance->' +
'Execution Started Event->' +
'Key Reference->Exchange Account Key->' +
'Key Reference->Exchange Account Key->API Authorization Key->' +
'Task Manager->' +
'Data Mine Tasks->Trading Mine Tasks->Portfolio Mine Tasks->Learning Mine Tasks->' +
'Market Data Tasks->Market Trading Tasks->Market Portfolio Tasks->Market Learning Tasks->' +
Expand Down Expand Up @@ -249,7 +249,7 @@ function newFoundationsFunctionLibraryTaskFunctions() {
let managedTasksLightingPath = '->Task->Managed Tasks->Portfolio Bot Instance->' +
'Task Reference->Task->Sensor Bot Instance->API Data Fetcher Bot->Indicator Bot Instance->Study Bot Instance->Trading Bot Instance->Learning Bot Instance->' +
'Sensor Process Instance->Time Frames Filter->API Data Fetcher Process Instance->Indicator Process Instance->Study Process Instance->Trading Process Instance->Learning Process Instance->' +
'Execution Started Event->Key Reference->Exchange Account Key->' +
'Execution Started Event->Key Reference->Exchange Account Key->API Authorization Key->' +
'Task Manager->' +
'Data Mine Tasks->Trading Mine Tasks->Learning Mine Tasks->Portfolio Mine Tasks->' +
'Market Trading Tasks->Market Data Tasks->Market Learning Tasks->Market Portfolio Tasks->' +
Expand Down
3 changes: 2 additions & 1 deletion TaskServerRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ async function runRoot() {
axios: require('axios'),
crypto: require('crypto'),
simpleGit: require('simple-git'),
ethers: require('ethers')
ethers: require('ethers'),
vaderSentiment: require('vader-sentiment')
}
SA.version = require('./package.json').version
/*
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"telegraf": "^4.4.2",
"twitter-api-v2": "^1.7.1",
"util": "^0.12.4",
"vader-sentiment": "^1.1.3",
"web3": "^1.6.1",
"workbox-webpack-plugin": "5.1.4",
"ws": "^8.4.0"
Expand Down

0 comments on commit 0860caf

Please sign in to comment.