mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
interact: refactor generateStrategyButtonsForm()
This commit is contained in:
parent
9588064f19
commit
1a13826505
|
@ -65,10 +65,11 @@ func filterStrategyByInterface(checkInterface interface{}, exchangeStrategies ma
|
||||||
return strategies, found
|
return strategies, found
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateStrategyButtonsForm(strategies []string) [][3]string {
|
func generateStrategyButtonsForm(strategies map[string]SingleExchangeStrategy) [][3]string {
|
||||||
var buttonsForm [][3]string
|
var buttonsForm [][3]string
|
||||||
for _, strategy := range strategies {
|
signatures := getStrategySignatures(strategies)
|
||||||
buttonsForm = append(buttonsForm, [3]string{strategy, "strategy", strategy})
|
for _, signature := range signatures {
|
||||||
|
buttonsForm = append(buttonsForm, [3]string{signature, "strategy", signature})
|
||||||
}
|
}
|
||||||
|
|
||||||
return buttonsForm
|
return buttonsForm
|
||||||
|
@ -122,7 +123,7 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
// it.trader.exchangeStrategies
|
// it.trader.exchangeStrategies
|
||||||
// send symbol options
|
// send symbol options
|
||||||
if strategies, found := filterStrategyByInterface((*PositionReader)(nil), it.exchangeStrategies); found {
|
if strategies, found := filterStrategyByInterface((*PositionReader)(nil), it.exchangeStrategies); found {
|
||||||
reply.AddMultipleButtons(generateStrategyButtonsForm(getStrategySignatures(strategies)))
|
reply.AddMultipleButtons(generateStrategyButtonsForm(strategies))
|
||||||
reply.Message("Please choose one strategy")
|
reply.Message("Please choose one strategy")
|
||||||
} else {
|
} else {
|
||||||
reply.Message("No strategy supports PositionReader")
|
reply.Message("No strategy supports PositionReader")
|
||||||
|
@ -163,7 +164,7 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
// it.trader.exchangeStrategies
|
// it.trader.exchangeStrategies
|
||||||
// send symbol options
|
// send symbol options
|
||||||
if strategies, found := filterStrategyByInterface((*PositionCloser)(nil), it.exchangeStrategies); found {
|
if strategies, found := filterStrategyByInterface((*PositionCloser)(nil), it.exchangeStrategies); found {
|
||||||
reply.AddMultipleButtons(generateStrategyButtonsForm(getStrategySignatures(strategies)))
|
reply.AddMultipleButtons(generateStrategyButtonsForm(strategies))
|
||||||
reply.Message("Please choose one strategy")
|
reply.Message("Please choose one strategy")
|
||||||
} else {
|
} else {
|
||||||
reply.Message("No strategy supports PositionCloser")
|
reply.Message("No strategy supports PositionCloser")
|
||||||
|
@ -232,7 +233,7 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
// it.trader.exchangeStrategies
|
// it.trader.exchangeStrategies
|
||||||
// send symbol options
|
// send symbol options
|
||||||
if strategies, found := filterStrategyByInterface((*StrategyStatusReader)(nil), it.exchangeStrategies); found {
|
if strategies, found := filterStrategyByInterface((*StrategyStatusReader)(nil), it.exchangeStrategies); found {
|
||||||
reply.AddMultipleButtons(generateStrategyButtonsForm(getStrategySignatures(strategies)))
|
reply.AddMultipleButtons(generateStrategyButtonsForm(strategies))
|
||||||
reply.Message("Please choose a strategy")
|
reply.Message("Please choose a strategy")
|
||||||
} else {
|
} else {
|
||||||
reply.Message("No strategy supports StrategyStatusReader")
|
reply.Message("No strategy supports StrategyStatusReader")
|
||||||
|
@ -270,7 +271,7 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
// it.trader.exchangeStrategies
|
// it.trader.exchangeStrategies
|
||||||
// send symbol options
|
// send symbol options
|
||||||
if strategies, found := filterStrategyByInterface((*StrategyToggler)(nil), it.exchangeStrategies); found {
|
if strategies, found := filterStrategyByInterface((*StrategyToggler)(nil), it.exchangeStrategies); found {
|
||||||
reply.AddMultipleButtons(generateStrategyButtonsForm(getStrategySignatures(strategies)))
|
reply.AddMultipleButtons(generateStrategyButtonsForm(strategies))
|
||||||
reply.Message("Please choose one strategy")
|
reply.Message("Please choose one strategy")
|
||||||
} else {
|
} else {
|
||||||
reply.Message("No strategy supports StrategyToggler")
|
reply.Message("No strategy supports StrategyToggler")
|
||||||
|
@ -312,7 +313,7 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
// it.trader.exchangeStrategies
|
// it.trader.exchangeStrategies
|
||||||
// send symbol options
|
// send symbol options
|
||||||
if strategies, found := filterStrategyByInterface((*StrategyToggler)(nil), it.exchangeStrategies); found {
|
if strategies, found := filterStrategyByInterface((*StrategyToggler)(nil), it.exchangeStrategies); found {
|
||||||
reply.AddMultipleButtons(generateStrategyButtonsForm(getStrategySignatures(strategies)))
|
reply.AddMultipleButtons(generateStrategyButtonsForm(strategies))
|
||||||
reply.Message("Please choose one strategy")
|
reply.Message("Please choose one strategy")
|
||||||
} else {
|
} else {
|
||||||
reply.Message("No strategy supports StrategyToggler")
|
reply.Message("No strategy supports StrategyToggler")
|
||||||
|
@ -354,7 +355,7 @@ func (it *CoreInteraction) Commands(i *interact.Interact) {
|
||||||
// it.trader.exchangeStrategies
|
// it.trader.exchangeStrategies
|
||||||
// send symbol options
|
// send symbol options
|
||||||
if strategies, found := filterStrategyByInterface((*EmergencyStopper)(nil), it.exchangeStrategies); found {
|
if strategies, found := filterStrategyByInterface((*EmergencyStopper)(nil), it.exchangeStrategies); found {
|
||||||
reply.AddMultipleButtons(generateStrategyButtonsForm(getStrategySignatures(strategies)))
|
reply.AddMultipleButtons(generateStrategyButtonsForm(strategies))
|
||||||
reply.Message("Please choose one strategy")
|
reply.Message("Please choose one strategy")
|
||||||
} else {
|
} else {
|
||||||
reply.Message("No strategy supports EmergencyStopper")
|
reply.Message("No strategy supports EmergencyStopper")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user