-
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding slack imtegration example
- Loading branch information
Showing
11 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ _testmain.go | |
*.prof | ||
|
||
golang-crypto-trading-bot | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package strategies | ||
|
||
import ( | ||
"log" | ||
"time" | ||
|
||
"github.com/nlopes/slack" | ||
|
||
"github.com/shomali11/slacker" | ||
|
||
"github.com/saniales/golang-crypto-trading-bot/environment" | ||
"github.com/saniales/golang-crypto-trading-bot/exchangeWrappers" | ||
) | ||
|
||
var bot *slacker.Slacker | ||
|
||
// The following slack integration allows to send messages as a strategy. | ||
// RTM not supported (and usually not requested when trading, this is an automated bot). | ||
var slackIntegrationExample = IntervalStrategy{ | ||
model: StrategyModel{ | ||
Setup: func(exchangeWrappers.ExchangeWrapper, *environment.Market) error { | ||
// connect slack token | ||
bot = slacker.NewClient("YOUR-TOKEN-HERE") | ||
bot.Init(func() { | ||
log.Println("Slackbot Connected") | ||
}) | ||
bot.Err(func(err string) { | ||
log.Println("Error during slack bot connection: ", err) | ||
}) | ||
return bot.Listen() | ||
}, | ||
OnUpdate: func(exchangeWrappers.ExchangeWrapper, *environment.Market) error { | ||
//if updates has requirements | ||
bot.Client.PostMessage("DESIRED-CHANNEL", "OMG something happening!!!!!", slack.PostMessageParameters{}) | ||
return nil | ||
}, | ||
OnError: func(err error) { | ||
//log | ||
}, | ||
}, | ||
Interval: time.Second * 10, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters