Giter Club home page Giter Club logo

finam-broker's Introduction

finam-broker

An implementation of trengin.Broker using Finam Trade API for creating automated trading robots.

Features

  • Opens position, changes stop loss and take profit, closes position.
  • Tracks open position.
  • Supports multiple open positions at the same time.

How to use

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.

Option

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

Checkup

Use finam-checkup for checking the ability to trade with a specific token and client id.

How to install

go install github.com/evsamsonov/finam-broker/cmd/finam-checkup@latest

How to use

finam-checkup [CLIENT_ID] [SECURITY_BOARD] [SECURITY_CODE] [-v]
Flag Description
-v Print logger output

Development

Makefile

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

TODO

  • Use protective spread for open position
  • Add commission to position
  • Remove duplicate events in order trade listener
  • Add unit tests

finam-broker's People

Contributors

evsamsonov avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.