diff --git a/client/package-lock.json b/client/package-lock.json
index a73a5e1d5..b3bdfc11c 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "@superalgos/operations-client",
- "version": "0.0.38",
+ "version": "0.0.41",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/client/src/GraphQL/models.js b/client/src/GraphQL/models.js
index ce2da851d..a45c7db0a 100644
--- a/client/src/GraphQL/models.js
+++ b/client/src/GraphQL/models.js
@@ -1,18 +1,3 @@
-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 = {
@@ -42,9 +27,6 @@ const indicatorProcessNames = {
Market: 'Multi-Period-Market'
}
-const tradingProcessNames = {
- TradingProcess: "Trading-Process"
-}
const botTypes = {
Trading: "Trading",
@@ -57,7 +39,15 @@ const exchanges = {
Poloniex: "Poloniex"
}
+const markets = {
+ USDT_BTC: "USDT_BTC"
+}
+
+const baseAssets = {
+ assetA: "USDT",
+ assetB: "BTC"
+}
+
export {
- tradingStartModes, tradingStartModesList, exchanges, indicatorStartModes, availableMonths,
- availableTimePeriods, sensorProcessNames, indicatorProcessNames, tradingProcessNames, botTypes
+ tradingStartModes, tradingStartModesList, exchanges, indicatorStartModes, availableTimePeriods, sensorProcessNames, indicatorProcessNames, botTypes, markets, baseAssets
}
diff --git a/client/src/utils/index.js b/client/src/utils/index.js
index a12aa4fa9..72c6b92e5 100644
--- a/client/src/utils/index.js
+++ b/client/src/utils/index.js
@@ -73,11 +73,3 @@ export function slugify (string) {
.replace(/-+$/, '') // Trim - from end of text
}
-export function getIndicatorYears () {
- const localDate = new Date()
- let availableYears = []
- for (var i = 2015; i <= localDate.getUTCFullYear(); i++) {
- availableYears[i - 2015] = i
- }
- return availableYears
-}
diff --git a/client/src/views/Clone/Add/index.js b/client/src/views/Clone/Add/index.js
index d8c8ca2cf..8ab5803de 100644
--- a/client/src/views/Clone/Add/index.js
+++ b/client/src/views/Clone/Add/index.js
@@ -6,10 +6,10 @@ import TopBar from '../../BannerTopBar'
import { withStyles } from '@material-ui/core/styles'
import classNames from 'classnames'
import styles from './styles'
-import { isDefined, getIndicatorYears } from '../../../utils'
+import { isDefined } from '../../../utils'
import {
- tradingStartModes, indicatorStartModes, availableMonths, availableTimePeriods,
- sensorProcessNames, indicatorProcessNames, tradingProcessNames, botTypes, exchanges
+ tradingStartModes, availableTimePeriods,
+ sensorProcessNames, indicatorProcessNames, botTypes, exchanges, markets, baseAssets
} from '../../../GraphQL/models'
import {
@@ -28,10 +28,10 @@ class AddClone extends Component {
this.state = {
user: JSON.parse(user),
selectedBot: { 'id': '' },
- mode: "noTime",
+ mode: tradingStartModes.backtest,
resumeExecution: false,
- beginDatetime: DateTime.local().minus({ days: 8 }).startOf('day'),
- endDatetime: DateTime.local(),
+ beginDatetime: DateTime.utc().minus({ days: 8 }).startOf('day'),
+ endDatetime: DateTime.utc(),
waitTime: 1,
state: '',
stateDatetime: 0,
@@ -43,7 +43,9 @@ class AddClone extends Component {
processName: indicatorProcessNames.Daily,
accessCodeOption: false,
accessCode: '',
- balanceAssetB: 0.001,
+ baseAssetBalance: 0,
+ market: markets.USDT_BTC,
+ baseAsset: baseAssets.assetA,
// Indicator Bot
startYear: 2019,
@@ -51,7 +53,7 @@ class AddClone extends Component {
month: 1,
//TradingBot
- timePeriod: '01-hs',
+ timePeriod: '',
//Error handlers
botError: false,
@@ -62,7 +64,7 @@ class AddClone extends Component {
processNameError: false,
keyIdError: false,
accessCodeError: false,
- balanceAssetBError: false
+ baseAssetBalanceError: false
}
}
@@ -176,8 +178,51 @@ class AddClone extends Component {
))}
+ this.setState({ timePeriod: e.target.value })}
+ fullWidth
+ >
+ {availableTimePeriods.map((option, index) => (
+
+ ))}
+
+
{this.state.selectedBot.kind === botTypes.Trading &&
+
+ this.setState({ market: e.target.value })}
+ fullWidth
+ >
+ {Object.keys(markets).map((option, index) => (
+
+ ))}
+
+
+ this.setState({ baseAsset: e.target.value })}
+ fullWidth
+ >
+ {Object.keys(baseAssets).map((option, index) => (
+
+ ))}
+
+
Available Running Modes are Backtest and Live.
@@ -293,7 +338,7 @@ class AddClone extends Component {
Because we are still in early alpha-testing phase,
Live Trading Clones are limited to an initial investment
- of 0.001 BTC. If you choose to run this bot or any modified
+ of 0.001 BTC or 10 USDT. If you choose to run this bot or any modified
version of the code, you are doing it at your own risk.
@@ -328,35 +373,17 @@ class AddClone extends Component {
/>
this.setState({ balanceAssetB: e.target.value })}
- onBlur={(e) => this.setState({ balanceAssetBError: false })}
- error={this.state.balanceAssetBError}
+ value={this.state.baseAssetBalance}
+ onChange={(e) => this.setState({ baseAssetBalance: e.target.value })}
+ onBlur={(e) => this.setState({ baseAssetBalanceError: false })}
+ error={this.state.baseAssetBalanceError}
fullWidth
/>
}
-
- The Time Period in which the bot will operate.
-
-
- this.setState({ timePeriod: e.target.value })}
- fullWidth
- >
- {availableTimePeriods.map((option, index) => (
-
- ))}
-
-
}
@@ -400,7 +427,7 @@ class AddClone extends Component {
}
- {(this.state.mode === "noTime" && this.state.selectedBot.kind !== botTypes.Sensor) &&
+ {(this.state.mode === "noTime" && this.state.selectedBot.kind === botTypes.Indicator) &&
The Resume Execution option let's you pick up the context of
@@ -525,21 +552,27 @@ class AddClone extends Component {
if (this.state.selectedBot.kind === "Trading") {
variables.clone.processName = 'Trading-Process'
variables.clone.timePeriod = this.state.timePeriod
+ variables.clone.baseAsset = this.state.baseAsset
+ variables.clone.market = this.state.market
if (this.state.mode === "backtest") {
- variables.clone.beginDatetime = this.state.beginDatetime.valueOf() / 1000 | 0
- variables.clone.endDatetime = this.state.endDatetime.valueOf() / 1000 | 0
+ let beginDate = DateTime.fromISO(this.state.beginDatetime.toISO({ includeOffset: false }), { zone: "UTC" });
+ let endDate = DateTime.fromISO(this.state.endDatetime.toISO({ includeOffset: false }), { zone: "UTC" });
+ variables.clone.beginDatetime = beginDate.valueOf() / 1000 | 0
+ variables.clone.endDatetime = endDate.valueOf() / 1000 | 0
variables.clone.waitTime = this.state.waitTime
} else {
variables.clone.keyId = this.state.keyId
variables.clone.accessCode = this.state.accessCode
- variables.clone.balanceAssetB = Number(this.state.balanceAssetB)
+ variables.clone.baseAssetBalance = Number(this.state.baseAssetBalance)
}
} else {
+ let beginDate = DateTime.fromISO(this.state.beginDatetime.toISO({ includeOffset: false }), { zone: "UTC" });
+
variables.clone.processName = this.state.processName
variables.clone.startYear = this.state.startYear
variables.clone.endYear = this.state.endYear
variables.clone.month = this.state.month
- variables.clone.beginDatetime = this.state.beginDatetime.valueOf() / 1000 | 0
+ variables.clone.beginDatetime = beginDate.valueOf() / 1000 | 0
}
return this.props.addCloneMutation({
@@ -561,8 +594,8 @@ class AddClone extends Component {
selectedBot: { 'id': '' },
mode: 'noTime',
resumeExecution: false,
- beginDatetime: DateTime.local().minus({ days: 8 }).startOf('day'),
- endDatetime: DateTime.local(),
+ beginDatetime: DateTime.utc().minus({ days: 8 }).startOf('day'),
+ endDatetime: DateTime.utc(),
waitTime: 1,
state: '',
stateDatetime: 0,
@@ -574,7 +607,9 @@ class AddClone extends Component {
keyId: '',
accessCodeOption: false,
accessCode: '',
- balanceAssetB: 0.001,
+ baseAssetBalance: 0,
+ market: markets.USDT_BTC,
+ baseAsset: baseAssets.assetA,
// Indicator Bot
startYear: 2019,
@@ -582,7 +617,7 @@ class AddClone extends Component {
month: 1,
//TradingBot
- timePeriod: '01-hs',
+ timePeriod: '',
//Error handlers
botError: false,
@@ -593,7 +628,7 @@ class AddClone extends Component {
processNameError: false,
keyIdError: false,
accessCodeError: false,
- balanceAssetBError: false
+ baseAssetBalanceError: false
})
};
@@ -632,15 +667,16 @@ class AddClone extends Component {
isError = true
this.setState(state => ({ accessCodeError: true }));
}
- if (this.state.balanceAssetB.length < 1 || isNaN(this.state.balanceAssetB)) {
+ if (this.state.baseAssetBalance.length < 1 || isNaN(this.state.baseAssetBalance)) {
isError = true
- this.setState(state => ({ balanceAssetBError: true }));
+ this.setState(state => ({ baseAssetBalanceError: true }));
}
}
return isError;
}
+
}
export default compose(
diff --git a/server/src/kubernetes/createClone.js b/server/src/kubernetes/createClone.js
index 202c20e45..a89ec00c0 100644
--- a/server/src/kubernetes/createClone.js
+++ b/server/src/kubernetes/createClone.js
@@ -94,6 +94,10 @@ const createClone = async (clone) => {
'value': datasetNames().get(clone.timePeriod)
})
+ env.push({
+ 'name': 'BASE_ASSET',
+ 'value': clone.baseAsset
+ })
env.push({
'name': 'INITIAL_BALANCE_ASSET_A',
'value': clone.balanceAssetA.toString()
diff --git a/server/src/schema/mutations/AddCloneMutation.js b/server/src/schema/mutations/AddCloneMutation.js
index 41dd97cf3..1cf7d4abb 100644
--- a/server/src/schema/mutations/AddCloneMutation.js
+++ b/server/src/schema/mutations/AddCloneMutation.js
@@ -52,13 +52,28 @@ const resolve = async (parent, { clone }, context) => {
// TODO Temporary Limitations on bot creation
if (clone.accessCode !== undefined && clone.accessCode.length > 0) {
if (clone.accessCode === process.env.ACCESS_CODE) {
- clone.balanceAssetA = Number(process.env.DEFAULT_BALANCE_ASSET_A)
+ if (clone.baseAsset === 'assetB') {
+ clone.balanceAssetA = 0
+ clone.balanceAssetB = clone.balanceBaseAsset
+ } else if (clone.baseAsset === 'assetA') {
+ clone.balanceAssetA = clone.balanceBaseAsset
+ clone.balanceAssetB = 0
+ } else {
+ throw new Error('Invalid base asset.')
+ }
} else {
throw new Error('Invalid access code.')
}
} else {
- clone.balanceAssetA = Number(process.env.DEFAULT_BALANCE_ASSET_A)
- clone.balanceAssetB = Number(process.env.DEFAULT_BALANCE_ASSET_B)
+ if (clone.baseAsset === 'assetB') {
+ clone.balanceAssetA = 0
+ clone.balanceAssetB = Number(process.env.DEFAULT_BALANCE_ASSET_B)
+ } else if (clone.baseAsset === 'assetA') {
+ clone.balanceAssetA = Number(process.env.DEFAULT_BALANCE_ASSET_A)
+ clone.balanceAssetB = 0
+ } else {
+ throw new Error('Invalid base asset.')
+ }
}
if (!(clone.teamSlug === "AAMasters" || clone.teamSlug === "AAVikings")) {
@@ -94,15 +109,15 @@ const resolve = async (parent, { clone }, context) => {
await createKubernetesClone(clone)
- if(clone.botType === Trading){
+ if (clone.botType === Trading) {
let productCodeName
- if(clone.mode === LIVE){
+ if (clone.mode === LIVE) {
productCodeName = 'Live Trading History'
}
- if(clone.mode === COMPETITION){
+ if (clone.mode === COMPETITION) {
productCodeName = 'Competition Trading History'
}
- if(clone.mode === BACKTEST){
+ if (clone.mode === BACKTEST) {
productCodeName = 'Backtest Trading History'
}
diff --git a/server/src/schema/types/input/Clone.js b/server/src/schema/types/input/Clone.js
index b4df8d345..2be02a3b3 100644
--- a/server/src/schema/types/input/Clone.js
+++ b/server/src/schema/types/input/Clone.js
@@ -27,8 +27,9 @@ const Type = new GraphQLInputObjectType({
keyId: { type: GraphQLString },
timePeriod: { type: GraphQLString },
exchangeName: { type: GraphQLString },
- balanceAssetA: { type: GraphQLFloat },
- balanceAssetB: { type: GraphQLFloat },
+ balanceBaseAsset: { type: GraphQLFloat },
+ market: { type: GraphQLString },
+ baseAsset: { type: GraphQLString },
accessCode: { type: GraphQLString }
})
})