Merge pull request #44 from AAVikings/master
Adding select for processes
This commit is contained in:
10 files changed
+132
-41
No files matched your search
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@superalgos/operations-client",
|
||||
"version": "0.0.17",
|
||||
"version": "0.0.18",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@superalgos/operations-client",
|
||||
"version": "0.0.18",
|
||||
"version": "0.0.21",
|
||||
"description": "Superalgos Operations client-side web app",
|
||||
"main": "src/index.js",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
const availableMonths = ['January', 'February', 'March', 'April', 'May', 'June',
|
||||
'July', 'August', 'September', 'October', 'November', 'December']
|
||||
const availableMonths = [
|
||||
'January',
|
||||
'February',
|
||||
'March',
|
||||
'April',
|
||||
'May',
|
||||
'June',
|
||||
'July',
|
||||
'August',
|
||||
'September',
|
||||
'October',
|
||||
'November',
|
||||
'December'
|
||||
]
|
||||
|
||||
const availableTimePeriods = ["24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs", "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min"]
|
||||
|
||||
const tradingStartModes = {
|
||||
live: 'Live',
|
||||
@@ -18,6 +32,14 @@ const indicatorStartModes = {
|
||||
noTime: 'No Time'
|
||||
}
|
||||
|
||||
const processNames = {
|
||||
Daily: 'Multi-Period-Daily',
|
||||
Market: 'Multi-Period-Market',
|
||||
Min: "One-Min-Daily-Candles-Volumes",
|
||||
Live: "Poloniex-Live-Trades",
|
||||
HoleFixing: "Poloniex-Hole-Fixing"
|
||||
}
|
||||
|
||||
const exchanges = [
|
||||
{
|
||||
id: '1',
|
||||
@@ -25,4 +47,4 @@ const exchanges = [
|
||||
}
|
||||
]
|
||||
|
||||
export { tradingStartModes, tradingStartModesList, exchanges, indicatorStartModes, availableMonths }
|
||||
export { tradingStartModes, tradingStartModesList, exchanges, indicatorStartModes, availableMonths, processNames, availableTimePeriods }
|
||||
@@ -6,7 +6,7 @@ import TopBar from '../../BannerTopBar'
|
||||
import { withStyles } from '@material-ui/core/styles'
|
||||
import classNames from 'classnames'
|
||||
import styles from './styles'
|
||||
import { tradingStartModes, indicatorStartModes, availableMonths } from '../../../GraphQL/models'
|
||||
import { tradingStartModes, indicatorStartModes, availableMonths, processNames, availableTimePeriods } from '../../../GraphQL/models'
|
||||
import { isDefined, getIndicatorYears } from '../../../utils'
|
||||
import {
|
||||
MenuItem, Button, TextField, FormControl, InputLabel, Input, Typography,
|
||||
@@ -43,6 +43,9 @@ class AddClone extends Component {
|
||||
month: 1,
|
||||
processName: '',
|
||||
|
||||
//TraderBot
|
||||
timePeriod: '01-hs',
|
||||
|
||||
//Error handlers
|
||||
nameError: false,
|
||||
teamError: false,
|
||||
@@ -215,19 +218,6 @@ class AddClone extends Component {
|
||||
className={classNames(classes.form, classes.textField)}
|
||||
fullWidth
|
||||
/>
|
||||
|
||||
<Typography className={classes.typography} variant='subtitle1' align='justify'>
|
||||
The Wait Time represent the number of miliseconds the bot will wait between executions.
|
||||
</Typography>
|
||||
|
||||
<TextField
|
||||
id="waitTime"
|
||||
label="Wait Time"
|
||||
className={classNames(classes.form, classes.textField)}
|
||||
value={this.state.waitTime}
|
||||
onChange={(e)=>this.setState({waitTime:e.target.value})}
|
||||
fullWidth
|
||||
/>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
@@ -290,6 +280,27 @@ class AddClone extends Component {
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
|
||||
|
||||
<Typography className={classes.typography} variant='subtitle1' align='justify'>
|
||||
The Time Period in which the bot will operate.
|
||||
</Typography>
|
||||
|
||||
<TextField
|
||||
select
|
||||
label="Time Period"
|
||||
className={classNames(classes.margin, classes.textField, classes.form)}
|
||||
value={this.state.timePeriod}
|
||||
onChange={(e)=> this.setState({timePeriod:e.target.value})}
|
||||
fullWidth
|
||||
>
|
||||
{availableTimePeriods.map((option, index) => (
|
||||
<MenuItem key={index} value={option}>
|
||||
{option}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
|
||||
{ false &&
|
||||
<React.Fragment>
|
||||
<Typography className={classes.typography} variant='subtitle1' align='justify'>
|
||||
@@ -320,6 +331,7 @@ class AddClone extends Component {
|
||||
|| this.state.selectedBot.kind === "EXTRACTOR") &&
|
||||
<React.Fragment>
|
||||
<TextField
|
||||
select
|
||||
label="Process Name"
|
||||
className={classNames(classes.textField, classes.form)}
|
||||
value={this.state.processName}
|
||||
@@ -327,7 +339,14 @@ class AddClone extends Component {
|
||||
onBlur={(e)=>this.setState({processNameError:false})}
|
||||
error={this.state.processNameError}
|
||||
fullWidth
|
||||
/>
|
||||
>
|
||||
{Object.keys(processNames).map(option => (
|
||||
<MenuItem key={option} value={processNames[option]}>
|
||||
{processNames[option]}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
|
||||
|
||||
<TextField
|
||||
select
|
||||
@@ -394,14 +413,14 @@ class AddClone extends Component {
|
||||
fullWidth
|
||||
>
|
||||
{getIndicatorYears().map((option, index) => (
|
||||
<MenuItem key={option} value={index}>
|
||||
<MenuItem key={index} value={option}>
|
||||
{option}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
|
||||
<TextField
|
||||
id="endYearInput"
|
||||
id="endMonthInput"
|
||||
select
|
||||
label="Month"
|
||||
className={classNames(classes.textField, classes.form)}
|
||||
@@ -409,8 +428,8 @@ class AddClone extends Component {
|
||||
onChange={(e)=> this.setState({month:e.target.value})}
|
||||
fullWidth
|
||||
>
|
||||
{availableMonths.map(option => (
|
||||
<MenuItem key={option} value={option}>
|
||||
{availableMonths.map((option, index) => (
|
||||
<MenuItem key={index} value={index+1}>
|
||||
{option}
|
||||
</MenuItem>
|
||||
))}
|
||||
@@ -506,6 +525,7 @@ class AddClone extends Component {
|
||||
if(this.state.selectedBot.kind === "TRADER"){
|
||||
variables.clone.runAsTeam = this.state.runAsTeam
|
||||
variables.clone.processName = 'Trading-Process'
|
||||
variables.clone.timePeriod = this.state.timePeriod
|
||||
if(this.state.mode === "backtest"){
|
||||
variables.clone.beginDatetime = this.state.beginDatetime.valueOf() / 1000|0
|
||||
variables.clone.endDatetime = this.state.endDatetime.valueOf() / 1000|0
|
||||
|
||||
@@ -88,6 +88,11 @@ const createClone = async (clone) => {
|
||||
'value': clone.resumeExecution.toString()
|
||||
})
|
||||
|
||||
env.push({
|
||||
'name': 'EXECUTION_PARAMETERS',
|
||||
'value': buildExecutionParameters(clone)
|
||||
})
|
||||
|
||||
if (clone.mode === BACKTEST) {
|
||||
env.push({
|
||||
'name': 'BEGIN_DATE_TIME',
|
||||
@@ -151,4 +156,36 @@ const createClone = async (clone) => {
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
}
|
||||
|
||||
function buildExecutionParameters(clone){
|
||||
let executionParameters = {}
|
||||
executionParameters.timePeriod = clone.timePeriod
|
||||
executionParameters.dataSet = datasetNames().get(clone.timePeriod)
|
||||
return executionParameters
|
||||
}
|
||||
|
||||
function datasetNames(){
|
||||
let dataSetMap = new Map()
|
||||
dataSetMap.set("24-hs","Multi-Period-Market")
|
||||
dataSetMap.set("12-hs","Multi-Period-Market")
|
||||
dataSetMap.set("08-hs","Multi-Period-Market")
|
||||
dataSetMap.set("06-hs","Multi-Period-Market")
|
||||
dataSetMap.set("04-hs","Multi-Period-Market")
|
||||
dataSetMap.set("03-hs","Multi-Period-Market")
|
||||
dataSetMap.set("02-hs","Multi-Period-Market")
|
||||
dataSetMap.set("01-hs","Multi-Period-Market")
|
||||
dataSetMap.set("45-min","Multi-Period-Daily")
|
||||
dataSetMap.set("40-min","Multi-Period-Daily")
|
||||
dataSetMap.set("30-min","Multi-Period-Daily")
|
||||
dataSetMap.set("20-min","Multi-Period-Daily")
|
||||
dataSetMap.set("15-min","Multi-Period-Daily")
|
||||
dataSetMap.set("10-min","Multi-Period-Daily")
|
||||
dataSetMap.set("05-min","Multi-Period-Daily")
|
||||
dataSetMap.set("04-min","Multi-Period-Daily")
|
||||
dataSetMap.set("03-min","Multi-Period-Daily")
|
||||
dataSetMap.set("02-min","Multi-Period-Daily")
|
||||
dataSetMap.set("01-min","Multi-Period-Daily")
|
||||
return dataSetMap
|
||||
}
|
||||
|
||||
export default createClone
|
||||
@@ -20,13 +20,18 @@ const getClonePodLogs = async (cloneName) => {
|
||||
'tailLines': '20'
|
||||
}
|
||||
}
|
||||
const logs = await client.api.v1.namespaces('default')
|
||||
.pods(pod.body.items[0].metadata.name).log.get(queryLogs)
|
||||
let logsArray = logs.body.split('\n')
|
||||
if(pod.body.items[0] !== undefined){
|
||||
const logs = await client.api.v1.namespaces('default')
|
||||
.pods(pod.body.items[0].metadata.name).log.get(queryLogs)
|
||||
let logsArray = logs.body.split('\n')
|
||||
|
||||
logger.debug('getClonePodLogs on kubernates successful.')
|
||||
logger.debug('getClonePodLogs on kubernates successful.')
|
||||
|
||||
return JSON.stringify(logsArray, null, 2)
|
||||
return JSON.stringify(logsArray, null, 2)
|
||||
} else {
|
||||
logger.warn('getClonePodStatus pod not found %s: ', cloneName)
|
||||
return "Logs not available."
|
||||
}
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Client, config } from 'kubernetes-client'
|
||||
const getClonePodStatus = async (cloneName) => {
|
||||
try {
|
||||
logger.debug('getClonePodStatus on kubernates started. ')
|
||||
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
|
||||
const client = new Client({ config: config.fromKubeconfig(), version: '1.9' })
|
||||
|
||||
let query = {
|
||||
'qs': {
|
||||
@@ -15,14 +15,20 @@ const getClonePodStatus = async (cloneName) => {
|
||||
|
||||
const pod = await client.api.v1.namespaces('default').pods.get(query)
|
||||
|
||||
let clonePodStatus = pod.body.items[0].status.containerStatuses[0].state
|
||||
if (pod.body.items[0] !== undefined) {
|
||||
let clonePodStatus = pod.body.items[0].status.containerStatuses[0].state
|
||||
|
||||
if (clonePodStatus.hasOwnProperty('terminated')
|
||||
&& clonePodStatus.terminated.hasOwnProperty('containerID')) {
|
||||
delete clonePodStatus.terminated.containerID
|
||||
if (clonePodStatus.hasOwnProperty('terminated')
|
||||
&& clonePodStatus.terminated.hasOwnProperty('containerID')) {
|
||||
delete clonePodStatus.terminated.containerID
|
||||
}
|
||||
logger.debug('getClonePodStatus %s on kubernates successful', cloneName)
|
||||
|
||||
return JSON.stringify(clonePodStatus, null, 2)
|
||||
} else {
|
||||
logger.warn('getClonePodStatus pod not found %s: ', cloneName)
|
||||
return " Clone not found on the server. "
|
||||
}
|
||||
logger.debug('getClonePodStatus %s on kubernates successful', cloneName)
|
||||
return JSON.stringify(clonePodStatus, null, 2)
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ const removeClone = async (clone) => {
|
||||
|
||||
logger.debug('removeClone %s on kubernates succesful', clone.id)
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
logger.warn('removeClone %s on kubernates failed, the job was not found on the server.', clone.id)
|
||||
}
|
||||
}
|
||||
export default removeClone
|
||||
@@ -21,7 +21,7 @@ const args = {
|
||||
clone: { type: CloneInputType }
|
||||
}
|
||||
|
||||
const resolve = async(parent, { clone }, context) => {
|
||||
const resolve = async (parent, { clone }, context) => {
|
||||
logger.debug('addClone -> Entering Fuction.')
|
||||
|
||||
if (!context.userId) {
|
||||
@@ -36,7 +36,7 @@ const resolve = async(parent, { clone }, context) => {
|
||||
throw new WrongArgumentsError('The bot type selected is not valid.')
|
||||
}
|
||||
|
||||
if ( (clone.mode === LIVE || clone.mode === COMPETITION) && !isDefined(clone.keyId)) {
|
||||
if ((clone.mode === LIVE || clone.mode === COMPETITION) && !isDefined(clone.keyId)) {
|
||||
throw new WrongArgumentsError('The key was not provided to run the clone.')
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ const resolve = async(parent, { clone }, context) => {
|
||||
} else {
|
||||
throw new AutorizationError()
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
await createKubernetesClone(clone)
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ const Type = new GraphQLInputObjectType({
|
||||
interval: { type: GraphQLInt },
|
||||
processName: { type: new GraphQLNonNull(GraphQLString) },
|
||||
botType: { type: new GraphQLNonNull(GraphQLString) },
|
||||
keyId: { type: GraphQLString }
|
||||
keyId: { type: GraphQLString },
|
||||
timePeriod: { type: GraphQLString }
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user