Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_maintain_strategy_one_sided #721

Merged
merged 4 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ name: Feature request
about: Suggest an idea for this project

---


3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ archive

# Bandit config
!bandit.yml

# pre-commit hooks
!.pre-commit-config.yaml
4 changes: 4 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]
line_length = 120
multi_line_output = 3
include_trailing_comma = True
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Read up on pre-commit
# https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/

repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-yaml
- id: end-of-file-fixer
- id: no-commit-to-branch
- id: flake8

- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
hooks:
- id: isort

- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- id: black
language_version: python3
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include *.md
include dexbot/resources/img/*
include dexbot/resources/img/*
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ Join the [Telegram Chat for DEXBot](https://t.me/DEXBOTbts).

Install the software, use it and report any problems by creating a ticket.

Before commiting any changes first time, make sure to install pre-commit hooks!

```
pip install -r requirements-dev.txt
pre-commit install
```

* [New Contributors Guide](https://github.com/Codaone/DEXBot/wiki/New-Contributors-Guide)
* [Git Workflow](https://github.com/Codaone/DEXBot/wiki/Git-Workflow)

Expand Down
67 changes: 17 additions & 50 deletions dexbot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,31 @@
import os.path
import signal
import sys
from multiprocessing import freeze_support

from uptick.decorators import online
import bitshares.exceptions
import click # noqa: E402
import graphenecommon.exceptions
from bitshares.market import Market

from dexbot.config import Config, DEFAULT_CONFIG_FILE
from dexbot.cli_conf import SYSTEMD_SERVICE_NAME, get_whiptail, setup_systemd
from dexbot.helper import initialize_orders_log, initialize_data_folders
from dexbot.ui import (
verbose,
chain,
unlock,
configfile,
reset_nodes
)
from dexbot.config import DEFAULT_CONFIG_FILE, Config
from dexbot.helper import initialize_data_folders, initialize_orders_log
from dexbot.ui import chain, configfile, reset_nodes, unlock, verbose
from uptick.decorators import online

from .worker import WorkerInfrastructure
from . import errors, helper
from .cli_conf import configure_dexbot, dexbot_service_running
from . import errors
from . import helper
from multiprocessing import freeze_support
from .worker import WorkerInfrastructure

# We need to do this before importing click
if "LANG" not in os.environ:
os.environ['LANG'] = 'C.UTF-8'
import click # noqa: E402


log = logging.getLogger(__name__)

# Initial logging before proper setup.
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s'
)
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')

# Configure orders logging
initialize_orders_log()
Expand All @@ -50,39 +39,18 @@

@click.group()
@click.option(
"--configfile",
default=DEFAULT_CONFIG_FILE,
"--configfile", default=DEFAULT_CONFIG_FILE,
)
@click.option(
'--logfile',
default=None,
type=click.Path(dir_okay=False, writable=True),
help='Override logfile location (example: ~/dexbot.log)'
)
@click.option(
'--verbose',
'-v',
type=int,
default=3,
help='Verbosity (0-15)')
@click.option(
'--systemd/--no-systemd',
'-d',
default=False,
help='Run as a daemon from systemd')
@click.option(
'--pidfile',
'-p',
type=click.Path(dir_okay=False, writable=True),
default='',
help='File to write PID')
@click.option(
'--sortnodes',
'-s',
type=int,
default=-1,
help='Sort nodes, w/max timeout in sec. [sec > 0]'
help='Override logfile location (example: ~/dexbot.log)',
)
@click.option('--verbose', '-v', type=int, default=3, help='Verbosity (0-15)')
@click.option('--systemd/--no-systemd', '-d', default=False, help='Run as a daemon from systemd')
@click.option('--pidfile', '-p', type=click.Path(dir_okay=False, writable=True), default='', help='File to write PID')
@click.option('--sortnodes', '-s', type=int, default=-1, help='Sort nodes, w/max timeout in sec. [sec > 0]')
@click.pass_context
def main(ctx, **kwargs):
ctx.obj = {}
Expand Down Expand Up @@ -131,6 +99,7 @@ def run(ctx):
if ctx.obj['systemd']:
try:
import sdnotify # A soft dependency on sdnotify -- don't crash on non-systemd systems

n = sdnotify.SystemdNotifier()
n.notify("READY=1")
except BaseException:
Expand Down Expand Up @@ -203,9 +172,7 @@ def cancel(ctx, market, account):
try:
my_market = Market(market)
ctx.bitshares.bundle = True
my_market.cancel([
x["id"] for x in my_market.accountopenorders(account)
], account=account)
my_market.cancel([x["id"] for x in my_market.accountopenorders(account)], account=account)
response = ctx.bitshares.txbuffer.broadcast()
log.info(response)
if response is not None:
Expand Down
Loading