WISEPLAT / backtrader_moexalgo

MOEX API AlgoPack integration with Backtrader. На данных с биржи MOEX теперь можно создавать полноценные торговые стратегии. Проводить Backtesting и делать Live торговлю через брокеров Алор, Финам и тех, у кого есть торговый терминал Quik.
MIT License
41 stars 23 forks source link
algo-trading algopack algotrading alor backtest backtesting backtesting-trading-strategies backtrader download-financial-data finam finance historical-data historical-price live-strategy moex tinkoff trading-algorithms trading-bot trading-robot trading-strategies

backtrader_moexalgo

Интеграция MOEX API AlgoPack с Backtrader. Этот код был написан для Хакатона GO ALGO организатором которого выступает биржа MOEX.

С помощью этой интеграции вы можете делать:

Для подключения к API мы используем библиотеку moexalgo.

Обучающее видео по работе с этой библиотекой можно посмотреть на YouTube и на RuTube

Установка

1) Самый простой способ:

pip install backtrader_moexalgo

или

git clone https://github.com/WISEPLAT/backtrader_moexalgo

или

pip install git+https://github.com/WISEPLAT/backtrader_moexalgo.git

2) Пожалуйста, используйте backtrader из моего репозитория (так как вы можете размещать в нем свои коммиты). Установите его:

pip install git+https://github.com/WISEPLAT/backtrader.git

-- Могу ли я использовать ваш интерфейс для moexalgo с оригинальным backtrader?

-- Да, вы можете использовать оригинальный backtrader, так как автор оригинального backtrader одобрил все мои изменения.

Вот ссылка: mementum/backtrader#472

3) У нас есть некоторые зависимости, вам нужно их установить:

pip install numpy pandas backtrader moexalgo requests websockets matplotlib

Начало работы

Чтобы было легче разобраться как всё работает, сделано множество примеров в папках DataExamplesMoexAlgo_ru и StrategyExamplesMoexAlgo_ru.

Внимание! Для получения Super Candles - необходима авторизация на сайте Московской биржи.

1. Активируйте эту строку:
store = MoexAlgoStore(login=ConfigMOEX.Login, password=ConfigMOEX.Password)  # Хранилище AlgoPack + авторизация на Московской Бирже

2. Заполните ваши учетные данные в файле Config.py
class Config:
    Login = '<Адрес электронной почты>'  # Адрес электронной почты, указанный при регистрации на сайте moex.com
    Password = '<Пароль>'  # Пароль от учетной записи на сайте moex.com

В папке DataExamplesMoexAlgo_ru находится код примеров по работе с биржевыми данными через API интерфейс MOEX.

В папке StrategyExamplesMoexAlgo_ru находится код примеров стратегий.

Спасибо

Важно

Исправление ошибок, доработка и развитие библиотеки осуществляется автором и сообществом!

Пушьте ваши коммиты!

Условия использования

Библиотека backtrader_moexalgo позволяющая делать интеграцию Backtrader и MOEX API - это Программа созданная исключительно для удобства работы. При использовании Программы Пользователь обязан соблюдать положения действующего законодательства Российской Федерации или своей страны. Использование Программы предлагается по принципу «Как есть» («AS IS»). Никаких гарантий, как устных, так и письменных не прилагается и не предусматривается. Автор и сообщество не дает гарантии, что все ошибки Программы были устранены, соответственно автор и сообщество не несет никакой ответственности за последствия использования Программы, включая, но, не ограничиваясь любым ущербом оборудованию, компьютерам, мобильным устройствам, программному обеспечению Пользователя вызванным или связанным с использованием Программы, а также за любые финансовые потери, понесенные Пользователем в результате использования Программы. Никто не ответственен за потерю данных, убытки, ущерб, включаю случайный или косвенный, упущенную выгоду, потерю доходов или любые другие потери, связанные с использованием Программы.

Программа распространяется на условиях лицензии MIT.

История звезд

Пожалуйста, поставьте Звезду 🌟 этому коду

Star History Chart

Star History

Please, put a Star 🌟 for this code

==========================================================================

backtrader_moexalgo

MOEX API integration with Backtrader. This code was written for GO ALGO Hackathon, organized by the MOEX exchange.

With this integration you can do:

For API connection we are using library moexalgo.

A tutorial video with this library can be viewed on YouTube and on RuTube

Installation

1) The simplest way:

pip install backtrader_moexalgo

or

git clone https://github.com/WISEPLAT/backtrader_moexalgo

or

pip install git+https://github.com/WISEPLAT/backtrader_moexalgo.git

2) Please use backtrader from my repository (as your can push your commits in it). Install it:

pip install git+https://github.com/WISEPLAT/backtrader.git

-- Can I use your interface for moexalgo with original backtrader?

-- Yes, you can use original backtrader, as the author of original backtrader had approved all my changes.

Here is the link: mementum/backtrader#472

3) We have some dependencies, you need to install them:

pip install numpy pandas backtrader moexalgo requests websockets matplotlib

Getting started

To make it easier to figure out how everything works, many examples have been made in the folders DataExamplesMoexAlgo and StrategyExamplesMoexAlgo.

Attention! To receive Super Candles, you need to log in to the Moscow Exchange website.

1. Activate this line:
store = MoexAlgoStore(login=ConfigMOEX.Login, password=ConfigMOEX.Password)  # Storage AlgoPack + authorization on the Moscow Stock Exchange

2. Fill in your credentials in the file Config.py
class Config:
    Login = '<Email address>'  # The email address provided during registration on the site moex.com
    Password = '<Password>'  # The password for the account on the site moex.com

The DataExamplesMoexAlgo folder contains the code of examples for working with exchange data via the MOEX API.

The StrategyExamplesMoexAlgo folder contains the code of sample strategies.

Thanks

License

MIT

Important

Error correction, revision and development of the library is carried out by the author and the community!

Push your commits!

Terms of Use

The backtrader_moexalgo library, which allows you to integrate Backtrader and MOEX API, is the Program created solely for the convenience of work. When using the Program, the User is obliged to comply with the provisions of the current legislation of his country. Using the Program are offered on an "AS IS" basis. No guarantees, either oral or written, are attached and are not provided. The author and the community does not guarantee that all errors of the Program have been eliminated, respectively, the author and the community do not bear any responsibility for the consequences of using the Program, including, but not limited to, any damage to equipment, computers, mobile devices, User software caused by or related to the use of the Program, as well as for any financial losses incurred by the User as a result of using the Program. No one is responsible for data loss, losses, damages, including accidental or indirect, lost profits, loss of revenue or any other losses related to the use of the Program.

The Program is distributed under the terms of the MIT license.