Skip to content

Commit

Permalink
init: перенос кода из poptimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
WLM1ke committed Sep 23, 2022
0 parents commit d8b16c4
Show file tree
Hide file tree
Showing 79 changed files with 8,157 additions and 0 deletions.
120 changes: 120 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
.bin
env/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# PyCharm
.idea/

# PyTest
**.pytest_cache/

# Reports
/reports/

# MongoDB
/db/

# Portfolio data
/portfolio/*
!/portfolio/base.yaml

# Config data
/config/config.yaml

# Poptimizer logs
/logs/
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org>
94 changes: 94 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Цель проекта

Изучить Go путем реализации сбора данных по аналогии с [poptimizer](https://github.com/WLM1ke/poptimizer) + небольшой
Frontend на Alpine.js

## Frontend

Реализован Alpine.js в виде SPA со следующими основными разделами

### Tickers

Изменение перечня бумаг в портфеле, для которых необходимо отслеживать появление новых дивидендов среди всех бумаг,
обращающихся на MOEX

### Dividends

Обновление данных по дивидендам - производится сверка данных с информацией на сайтах:

- [www.nasdaq.com](https://www.nasdaq.com/)
- [закрытияреестров.рф](https://закрытияреестров.рф/)

Имеется возможность принятия отсутствующих, удаление лишних или ручного добавления новых значений.

### Accounts

Редактирование перечня брокерских счетов и находящихся на них бумаг

### Portfolio

Отображение суммарной стоимости и состава портфеля

## Автоматическое обновление
Большая часть данных обновляется на ежедневной основе после 0h45m MSK, когда на MOEX ISS обычно публикуются итоги
торгов. Координацией обновления занимается сервис Update, которой сначала обновляет рыночные данные, а после этого
запускает расчет актуализированной стоимости отдельных счетов и портфеля в целом. Если в процессе обновления возникают
ошибки, то ни логируются и отправляются в Telegram, а сам процесс по возможности продолжается. Более подробно
последовательность обновления изображена на диаграмме

```mermaid
flowchart TD
Update[\Update:0h45m MSK/]-->Data
subgraph Data
TradingDates-->USD
TradingDates-->CPI
TradingDates-->Indexes
TradingDates-->Securities
USD-->Dividends
Securities-->Dividends
Securities-->Status
Securities-->Backup
Securities-->Quotes
Status-->CloseReestry
Status-->NASDAQ
Status-->CheckRaw
end
subgraph Portfolio
Accounts-->Port[Portfolio]
end
Data-->Portfolio
```

## Ручное обновление данных

Вручную вводятся данные о дивидендах, выбранных для портфеля тикерах, чтобы для них отслеживалась актуальность
данных по дивидендам, и перечне и составе счетов.

```mermaid
flowchart
subgraph Frontend
Tickers[\Tickers/]
Dividends[\Dividends/]
Accounts[\Accounts/]
end
subgraph Data
Securities-->Backup
CheckRaw-->Backup
end
Tickers<-->Securities
Dividends<-->CheckRaw
subgraph Portfolio
Acc[Accounts] --> Port[Portfolio]
end
Accounts<-->Acc[Accounts]
```
8 changes: 8 additions & 0 deletions godata/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Данный файл можно переименовать в .env, в таком случае данные из него заменят дефолтные настройки

# URI для подсоединения к MongoDB
URI=mongodb://name:password@host

# Telegram API
TOKEN=token
CHAT_ID=id
147 changes: 147 additions & 0 deletions godata/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
run:
# Include test files or not.
# Default: true
tests: true

linters-settings:
gocritic:
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
# See https://github.com/go-critic/go-critic#usage -> section "Tags".
# Default: []
enabled-tags:
# - diagnostic
# - style
# - performance
# - experimental
- opinionated
# Which checks should be enabled; can't be combined with 'disabled-checks'.
# See https://go-critic.github.io/overview#checks-overview.
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`.
# By default, list of stable checks is used.
disabled-checks:
- hugeParam

linters:
enable:
- asciicheck
- bidichk
- bodyclose
- contextcheck
- cyclop
- deadcode
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- gofmt
- gofumpt
- goheader
- goimports
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- importas
- ineffassign
- lll
- makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- tenv
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- varcheck
- varnamelen
- wastedassign
- whitespace
- wrapcheck
- wsl
# Run only fast linters from enabled linters set (first run won't be fast)
# Default: false
fast: false

issues:
# Independently of option `exclude` we use default exclude patterns,
# it can be disabled by this option.
# To list all excluded by default patterns execute `golangci-lint run --help`.
# Default: true.
exclude-use-default: false
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- dupl
- funlen
- forcetypeassert
- wrapcheck
- path: mocks/
linters:
- forcetypeassert
- revive
- wrapcheck
- linters:
- errcheck
text: ".Close"
- linters:
- goerr113
text: "err113: do not define dynamic errors, use wrapped static errors instead:"
- linters:
- gomnd
source: "strconv.ParseFloat"
- linters:
- gosec
text: "G204: Subprocess launched with a potential tainted input or cmd arguments"
- linters:
- stylecheck
text: "ST1000: at least one file in a package should have a package comment"
- linters:
- wrapcheck
text: "error returned from interface method should be wrapped:"
- linters:
- wrapcheck
text: "error returned from external package is unwrapped: sig: func github.com/WLM1ke/poptimizer/opt/pkg"
fix: true
Loading

0 comments on commit d8b16c4

Please sign in to comment.