Remove timeframe from strategy (#13)
This commit is contained in:
@@ -1073,10 +1073,12 @@ export class ScenarioClient extends AuthorizedApiBase {
|
||||
return Promise.resolve<Scenario[]>(null as any);
|
||||
}
|
||||
|
||||
scenario_CreateScenario(name: string | null | undefined, strategies: string[]): Promise<Scenario> {
|
||||
scenario_CreateScenario(name: string | null | undefined, loopbackPeriod: number | null | undefined, strategies: string[]): Promise<Scenario> {
|
||||
let url_ = this.baseUrl + "/Scenario?";
|
||||
if (name !== undefined && name !== null)
|
||||
url_ += "name=" + encodeURIComponent("" + name) + "&";
|
||||
if (loopbackPeriod !== undefined && loopbackPeriod !== null)
|
||||
url_ += "loopbackPeriod=" + encodeURIComponent("" + loopbackPeriod) + "&";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
const content_ = JSON.stringify(strategies);
|
||||
@@ -1191,16 +1193,12 @@ export class ScenarioClient extends AuthorizedApiBase {
|
||||
return Promise.resolve<Strategy[]>(null as any);
|
||||
}
|
||||
|
||||
scenario_CreateStrategy(strategyType: StrategyType | undefined, timeframe: Timeframe | undefined, name: string | null | undefined, period: number | null | undefined, fastPeriods: number | null | undefined, slowPeriods: number | null | undefined, signalPeriods: number | null | undefined, multiplier: number | null | undefined, stochPeriods: number | null | undefined, smoothPeriods: number | null | undefined, cyclePeriods: number | null | undefined): Promise<Strategy> {
|
||||
scenario_CreateStrategy(strategyType: StrategyType | undefined, name: string | null | undefined, period: number | null | undefined, fastPeriods: number | null | undefined, slowPeriods: number | null | undefined, signalPeriods: number | null | undefined, multiplier: number | null | undefined, stochPeriods: number | null | undefined, smoothPeriods: number | null | undefined, cyclePeriods: number | null | undefined): Promise<Strategy> {
|
||||
let url_ = this.baseUrl + "/Scenario/strategy?";
|
||||
if (strategyType === null)
|
||||
throw new Error("The parameter 'strategyType' cannot be null.");
|
||||
else if (strategyType !== undefined)
|
||||
url_ += "strategyType=" + encodeURIComponent("" + strategyType) + "&";
|
||||
if (timeframe === null)
|
||||
throw new Error("The parameter 'timeframe' cannot be null.");
|
||||
else if (timeframe !== undefined)
|
||||
url_ += "timeframe=" + encodeURIComponent("" + timeframe) + "&";
|
||||
if (name !== undefined && name !== null)
|
||||
url_ += "name=" + encodeURIComponent("" + name) + "&";
|
||||
if (period !== undefined && period !== null)
|
||||
@@ -1583,7 +1581,7 @@ export class TradingClient extends AuthorizedApiBase {
|
||||
|
||||
let options_: RequestInit = {
|
||||
body: content_,
|
||||
method: "GET",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json"
|
||||
@@ -2206,11 +2204,11 @@ export interface Spotlight {
|
||||
export interface Scenario {
|
||||
name?: string | null;
|
||||
strategies?: Strategy[] | null;
|
||||
loopbackPeriod?: number | null;
|
||||
}
|
||||
|
||||
export interface Strategy {
|
||||
name?: string | null;
|
||||
timeframe?: Timeframe;
|
||||
type?: StrategyType;
|
||||
signalType?: SignalType;
|
||||
minimumHistory?: number;
|
||||
|
||||
@@ -1,13 +1,30 @@
|
||||
import type {
|
||||
TableInstance,
|
||||
UsePaginationInstanceProps,
|
||||
UsePaginationState,
|
||||
UseSortByInstanceProps,
|
||||
} from 'react-table'
|
||||
import type { Edge, Node } from 'reactflow'
|
||||
import type {TableInstance, UsePaginationInstanceProps, UsePaginationState, UseSortByInstanceProps,} from 'react-table'
|
||||
import type {Edge, Node} from 'reactflow'
|
||||
|
||||
import type {
|
||||
Account,
|
||||
AccountType,
|
||||
Backtest,
|
||||
Balance,
|
||||
BotType,
|
||||
Candle,
|
||||
FlowOutput,
|
||||
FlowType,
|
||||
IFlow,
|
||||
KeyValuePairOfDateTimeAndDecimal,
|
||||
MoneyManagement,
|
||||
Position,
|
||||
RiskLevel,
|
||||
Scenario,
|
||||
Signal,
|
||||
Ticker,
|
||||
Timeframe,
|
||||
TradeDirection,
|
||||
TradingBot,
|
||||
TradingExchanges
|
||||
} from '../generated/ManagingApi'
|
||||
import {FC, ReactNode} from 'react'
|
||||
|
||||
import type { Account, AccountType, Backtest, Balance, BotType, Candle, FlowOutput, FlowType, IFlow, KeyValuePairOfDateTimeAndDecimal, MoneyManagement, Position, RiskLevel, Scenario, Signal, Ticker, Timeframe, TradeDirection, TradingBot, TradingExchanges } from '../generated/ManagingApi'
|
||||
import { ReactNode, FC } from 'react'
|
||||
export type TabsType = {
|
||||
label: string
|
||||
index: number
|
||||
@@ -156,6 +173,7 @@ export type IBotList = {
|
||||
export type IScenarioFormInput = {
|
||||
name: string
|
||||
strategies: string[]
|
||||
loopbackPeriod: number | undefined
|
||||
}
|
||||
export type IScenarioList = {
|
||||
list: Scenario[]
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import type { SubmitHandler } from 'react-hook-form'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import React, {useEffect, useState} from 'react'
|
||||
import type {SubmitHandler} from 'react-hook-form'
|
||||
import {useForm} from 'react-hook-form'
|
||||
import 'react-toastify/dist/ReactToastify.css'
|
||||
|
||||
import useApiUrlStore from '../../app/store/apiStore'
|
||||
import { Modal, Toast } from '../../components/mollecules'
|
||||
import type { Scenario, Strategy } from '../../generated/ManagingApi'
|
||||
import { ScenarioClient } from '../../generated/ManagingApi'
|
||||
import type { IScenarioFormInput } from '../../global/type'
|
||||
import {Modal, Toast} from '../../components/mollecules'
|
||||
import type {Scenario, Strategy} from '../../generated/ManagingApi'
|
||||
import {ScenarioClient} from '../../generated/ManagingApi'
|
||||
import type {IScenarioFormInput} from '../../global/type'
|
||||
|
||||
import ScenarioTable from './scenarioTable'
|
||||
|
||||
@@ -22,7 +22,7 @@ const ScenarioList: React.FC = () => {
|
||||
async function createScenario(form: IScenarioFormInput) {
|
||||
const t = new Toast('Creating scenario')
|
||||
await client
|
||||
.scenario_CreateScenario(form.name, form.strategies)
|
||||
.scenario_CreateScenario(form.name, form.loopbackPeriod, form.strategies)
|
||||
.then((data: Scenario) => {
|
||||
t.update('success', 'Scenario created')
|
||||
setScenarios((arr) => [...arr, data])
|
||||
@@ -97,6 +97,17 @@ const ScenarioList: React.FC = () => {
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-control mb-5">
|
||||
<div className="input-group">
|
||||
<label htmlFor="name" className="label mr-6">
|
||||
Loopback period
|
||||
</label>
|
||||
<input
|
||||
className="bg-inherit w-full max-w-xs"
|
||||
{...register('loopbackPeriod')}
|
||||
></input>
|
||||
</div>
|
||||
</div>
|
||||
<div className="modal-action">
|
||||
<button type="submit" className="btn">
|
||||
Build
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import type { SubmitHandler } from 'react-hook-form'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import React, {useEffect, useState} from 'react'
|
||||
import type {SubmitHandler} from 'react-hook-form'
|
||||
import {useForm} from 'react-hook-form'
|
||||
import 'react-toastify/dist/ReactToastify.css'
|
||||
|
||||
import useApiUrlStore from '../../app/store/apiStore'
|
||||
import { Toast } from '../../components/mollecules'
|
||||
import type { Strategy } from '../../generated/ManagingApi'
|
||||
import {
|
||||
StrategyType,
|
||||
ScenarioClient,
|
||||
Timeframe,
|
||||
} from '../../generated/ManagingApi'
|
||||
import {Toast} from '../../components/mollecules'
|
||||
import type {Strategy} from '../../generated/ManagingApi'
|
||||
import {ScenarioClient, StrategyType, Timeframe,} from '../../generated/ManagingApi'
|
||||
|
||||
import StrategyTable from './strategyTable'
|
||||
|
||||
@@ -43,7 +39,6 @@ const StrategyList: React.FC = () => {
|
||||
await scenarioClient
|
||||
.scenario_CreateStrategy(
|
||||
form.type,
|
||||
form.timeframe,
|
||||
form.name,
|
||||
form.period,
|
||||
form.fastPeriods,
|
||||
|
||||
Reference in New Issue
Block a user