-
-
Notifications
You must be signed in to change notification settings - Fork 53
Quick start
For STANDALONE mode you can use both - pip and Docker deployment schemas, as you choice.
For margin mode - pip only.
For test purpose in STANDALONE mode create API key pair:
- Log in at Binance Spot Test Network
- Create API Key
You can test strategy on Binance, OKX and Bitfinex exchanges, where realized "paper trade mode"
- Register Telegram bot
- Get token
- Find channel_id. Just start IDBot and get channel_id
- After next step specify this data into
/home/ubuntu/.MartinBinance/config/ms_cfg.toml
for 'Demo - Binance', 0
- Install and run exchanges-wrapper server.
- Pull last version of martin-binance image
docker pull ghcr.io/dogstailfarmer/martin-binance:latest
The structure of the working directory will be created and the necessary files will be copied:
For Ubuntu it will be here: home/user/.MartinBinance/
docker run --rm --entrypoint /bin/sh martin-binance -c "cat ./martin_binance/__init__.py" > init.py && \
docker run --rm --entrypoint /bin/sh martin-binance -c "cat ./martin_binance/ms_cfg.toml.template" > ms_cfg.toml.template &&\
docker run --rm --entrypoint /bin/sh martin-binance -c "cat ./martin_binance/funds_rate.db.template" > funds_rate.db.template &&\
docker run --rm --entrypoint /bin/sh martin-binance -c "cat ./martin_binance/cli_0_BTCUSDT.py.template" > cli_0_BTCUSDT.py.template &&\
docker run --rm --entrypoint /bin/sh martin-binance -c "cat ./martin_binance/cli_2_AAABBB.py.template" > cli_2_AAABBB.py.template &&\
python3 init.py && rm init.py && rm ms_cfg.toml.template && rm funds_rate.db.template && rm cli_0_BTCUSDT.py.template && rm cli_2_AAABBB.py.template
docker run -itP \
--mount type=bind,source=/home/ubuntu/.MartinBinance,target=/home/appuser/.MartinBinance \
--network=host \
--restart=always \
--name=0-BTCUSDT \
martin-binance \
/home/appuser/.MartinBinance/cli_0_BTCUSDT.py 1
The last '1' it is parameter for silent restart with restore operational status.
.MartinBinance/cli_0_BTCUSDT.py
where trading parameters must be setting.
For auto update running containers recommended use Watchtower
pip install martin-binance
After first install find where pip installs packages, often it's /home/ubuntu/.local/lib/python3.10/site-packages
and run:
exchanges_wrapper/__init__.py
then
martin_binance/__init__.py
The structure of the working directory will be created and the necessary files will be copied. On init output you can find location.
- Specify api_key and api_secret in
/home/ubuntu/.MartinBinance/config/exch_srv_cfg.toml
- Run
exchanges_wrapper/exch_srv.py
in terminal window.
- Run
/home/ubuntu/.MartinBinance/cli_0_BTCUSDT.py
in other terminal window.
Strategy is started.
For upgrade to latest versions use:
pip install -U martin-binance
You must set pair name in three places the same (yes, it is crooked, but so far):
- base setting at top of the
cli_X_AAABBB.py
,ex.SYMBOL = 'AAABBB'
- the name of
cli_X_AAABBB.py
must match - the
X
it is index of element from exchange list inconfig/ms_cfg.toml
For 'Demo - Binance' and BTC/USDT trade pair it will be cli_0_BTCUSDT.py
- the name of pane in Tmux terminal window must match too, see explanation in the relevant section
For stop strategy use Ctrl-C and/or Telegram control function
For different OS paths will be different, this example for Ubuntu
- Install margin to the
~/opt/margin/
Change dir to the ~/opt/margin/resources/python/lib/python3.7/site-packages/
and install martin-binance there:
pip install --no-cache-dir -t . -U --ignore-requires-python --no-deps martin-binance
The margin terminal uses its own assembly Python3.7 which does not have some packages necessary for the strategy to work. They need to be installed.
For Ubuntu (Linux):
pip install --no-cache-dir -t . -U --ignore-requires-python --no-deps -r ./martin_binance/margin/margin_req.txt
For Ubuntu (Linux) also check if exist file
~/opt/margin/resources/python/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-x86_64-linux-gnu.so
and if not, copy it from martin_binance/margin/_sqlite3.cpython-37m-x86_64-linux-gnu.so
For Windows:
pip install -U wheel
pip install -U setuptools
pip install --use-pep517 --no-cache-dir -t . -U --ignore-requires-python --no-deps -r ./martin_binance/margin/margin_req_win.txt
For Windows download file margin_win_addon.zip
and unzip it to the C:\Users\UserName\AppData\Local\Programs\margin\resources\python\lib\python3.7\site-packages
if margin installed in that place or find it yourself
After first install run
site-packages/martin_binance/__init__.py
The structure of the working directory will be created and the necessary files will be copied. On init output you can find location.
- Create Telegram bot as described above and specify the data in
ms_cfg.toml
- Start margin in Demo mode
- Add currency pair BTC/USDT
- Set the custom fee level = 0.0% in the margin terminal settings
- Add Python strategy:
- Copy/paste the contents of the file
/home/ubuntu/.MartinBinance/cli_0_BTCUSDT.py
to the Code Editor window - Save, Run Strategy, Start
Strategy is started.
The selection of the pair is determined by the window of the terminal in which the strategy is launched.
You can ask any questions about strategy in discussions section. Create issue if you have trouble or suggestions for development.
1. Home
- Trade idea
- Features
- Quick start
- Terminal Tmux (useful tips)
-
How it's work
- Place grid
- Reverse
- Grid only
- Place take profit order
- Restart
- Fee options
- Keeping level of first asset
- Maintaining a supply of BNB in a sub-account to pay fees
- Deposit and withdraw assets on active strategy
- Telegram notification
- Telegram control
- Save data for external analytics
- Consolidated asset valuation
- Asset management
- Recovery after any reason crash, restart etc.
- Back testing and parameters optimization
- For developers