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

Basestrategy rework #305

Merged
merged 44 commits into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7ebd395
Add base.py as new base for strategies
joelvai Aug 31, 2018
d66bb04
WIP Add logic to functions
joelvai Sep 3, 2018
b1b119b
Add documentation to truncate() in helper.py
joelvai Sep 6, 2018
9cccdd8
Refactor double to single quotes in ConfigElemet
joelvai Sep 6, 2018
d2ab2e4
WIP Change base.py functions and structure
joelvai Sep 6, 2018
bc4cdce
Refactor get market buy and sell orders
joelvai Sep 6, 2018
ad6b57c
Remove execute_bundle() from base.py
joelvai Sep 6, 2018
af6c7ed
Add calculate_worker_value() to base.py
joelvai Sep 7, 2018
3f0fa5c
Add fee_reservation parameter to balance()
joelvai Sep 7, 2018
b58a9e9
Remove duplicate function for getting order
joelvai Sep 7, 2018
9e386c7
Remove old calculate center price method
joelvai Sep 7, 2018
c7be01b
WIP Change base.py comments and functions
joelvai Sep 7, 2018
b0aef0a
Change comments on functions
joelvai Sep 11, 2018
7eecdfd
Add functions to get order fees
joelvai Sep 11, 2018
54a7460
Remove unused functions
joelvai Sep 11, 2018
be6e012
WIP Change get_market_center_price()
joelvai Sep 11, 2018
b7d3b72
Made center price and spread methods use get_market_sell/buy_price()
MarkoPaasila Sep 11, 2018
8c62a17
Merge pull request #302 from MarkoPaasila/basestrategy-rework
joelvai Sep 12, 2018
07695bd
WIP Change market price calculations
joelvai Sep 12, 2018
e0d9c3d
Refactor variables in get_market_center_price()
joelvai Sep 13, 2018
6d0e908
Remove todo comments
joelvai Sep 13, 2018
fea24d6
Remove base for restore_order()
joelvai Sep 13, 2018
9a1dfdb
Change get_market_buy_price()
joelvai Sep 13, 2018
1f981f5
Change get_market_sell_price()
joelvai Sep 13, 2018
982fb5a
Change fee asset for get_x_fee functions to BTS
joelvai Sep 13, 2018
30ea21c
Change comments on functions
joelvai Sep 13, 2018
21e3481
Merge branch 'master' into basestrategy-rework
joelvai Sep 13, 2018
7efc45a
Change get_own_spread() by removing depth
joelvai Sep 13, 2018
4f9108b
Add doc for WorkerController strategies()
joelvai Sep 13, 2018
18cd2a0
Refactor base.py variable names and ticker
joelvai Sep 13, 2018
ce01996
Add strategy_template.py
joelvai Sep 13, 2018
9da827c
Update cli_conf.py to use new StrategyBase
joelvai Sep 14, 2018
6de9454
Update worker.py to use new StrategyBase
joelvai Sep 14, 2018
0310770
Refactor Relative Orders to work with StrategyBase
joelvai Sep 14, 2018
90e1c44
Change basestrategy.rst to strategybase.rst
joelvai Sep 14, 2018
5d70892
Remove enchance_center_price()
joelvai Sep 14, 2018
3a0df0c
Refactor pause_worker() to pause()
joelvai Sep 14, 2018
a2acbfd
Update echo.py to use StrategyBase
joelvai Sep 14, 2018
2bd72c2
Remove get_external_price()
joelvai Sep 14, 2018
f5eb060
Change comments on function descriptions
joelvai Sep 14, 2018
03e4852
Fix problem where old cancel method was called
joelvai Sep 14, 2018
0584158
Remove code that was used for testing
joelvai Sep 14, 2018
e089dca
Change example fields to be more clear
joelvai Sep 14, 2018
a1928d9
Add support for the old BaseStrategy
joelvai Sep 14, 2018
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
12 changes: 6 additions & 6 deletions dexbot/cli_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Requires the 'whiptail' tool for text-based configuration (so UNIX only)
if not available, falls back to a line-based configurator ("NoWhiptail")

Note there is some common cross-UI configuration stuff: look in basestrategy.py
Note there is some common cross-UI configuration stuff: look in base.py
It's expected GUI/web interfaces will be re-implementing code in this file, but they should
understand the common code so worker strategy writers can define their configuration once
for each strategy class.
Expand All @@ -22,7 +22,7 @@
import subprocess

from dexbot.whiptail import get_whiptail
from dexbot.basestrategy import BaseStrategy
from dexbot.strategies.base import StrategyBase
import dexbot.helper

STRATEGIES = [
Expand Down Expand Up @@ -217,14 +217,14 @@ def configure_dexbot(config, ctx):
worker_name = whiptail.menu("Select worker to edit", [(i, i) for i in workers])
config['workers'][worker_name] = configure_worker(whiptail, config['workers'][worker_name])

strategy = BaseStrategy(worker_name, bitshares_instance=bitshares_instance, config=config)
strategy.purge()
strategy = StrategyBase(worker_name, bitshares_instance=bitshares_instance, config=config)
strategy.clear_all_worker_data()
elif action == 'DEL':
worker_name = whiptail.menu("Select worker to delete", [(i, i) for i in workers])
del config['workers'][worker_name]

strategy = BaseStrategy(worker_name, bitshares_instance=bitshares_instance, config=config)
strategy.purge()
strategy = StrategyBase(worker_name, bitshares_instance=bitshares_instance, config=config)
strategy.clear_all_worker_data()
elif action == 'NEW':
txt = whiptail.prompt("Your name for the new worker")
config['workers'][txt] = configure_worker(whiptail, {})
Expand Down
8 changes: 8 additions & 0 deletions dexbot/controllers/worker_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def __init__(self, view, bitshares_instance, mode):

@property
def strategies(self):
""" Defines strategies that are configurable from the GUI.

key: Strategy location in the project
name: The name that is shown in the GUI for user
form_module: If there is custom form module created with QTDesigner

:return: List of strategies
"""
strategies = collections.OrderedDict()
strategies['dexbot.strategies.relative_orders'] = {
'name': 'Relative Orders',
Expand Down
4 changes: 4 additions & 0 deletions dexbot/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def remove(path):

def truncate(number, decimals):
""" Change the decimal point of a number without rounding

:param float | number: A float number to be cut down
:param int | decimals: Number of decimals to be left to the float number
:return: Price with specified precision
"""
return math.floor(number * 10 ** decimals) / 10 ** decimals

Expand Down
Loading