Adding support for Indicators and Extractors
This commit is contained in:
1 parent
f942581f58
commit
a8ac7385d6
12 files changed
+325
-356
No files matched your search
@@ -1,11 +1,17 @@
|
||||
export const LIVE = 'Live';
|
||||
export const BACKTEST = 'Backtest';
|
||||
export const COMPETITION = 'Competition';
|
||||
export const LIVE = 'Live'
|
||||
export const BACKTEST = 'Backtest'
|
||||
export const COMPETITION = 'Competition'
|
||||
export const ALL_MONTHS = 'All Months'
|
||||
export const ONE_MONTH = 'One Month'
|
||||
export const NO_TIME = 'No Time'
|
||||
|
||||
export const CloneModeEnum = [
|
||||
LIVE,
|
||||
BACKTEST,
|
||||
COMPETITION
|
||||
];
|
||||
COMPETITION,
|
||||
ALL_MONTHS,
|
||||
ONE_MONTH,
|
||||
NO_TIME
|
||||
]
|
||||
|
||||
export default CloneModeEnum;
|
||||
export default CloneModeEnum
|
||||
File renamed without changes.
@@ -1,98 +0,0 @@
|
||||
import logger from '../config/logger'
|
||||
import { toPlatformDatetime } 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} from '../enums/CloneMode';
|
||||
|
||||
const platformExecutionContext = async (clone, cloneName) => {
|
||||
try {
|
||||
logger.info("createClone %j", cloneName)
|
||||
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
|
||||
|
||||
// Make changes to base deployment config
|
||||
deploymentManifest.metadata.name = cloneName
|
||||
|
||||
logger.debug("createClone Set basic environment configuration.")
|
||||
let env = envConfig
|
||||
|
||||
logger.debug("createClone Configuration for team, bot and process.")
|
||||
env.push({
|
||||
"name": "DEV_TEAM",
|
||||
"value": clone.teamId
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "BOT",
|
||||
"value": clone.botId
|
||||
})
|
||||
|
||||
// TODO allow other types
|
||||
env.push({
|
||||
"name": "PROCESS",
|
||||
"value": "Trading-Process"
|
||||
})
|
||||
|
||||
// TODO allow other types
|
||||
env.push({
|
||||
"name": "TYPE",
|
||||
"value": "Trading"
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "RUN_AS_TEAM",
|
||||
"value": clone.runAsTeam.toString()
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "USER_LOGGED_IN",
|
||||
"value": clone.userLoggedIn
|
||||
})
|
||||
|
||||
logger.debug("createClone Configuration for the execution.")
|
||||
env.push({
|
||||
"name": "START_MODE",
|
||||
"value": clone.mode.toLowerCase()
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "RESUME_EXECUTION",
|
||||
"value": clone.resumeExecution.toString()
|
||||
})
|
||||
|
||||
if(clone.mode === BACKTEST){
|
||||
env.push({
|
||||
"name": "BEGIN_DATE_TIME",
|
||||
"value": toPlatformDatetime(clone.beginDatetime)
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "END_DATE_TIME",
|
||||
"value": toPlatformDatetime(clone.endDatetime)
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "WAIT_TIME",
|
||||
"value": clone.waitTime.toString()
|
||||
})
|
||||
}
|
||||
|
||||
deploymentManifest.spec.template.spec.containers[0].env = env
|
||||
|
||||
// Create a new Deployment
|
||||
const create = await client.apis.batch.v1.namespaces('default').jobs.post(
|
||||
{ body: deploymentManifest })
|
||||
logger.debug("Create: %j ", create)
|
||||
|
||||
// Fetch the Deployment we just created
|
||||
const deployment = await client.apis.batch.v1.namespaces('default').jobs(
|
||||
deploymentManifest.metadata.name).get()
|
||||
logger.debug("Job: %j ", deployment)
|
||||
|
||||
logger.info("createClone %j succesfull", cloneName)
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
}
|
||||
export default platformExecutionContext
|
||||
@@ -1,98 +0,0 @@
|
||||
import logger from '../config/logger'
|
||||
import { toPlatformDatetime } 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} from '../enums/CloneMode';
|
||||
|
||||
const platformExecutionContext = async (clone, cloneName) => {
|
||||
try {
|
||||
logger.info("createClone %j", cloneName)
|
||||
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
|
||||
|
||||
// Make changes to base deployment config
|
||||
deploymentManifest.metadata.name = cloneName
|
||||
|
||||
logger.debug("createClone Set basic environment configuration.")
|
||||
let env = envConfig
|
||||
|
||||
logger.debug("createClone Configuration for team, bot and process.")
|
||||
env.push({
|
||||
"name": "DEV_TEAM",
|
||||
"value": clone.teamId
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "BOT",
|
||||
"value": clone.botId
|
||||
})
|
||||
|
||||
// TODO allow other types
|
||||
env.push({
|
||||
"name": "PROCESS",
|
||||
"value": "Trading-Process"
|
||||
})
|
||||
|
||||
// TODO allow other types
|
||||
env.push({
|
||||
"name": "TYPE",
|
||||
"value": "Trading"
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "RUN_AS_TEAM",
|
||||
"value": clone.runAsTeam.toString()
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "USER_LOGGED_IN",
|
||||
"value": clone.userLoggedIn
|
||||
})
|
||||
|
||||
logger.debug("createClone Configuration for the execution.")
|
||||
env.push({
|
||||
"name": "START_MODE",
|
||||
"value": clone.mode.toLowerCase()
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "RESUME_EXECUTION",
|
||||
"value": clone.resumeExecution.toString()
|
||||
})
|
||||
|
||||
if(clone.mode === BACKTEST){
|
||||
env.push({
|
||||
"name": "BEGIN_DATE_TIME",
|
||||
"value": toPlatformDatetime(clone.beginDatetime)
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "END_DATE_TIME",
|
||||
"value": toPlatformDatetime(clone.endDatetime)
|
||||
})
|
||||
|
||||
env.push({
|
||||
"name": "WAIT_TIME",
|
||||
"value": clone.waitTime.toString()
|
||||
})
|
||||
}
|
||||
|
||||
deploymentManifest.spec.template.spec.containers[0].env = env
|
||||
|
||||
// Create a new Deployment
|
||||
const create = await client.apis.batch.v1.namespaces('default').jobs.post(
|
||||
{ body: deploymentManifest })
|
||||
logger.debug("Create: %j ", create)
|
||||
|
||||
// Fetch the Deployment we just created
|
||||
const deployment = await client.apis.batch.v1.namespaces('default').jobs(
|
||||
deploymentManifest.metadata.name).get()
|
||||
logger.debug("Job: %j ", deployment)
|
||||
|
||||
logger.info("createClone %j succesfull", cloneName)
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
}
|
||||
export default platformExecutionContext
|
||||
@@ -46,7 +46,7 @@ const resolve = async(parent, { clone }, context) => {
|
||||
|
||||
logger.debug('addClone -> Checking existing clone %j', existingClone)
|
||||
if(isDefined(existingClone) && existingClone.length > 0){
|
||||
throw new CustomError('You can only create one clone per mode. Remove the'
|
||||
throw new CustomError('You can only have one active clone by mode. Remove the'
|
||||
+ ' existing clone of type: ' + clone.mode + ' and try again.')
|
||||
}
|
||||
|
||||
@@ -76,8 +76,7 @@ const resolve = async(parent, { clone }, context) => {
|
||||
`,
|
||||
},
|
||||
headers: {
|
||||
authorization: context.authorization,
|
||||
preshared: process.env.OPERATIONS_API_PRESHARED
|
||||
authorization: context.authorization
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user