Merge pull request #628 from c9s/feature/optimizer

fix: fix summary report intervals
This commit is contained in:
Yo-An Lin 2022-05-20 00:55:53 +08:00 committed by GitHub
commit f38d165960
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 8 deletions

View File

@ -235,7 +235,7 @@ const ReportDetails = (props: ReportDetailsProps) => {
{
reportSummary.symbols.map((symbol: string, i: number) => {
return <TradingViewChart key={i} basePath={props.basePath} runID={props.runID} reportSummary={reportSummary}
symbol={symbol} intervals={["1m", "5m", "1h"]}/>
symbol={symbol}/>
})
}
</div>

View File

@ -329,10 +329,8 @@ const TradingViewChart = (props) => {
const chartContainerRef = useRef();
const chart = useRef();
const resizeObserver = useRef();
const [data, setData] = useState(null);
const [currentInterval, setCurrentInterval] = useState('5m');
const intervals = props.intervals || [];
const intervals = props.reportSummary.intervals || [];
useEffect(() => {
if (!chartContainerRef.current || chartContainerRef.current.children.length > 0) {

View File

@ -28,6 +28,7 @@ export interface ReportSummary {
endTime: Date;
sessions: string[];
symbols: string[];
intervals: string[];
initialTotalBalances: BalanceMap;
finalTotalBalances: BalanceMap;
symbolReports: SymbolReport[];

View File

@ -372,7 +372,6 @@ var BacktestCmd = &cobra.Command{
defer func() { _ = ordersTsv.Close() }()
_ = ordersTsv.Write(types.Order{}.CsvHeader())
defer ordersTsv.Flush()
for _, exSource := range exchangeSources {
exSource.Session.UserDataStream.OnOrderUpdate(func(order types.Order) {
if order.Status == types.OrderStatusFilled {
@ -463,14 +462,17 @@ var BacktestCmd = &cobra.Command{
}
allKLineIntervals := map[types.Interval]struct{}{}
for _, interval := range backTestIntervals {
allKLineIntervals[interval] = struct{}{}
}
for _, session := range environ.Sessions() {
for _, sub := range session.Subscriptions {
if sub.Channel == types.KLineChannel {
allKLineIntervals[types.Interval(sub.Options.Interval)] = struct{}{}
allKLineIntervals[sub.Options.Interval] = struct{}{}
}
}
}
for interval := range allKLineIntervals {
summaryReport.Intervals = append(summaryReport.Intervals, interval)
}
@ -584,7 +586,7 @@ func createSymbolReport(userConfig *bbgo.Config, session *bbgo.ExchangeSession,
sessionKLineIntervals := map[types.Interval]struct{}{}
for _, sub := range session.Subscriptions {
if sub.Channel == types.KLineChannel {
sessionKLineIntervals[types.Interval(sub.Options.Interval)] = struct{}{}
sessionKLineIntervals[sub.Options.Interval] = struct{}{}
}
}