mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-23 23:35:14 +00:00
common/strategy: add google sheet service configuration
This commit is contained in:
parent
eb9b3563da
commit
f70f39fdde
|
@ -88,7 +88,8 @@ func (s *Strategy) Initialize(ctx context.Context, environ *bbgo.Environment, se
|
||||||
})
|
})
|
||||||
|
|
||||||
if environ.GoogleSpreadSheetService != nil {
|
if environ.GoogleSpreadSheetService != nil {
|
||||||
// allocate a google spread sheet for this strategy
|
// allocate a Google spread sheet for this strategy
|
||||||
|
s.configureSpreadSheet()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !s.PositionHardLimit.IsZero() && !s.MaxPositionQuantity.IsZero() {
|
if !s.PositionHardLimit.IsZero() && !s.MaxPositionQuantity.IsZero() {
|
||||||
|
@ -105,3 +106,30 @@ func (s *Strategy) Initialize(ctx context.Context, environ *bbgo.Environment, se
|
||||||
s.ProfitStats)
|
s.ProfitStats)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Strategy) configureSpreadSheet() error {
|
||||||
|
sheetSrv := s.Environ.GoogleSpreadSheetService
|
||||||
|
// allocate a Google spread sheet for this strategy
|
||||||
|
spreadsheet, err := sheetSrv.Get(true)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("spreadsheet loaded: %+v", spreadsheet)
|
||||||
|
|
||||||
|
profitStatsTitle := "profitStats-" + s.Position.StrategyInstanceID
|
||||||
|
sheet, err := sheetSrv.LookupOrNewSheet(profitStatsTitle)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("sheet loaded: %+v", sheet)
|
||||||
|
|
||||||
|
column, err := sheetSrv.GetFirstColumn(sheet)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("column: %+v", column)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user