PHP code example of metaseller / tinkoff-robot-buyer

1. Go to this page and download the library: Download metaseller/tinkoff-robot-buyer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

metaseller / tinkoff-robot-buyer example snippets


return [
    'app_name' => 'metaseller.tinkoff-robot-buyer',

    'profiles' => [
        'default' => [
            'secret_key' => 't.K......F',
            'default_account_id' => '2........3',

            'accounts' => [
                'account1' => '2........7',
                'account2' => '2........1',
                'account3' => '2........5',
            ],
        ],
    ],
];

return [
    [
        'active' => true,

        'profile' => 'default',
        'account' => 'account1',

        'etfs' => [
            'TMOS@' => [
                'INCREMENT_VALUE' => 1, // На сколько мы увеличиваем накопленное количество лотов позиций к покупке через каждый период
                'INCREMENT_PERIOD' => 5, // Период в минутах, через который мы инкрементируем количество лотов позиций к покупке
                'BUY_CHECK_PERIOD' => 1, // Период в минутах, через который мы проверяем возможность покупки накопленного количества лотов позиций
                'BUY_LOTS_BOTTOM_LIMIT' => 10, // Не пытаемся совершить покупку, пока не достигнут указанный накопленный лимит лотов к покупке
                'BUY_TRAILING_PERCENTAGE' => 0.18, //Величина в процентах, на которую текущая цена должна превысить трейлинг цену для совершения покупки
            ],
        ],
    ],
];

return [
    'test_strategy' => [
        'active' => true,

        'profile' => 'default',
        'account' => 'account3',

        'balance_control_accounts' => [
            'account2',
            'account3',
        ],

        'balance_shares_percentage' => 100 - (date('Y') - 1983),

        'parking_money_etf' => 'LQDT',
        'shares_money_limit' => 500000,

        'bonds' => file_exists(__DIR__ . '/strategy-manage-bonds.php') ? 

'balance_shares_percentage' => 100 - (date('Y') - 1983),

'parking_money_etf' => 'LQDT',

return [
    'LKOH' => 13,
    'SBER' => 13,
    'GAZP' => 6,
    'YDEX' => 7.7,
    'TATN' => 4.5,
    'NVTK' => 5,
    'T' => 5,
    'GMKN' => 4,
    'PLZL' => 3.6,
    'VTBR' => 3.5,
    'ROSN' => 2.7,
    'X5' => 2.5,
    'OZON' => 2.5,
    'SBERP' => 2.4,
    'SNGS' => 1.8,
    'SNGSP' => 1.8,
    'RUAL' => 0.6,
    'MOEX' => 1,
    'IRAO' => 1,
    'MTSS' => 1,
    'CHMF' => 0.8,
    'NLMK' => 0.7,
    'TATNP' => 0.8,
    'PHOR' => 3,
    'RTKM' => 0.5,
    'DOMRF' => 1.65,
    'MAGN' => 0.5,
    'ALRS' => 0.5,
    'TRNFP' => 0.5,
    'LENT' => 1.4,
    'SIBN' => 6,
    'AQUA' => 1.05,
];

LKOH	15.28
SBER	13.94
GAZP	9.51
YDEX	6.07
TATN	5.02
T	4.7
NVTK	4.08
GMKN	3.74
PLZL	3.65
VTBR	3.36
X5	2.86
ROSN	2.7
SBERP	2.69
OZON	2.53
SNGS	1.75
SNGSP	1.72
MOEX	1.17
IRAO	1.11
MTSS	1.1
RUAL	0.99
TATNP	0.87
HEAD	0.83
PIKK	0.8
CHMF	0.79
NLMK	0.73
DOMRF	0.64
PHOR	0.6
CBOM	0.57
AFLT	0.56
SVCB	0.51
RTKM	0.49
TRNFP	0.48
MAGN	0.45
VKCO	0.36
ALRS	0.36
AFKS	0.35
MDMG	0.35
BSPB	0.34
FLOT	0.33
ENPG	0.3
CNRU	0.29
LENT	0.24
POSI	0.22
UGLD	0.2
RENI	0.19
MSNG	0.19

return [
    'RU000A109L49' => 15, //АЛРОСА 001Р-01
    'RU000A10DY92' => 10, //Алроса 002P-01
    'RU000A10BPZ1' => 10, //АФК Система 002P-02
    'RU000A10CP78' => 15, //Банк ПСБ 004Р-01
    'RU000A1097S8' => 10, //Газпромбанк 005Р-04Р
    'RU000A106565' => 15, //Газпром нефть выпуск 6
    'RU000A10DHX9' => 10, //Инарктика 002Р-04
    'RU000A10DHV3' => 10, //Инарктика 002Р-05
    'RU000A10CQ77' => 15, //КАМАЗ БО-П16
    'RU000A10DBM5' => 10, //Кредитный поток 3.0
];

return [
    'account1' => [
        'token' => '1-------o',
        'chat_id' => '-41.......03',
    ],
    'account2' => [
        'token' => '1--------o',
        'chat_id' => '-9.........1',
    ],
    'account3' => [
        'token' => '1----------o',
        'chat_id' => '-4.........8',
    ],
];
shell
php yii info/accounts
shell
php yii info/imoex
shell
php yii rebalance/balance-state test_strategy
shell
php yii rebalance/shares-state test_strategy
shell
php yii rebalance/bonds-state test_strategy
shell
php yii info/user
shell
php yii info/accounts
shell
php yii info/portfolio account3
shell
php yii info/operations account3
shell
php yii info/funding account3
shell
Запрашиваем информацию о пополнениях счета 2........4
[2021 год] => 0 руб.
[2022 год] => 0 руб.
[2023 год] => 0 руб.
[2024 год] => 431810.02 руб.
[2025 год] => 710150.22 руб.
[2026 год] => 474695.61 руб.

[Всего] => 1616655.85 руб.

Разбивка по месяцам текущего года:
January -> 109465.08 руб.
February -> 101600 руб.
March -> 131465 руб.
April -> 124686.53 руб.
May -> 7479 руб.
June -> 0 руб.