diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..66374a65a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+# See https://help.github.com/ignore-files/ for more about ignoring files.
+.scannerwork
diff --git a/client/package-lock.json b/client/package-lock.json
index 7ada4ee5a..8a42f92c0 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "@superalgos/operations-client",
- "version": "0.0.13",
+ "version": "0.0.14",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/client/src/index.js b/client/src/index.js
index fbec00c0c..dbc3944b5 100644
--- a/client/src/index.js
+++ b/client/src/index.js
@@ -1,9 +1,7 @@
-import React, { Component } from 'react'
+import React from 'react'
import { Route, Switch } from 'react-router-dom'
-
import { MuiPickersUtilsProvider } from 'material-ui-pickers'
import LuxonUtils from 'material-ui-pickers/utils/luxon-utils'
-
import BrowseClones from './views/Clone/List'
import HistoryClones from './views/Clone/History'
import AddClone from './views/Clone/Add'
diff --git a/client/src/views/Clone/Add/index.js b/client/src/views/Clone/Add/index.js
index 15bda776f..341634773 100644
--- a/client/src/views/Clone/Add/index.js
+++ b/client/src/views/Clone/Add/index.js
@@ -2,24 +2,17 @@ import React, { Component } from 'react'
import { graphql, compose, Query } from 'react-apollo'
import { clones, teams, keys } from '../../../GraphQL/Calls'
import { DateTime } from 'luxon';
-
import TopBar from '../../BannerTopBar'
-
import { withStyles } from '@material-ui/core/styles'
import classNames from 'classnames'
import styles from './styles'
-
-import { tradingStartModes, indicatorStartModes, availableMonths, processNames } from '../../../GraphQL/models'
+import { tradingStartModes, indicatorStartModes, availableMonths } from '../../../GraphQL/models'
import { isDefined, getIndicatorYears } from '../../../utils'
-
import {
MenuItem, Button, TextField, FormControl, InputLabel, Input, Typography,
Paper, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions,
Select, FormControlLabel, Checkbox, FormHelperText
} from '@material-ui/core'
-
-import NumberFormat from 'react-number-format'
-
import { DateTimePicker } from 'material-ui-pickers'
import {
ChevronLeft,
diff --git a/client/src/views/Clone/History/index.js b/client/src/views/Clone/History/index.js
index 7a1c103e3..396a7b1b4 100644
--- a/client/src/views/Clone/History/index.js
+++ b/client/src/views/Clone/History/index.js
@@ -2,12 +2,8 @@ import React, { Component } from 'react'
import { graphql } from 'react-apollo'
import { clones } from '../../../GraphQL/Calls'
import TopBar from '../../BannerTopBar'
-//import CloneDialog from './CloneDialog'
import ListClones from '../List/ListClones'
-// Material-ui
-import { Typography, Paper } from '@material-ui/core'
-
class HistoryClones extends Component {
constructor (props) {
diff --git a/client/src/views/Clone/List/CloneDialog.js b/client/src/views/Clone/List/CloneDialog.js
index 46525d2c1..90998f09a 100644
--- a/client/src/views/Clone/List/CloneDialog.js
+++ b/client/src/views/Clone/List/CloneDialog.js
@@ -1,12 +1,9 @@
import React, { Component } from 'react'
import AddClone from './AddClone'
-
-import AddIcon from '@material-ui/icons/Add'
import { withStyles } from '@material-ui/core/styles'
import styles from './styles'
-
import {
- Button, Dialog, DialogContent, DialogContentText, DialogTitle, Paper, Typography
+ Button, Dialog, DialogContent, DialogContentText, DialogTitle
} from '@material-ui/core'
class CloneDialog extends Component {
diff --git a/client/src/views/Clone/List/ListClones.js b/client/src/views/Clone/List/ListClones.js
index 7eea28c18..b9c577826 100644
--- a/client/src/views/Clone/List/ListClones.js
+++ b/client/src/views/Clone/List/ListClones.js
@@ -1,19 +1,15 @@
import React, { Component } from 'react'
import { graphql, compose } from 'react-apollo'
import { clones } from '../../../GraphQL/Calls'
-import Poloniex from '../../../img/poloniex.png'
-import Binance from '../../../img/binance.png'
-
import {
- Grid, Paper, Typography, Button, TextField, Dialog, DialogContent,
+ Typography, Button, TextField, Dialog, DialogContent,
DialogContentText, DialogTitle, DialogActions,
ExpansionPanel, ExpansionPanelDetails, ExpansionPanelSummary,
- ExpansionPanelActions, Chip, Divider
+ ExpansionPanelActions, Divider
} from '@material-ui/core'
import Avatar from '@material-ui/core/Avatar';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
-
import { tradingStartModes, indicatorStartModes } from '../../../GraphQL/models'
import { isDefined, toLocalTime } from '../../../utils'
import classNames from 'classnames'
diff --git a/client/src/views/Clone/List/index.js b/client/src/views/Clone/List/index.js
index 8b601e92e..6df628fa4 100644
--- a/client/src/views/Clone/List/index.js
+++ b/client/src/views/Clone/List/index.js
@@ -2,12 +2,8 @@ import React, { Component } from 'react'
import { graphql } from 'react-apollo'
import { clones } from '../../../GraphQL/Calls'
import TopBar from '../../BannerTopBar'
-//import CloneDialog from './CloneDialog'
import ListClones from './ListClones'
-// Material-ui
-import { Typography, Paper } from '@material-ui/core'
-
class BrowseClones extends Component {
constructor (props) {
diff --git a/client/src/views/Clone/List/styles.js b/client/src/views/Clone/List/styles.js
index f2c33d236..1e7adc606 100644
--- a/client/src/views/Clone/List/styles.js
+++ b/client/src/views/Clone/List/styles.js
@@ -32,7 +32,6 @@ const styles = theme => ({
marginRight: theme.spacing.unit,
},
textArea: {
- width:'1750px',
margin: theme.spacing.unit,
whiteSpace: 'pre',
width:'98%',
diff --git a/client/src/views/Home.js b/client/src/views/Home.js
index 766c931a2..6b4d9aaec 100644
--- a/client/src/views/Home.js
+++ b/client/src/views/Home.js
@@ -1,6 +1,5 @@
import React, { Component } from 'react'
import { Typography } from '@material-ui/core'
-import { withStyles } from '@material-ui/core/styles'
import TopBar from './BannerTopBar'
class Home extends Component {
@@ -29,9 +28,7 @@ class Home extends Component {
-
-
-
+
diff --git a/server/src/errors/index.js b/server/src/errors/index.js
index 74e7c36ff..0a2f6ad14 100644
--- a/server/src/errors/index.js
+++ b/server/src/errors/index.js
@@ -1,5 +1,3 @@
-import logger from '../config/logger'
-
export class AuthentificationError extends Error {
code = 401
message = 'Autentification not found, you have to be authentificated to perform this action.'
diff --git a/server/src/kubernetes/createClone.js b/server/src/kubernetes/createClone.js
index 78e03c181..3ea956ad1 100644
--- a/server/src/kubernetes/createClone.js
+++ b/server/src/kubernetes/createClone.js
@@ -2,143 +2,142 @@ import logger from '../config/logger'
import { toPlatformDatetime, isDefined } from '../config/utils'
import { KubernateError } from '../errors'
import { Client, config } from 'kubernetes-client'
-// Get base Deployment config
import deploymentManifest from '../config/clone-deployment.json'
import { BACKTEST, NO_TIME } from '../enums/CloneMode'
import { TRADER, INDICATOR, EXTRACTION } from '../enums/BotTypes'
const createClone = async (clone) => {
try {
- logger.debug("createClone %s", clone.id)
+ logger.debug('createClone %s', clone.id)
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
// Make changes to base deployment config
deploymentManifest.metadata.name = clone.id
- logger.debug("createClone Environment and Auth Configuration.")
+ logger.debug('createClone Environment and Auth Configuration.')
let env = []
env.push({
- "name": "PLATFORM_ENVIRONMENT",
- "value": process.env.PLATFORM_ENVIRONMENT
+ 'name': 'PLATFORM_ENVIRONMENT',
+ 'value': process.env.PLATFORM_ENVIRONMENT
})
env.push({
- "name": "GATEWAY_ENDPOINT",
- "value": process.env.GATEWAY_ENDPOINT
+ 'name': 'GATEWAY_ENDPOINT',
+ 'value': process.env.GATEWAY_ENDPOINT
})
env.push({
- "name": "STORAGE_BASE_URL",
- "value": process.env.STORAGE_BASE_URL
+ 'name': 'STORAGE_BASE_URL',
+ 'value': process.env.STORAGE_BASE_URL
})
env.push({
- "name": "STORAGE_CONNECTION_STRING",
- "value": process.env.STORAGE_CONNECTION_STRING
+ 'name': 'STORAGE_CONNECTION_STRING',
+ 'value': process.env.STORAGE_CONNECTION_STRING
})
env.push({
- "name": "AUTH_URL",
- "value": process.env.AUTH_URL
+ 'name': 'AUTH_URL',
+ 'value': process.env.AUTH_URL
})
env.push({
- "name": "AUTH_CLIENT_ID",
- "value": process.env.AUTH_CLIENT_ID
+ 'name': 'AUTH_CLIENT_ID',
+ 'value': process.env.AUTH_CLIENT_ID
})
env.push({
- "name": "AUTH_CLIENT_SECRET",
- "value": process.env.AUTH_CLIENT_SECRET
+ 'name': 'AUTH_CLIENT_SECRET',
+ 'value': process.env.AUTH_CLIENT_SECRET
})
env.push({
- "name": "AUTH_AUDIENCE",
- "value": process.env.AUTH_AUDIENCE
+ 'name': 'AUTH_AUDIENCE',
+ 'value': process.env.AUTH_AUDIENCE
})
- logger.debug("createClone General Financial Being Configuration.")
+ logger.debug('createClone General Financial Being Configuration.')
env.push({
- "name": "DEV_TEAM",
- "value": clone.teamSlug
+ 'name': 'DEV_TEAM',
+ 'value': clone.teamSlug
})
env.push({
- "name": "BOT",
- "value": clone.botSlug
+ 'name': 'BOT',
+ 'value': clone.botSlug
})
env.push({
- "name": "TYPE",
- "value": clone.botType
+ 'name': 'TYPE',
+ 'value': clone.botType
})
env.push({
- "name": "CLONE_ID",
- "value": clone.id.toString()
+ 'name': 'CLONE_ID',
+ 'value': clone.id.toString()
})
env.push({
- "name": "START_MODE",
- "value": clone.mode
+ 'name': 'START_MODE',
+ 'value': clone.mode
})
env.push({
- "name": "RUN_AS_TEAM",
- "value": clone.runAsTeam.toString()
+ 'name': 'RUN_AS_TEAM',
+ 'value': clone.runAsTeam.toString()
})
env.push({
- "name": "USER_LOGGED_IN",
- "value": clone.userLoggedIn
+ 'name': 'USER_LOGGED_IN',
+ 'value': clone.userLoggedIn
})
env.push({
- "name": "PROCESS",
- "value": clone.processName
+ 'name': 'PROCESS',
+ 'value': clone.processName
})
- logger.debug("createClone Trading Configuration.")
- if(clone.botType === TRADER ){
+ logger.debug('createClone Trading Configuration.')
+ if (clone.botType === TRADER) {
env.push({
- "name": "RESUME_EXECUTION",
- "value": clone.resumeExecution.toString()
+ 'name': 'RESUME_EXECUTION',
+ 'value': clone.resumeExecution.toString()
})
- if(clone.mode === BACKTEST){
+ if (clone.mode === BACKTEST) {
env.push({
- "name": "BEGIN_DATE_TIME",
- "value": toPlatformDatetime(clone.beginDatetime)
+ 'name': 'BEGIN_DATE_TIME',
+ 'value': toPlatformDatetime(clone.beginDatetime)
})
env.push({
- "name": "END_DATE_TIME",
- "value": toPlatformDatetime(clone.endDatetime)
+ 'name': 'END_DATE_TIME',
+ 'value': toPlatformDatetime(clone.endDatetime)
})
env.push({
- "name": "WAIT_TIME",
- "value": clone.waitTime.toString()
+ 'name': 'WAIT_TIME',
+ 'value': clone.waitTime.toString()
})
- } else{
+ } else {
env.push({
- "name": "KEY_ID",
- "value": clone.keyId
+ 'name': 'KEY_ID',
+ 'value': clone.keyId
+ })
+ }
+ } else if (clone.botType === INDICATOR || clone.botType === EXTRACTION) {
+ if (clone.mode !== NO_TIME) {
+ env.push({
+ 'name': 'MIN_YEAR',
+ 'value': isDefined(clone.startYear) ? clone.startYear.toString() : ''
+ })
+ env.push({
+ 'name': 'MAX_YEAR',
+ 'value': isDefined(clone.endYear) ? clone.endYear.toString() : ''
+ })
+ env.push({
+ 'name': 'MONTH',
+ 'value': isDefined(clone.month) ? clone.month.toString() : ''
+ })
+ env.push({
+ 'name': 'INTERVAL',
+ 'value': isDefined(clone.interval) ? clone.interval.toString() : ''
})
}
- } else if(clone.botType === INDICATOR || clone.botType === EXTRACTION ){
- if(clone.mode !== NO_TIME){
- env.push({
- "name": "MIN_YEAR",
- "value": isDefined(clone.startYear) ? clone.startYear.toString() : ''
- })
- env.push({
- "name": "MAX_YEAR",
- "value": isDefined(clone.endYear) ? clone.endYear.toString() : ''
- })
- env.push({
- "name": "MONTH",
- "value": isDefined(clone.month) ? clone.month.toString() : ''
- })
- env.push({
- "name": "INTERVAL",
- "value": isDefined(clone.interval) ? clone.interval.toString() : ''
- })
- }
}
deploymentManifest.spec.template.spec.containers[0].env = env
- const create = await client.apis.batch.v1.namespaces('default').jobs.post(
+ await client.apis.batch.v1.namespaces('default').jobs.post(
{ body: deploymentManifest })
- logger.debug("createClone %s on Kubernates success.", clone.id)
+ logger.debug('createClone %s on Kubernates success.', clone.id)
} catch (err) {
- throw new KubernateError(err)
+ throw new KubernateError(err)
}
}
export default createClone
diff --git a/server/src/kubernetes/removeClone.js b/server/src/kubernetes/removeClone.js
index 5af470b47..8bac6a3fa 100644
--- a/server/src/kubernetes/removeClone.js
+++ b/server/src/kubernetes/removeClone.js
@@ -4,25 +4,23 @@ import { Client, config } from 'kubernetes-client'
const removeClone = async (clone) => {
try {
- logger.debug("removeClone %s", clone.id)
+ logger.debug('removeClone %s', clone.id)
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
let query = {
- "qs":{
- "labelSelector": "job-name=" + clone.id
+ 'qs': {
+ 'labelSelector': 'job-name=' + clone.id
}
}
- const removed = await client.apis.batch.v1.namespaces('default').jobs(
- clone.id).delete()
+ await client.apis.batch.v1.namespaces('default').jobs(clone.id).delete()
const pod = await client.api.v1.namespaces('default').pods.get(query)
- const podRemoved = await client.api.v1.namespaces('default')
- .pods(pod.body.items[0].metadata.name).delete()
+ await client.api.v1.namespaces('default').pods(pod.body.items[0].metadata.name).delete()
- logger.debug("removeClone %s on kubernates succesful", clone.id)
+ logger.debug('removeClone %s on kubernates succesful', clone.id)
} catch (err) {
- throw new KubernateError(err)
+ throw new KubernateError(err)
}
}
export default removeClone
diff --git a/server/src/schema/mutations/AddCloneMutation.js b/server/src/schema/mutations/AddCloneMutation.js
index 072c4f8df..f41ee11e5 100644
--- a/server/src/schema/mutations/AddCloneMutation.js
+++ b/server/src/schema/mutations/AddCloneMutation.js
@@ -73,7 +73,7 @@ const resolve = async(parent, { clone }, context) => {
}
}
-const mutation = {
+const AddCloneMutation = {
addClone: {
type: CloneType,
args,
@@ -81,4 +81,4 @@ const mutation = {
}
}
-export default mutation
+export default AddCloneMutation
diff --git a/server/src/schema/mutations/RemoveCloneMutation.js b/server/src/schema/mutations/RemoveCloneMutation.js
index 32f33c3c3..c4509399f 100644
--- a/server/src/schema/mutations/RemoveCloneMutation.js
+++ b/server/src/schema/mutations/RemoveCloneMutation.js
@@ -64,7 +64,7 @@ const resolve = async (parent, { id }, context) => {
})
}
-const mutation = {
+const RemoveCloneMutation = {
removeClone: {
type: GraphQLString,
args,
@@ -72,4 +72,4 @@ const mutation = {
}
}
-export default mutation
+export default RemoveCloneMutation
diff --git a/server/src/schema/mutations/UpdateExecutionSummary.js b/server/src/schema/mutations/UpdateExecutionSummary.js
index 4e46d5f91..c3210c084 100644
--- a/server/src/schema/mutations/UpdateExecutionSummary.js
+++ b/server/src/schema/mutations/UpdateExecutionSummary.js
@@ -5,17 +5,13 @@ import {
GraphQLInt,
GraphQLFloat
} from 'graphql'
-
import {
OperationsError
} from '../../errors'
-
import { Clone } from '../../models'
import logger from '../../config/logger'
import teamQuery from '../../graphQLCalls/teamQuery'
-import authorizeClone from '../../graphQLCalls/authorizeClone'
import cloneDetails from '../cloneDetails'
-import removeKuberneteClone from '../../kubernetes/removeClone'
import { isDefined } from '../../config/utils'
const args = {
@@ -34,23 +30,22 @@ const resolve = async (parent,
{ id, summaryDate, buyAverage, sellAverage, marketRate, combinedProfitsA,
combinedProfitsB, assetA, assetB
}, context) => {
-
logger.debug('UpdateExecutionSummary -> Entering Function.')
if (!context.userId) {
throw new AuthentificationError()
}
- try{
+ try {
let sucessful
- let clone = await Clone.findOne( {
+ let clone = await Clone.findOne({
_id: id,
active: true
})
- if(!isDefined(clone)){
- return "Clone not found."
+ if (!isDefined(clone)) {
+ return 'Clone not found.'
}
let team = await teamQuery(context.authorization, clone.teamId)
@@ -72,7 +67,7 @@ const resolve = async (parent,
logger.debug('UpdateExecutionSummary -> Updating clone on database.')
await Clone.update(query, update, options, (err, clone) => {
- if (err){
+ if (err) {
logger.error('Error updating execution summary on the database. %s', err.stack)
throw err
} else {
@@ -81,16 +76,16 @@ const resolve = async (parent,
}
})
- if(sucessful)
+ if (sucessful) {
return 'Execution summary updated.'
-
+ }
} catch (error) {
logger.error('Error updating the execution summary. %s', error.stack)
throw new OperationsError(error.message)
}
}
-const mutation = {
+const UpdateExecutionSummary = {
updateExecutionSummary: {
type: GraphQLString,
args,
@@ -98,4 +93,4 @@ const mutation = {
}
}
-export default mutation
+export default UpdateExecutionSummary
diff --git a/server/src/schema/queries/GetClones.js b/server/src/schema/queries/GetClones.js
index 020b02474..f4902273f 100644
--- a/server/src/schema/queries/GetClones.js
+++ b/server/src/schema/queries/GetClones.js
@@ -53,7 +53,7 @@ const resolve = async(parent, { cloneIdList }, context) => {
}
}
-const query = {
+const GetClones = {
getClones: {
type: new GraphQLList(GetClonesType),
args,
@@ -61,4 +61,4 @@ const query = {
}
}
-export default query
+export default GetClones
diff --git a/server/src/schema/queries/HistoryClones.js b/server/src/schema/queries/HistoryClones.js
index bdf853f3c..081457f3b 100644
--- a/server/src/schema/queries/HistoryClones.js
+++ b/server/src/schema/queries/HistoryClones.js
@@ -10,8 +10,6 @@ import {
import { CloneType } from '../types'
import { Clone } from '../../models'
import logger from '../../config/logger'
-import getKuberneteClonePodStatus from '../../kubernetes/getClonePodStatus'
-import getKuberneteClonePodLogs from '../../kubernetes/getClonePodLogs'
import cloneDetails from '../cloneDetails'
import teamQuery from '../../graphQLCalls/teamQuery'
@@ -42,7 +40,7 @@ const resolve = async(parent, args, context) => {
}
}
-const query = {
+const HistoryClones = {
historyClones: {
type: new GraphQLList(CloneType),
args,
@@ -50,4 +48,4 @@ const query = {
}
}
-export default query
+export default HistoryClones
diff --git a/server/src/schema/queries/ListClones.js b/server/src/schema/queries/ListClones.js
index 9e80b9aec..b44458cf3 100644
--- a/server/src/schema/queries/ListClones.js
+++ b/server/src/schema/queries/ListClones.js
@@ -45,7 +45,7 @@ const resolve = async(parent, args, context) => {
}
}
-const query = {
+const ListClones = {
clones: {
type: new GraphQLList(CloneType),
args,
@@ -53,4 +53,4 @@ const query = {
}
}
-export default query
+export default ListClones