An implementation of trengin.Broker using Finam Trade API for creating automated trading robots.
- Opens position, changes stop loss and take profit, closes position.
- Tracks open position.
- Supports multiple open positions at the same time.
Create a new Finam
object using constructor New
. Pass full-access token,
client id.
package main
import (
"context"
"log"
"github.com/evsamsonov/trengin/v2"
"github.com/evsamsonov/finam-broker"
)
func main() {
finamBroker := fnmbroker.New(
"token",
"123",
// options...
)
tradingEngine := trengin.New(&Strategy{}, finamBroker)
if err := tradingEngine.Run(context.Background()); err != nil {
log.Fatal("Trading engine crashed")
}
}
type Strategy struct{}
func (s *Strategy) Run(ctx context.Context, actions trengin.Actions) error { panic("implement me") }
See more details in trengin documentation.
You can configure Finam
to use Option
Methods | Returns Option which |
---|---|
WithLogger |
Sets logger. The default logger is no-op Logger. |
WithProtectiveSpreadPercent |
Sets protective spread in percent for executing orders. The default value is 1%. |
WithUseCredit |
Sets using credit funds for executing orders. |
WithSecurityCacheFile |
Sets path to securities cache file. Default is ./securities.json |
Use finam-checkup
for checking the ability to trade with a specific token and client id.
go install github.com/evsamsonov/finam-broker/cmd/finam-checkup@latest
finam-checkup [CLIENT_ID] [SECURITY_BOARD] [SECURITY_CODE] [-v]
Flag | Description |
---|---|
-v |
Print logger output |
Makefile tasks are required docker and golang.
$ make help
doc Run doc server using docker
lint Run golang lint using docker
pre-push Run golang lint and test
test Run tests
- Use protective spread for open position
- Add commission to position
- Remove duplicate events in order trade listener
- Add unit tests