Skip to content
This repository was archived by the owner on Oct 5, 2021. It is now read-only.

Commit 6e7b643

Browse files
committed
interpret args
1 parent 8c349ef commit 6e7b643

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

algocoin/custom_strategies.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, size: int) -> None:
2424

2525
def onBuy(self, res: TradeResponse) -> None:
2626
if not res.success:
27-
slog.critical('order failure: %s' % res)
27+
slog.critical('order failure: %s', res)
2828
return
2929

3030
if self._intitialvalue is None:
@@ -34,7 +34,7 @@ def onBuy(self, res: TradeResponse) -> None:
3434

3535
self.bought = res.volume*res.price
3636
self.bought_qty = res.volume
37-
slog.critical('d->g:bought %.2f @ %.2f for %.2f' % (res.volume, res.price, self.bought))
37+
slog.critical('d->g:bought %.2f @ %.2f for %.2f', res.volume, res.price, self.bought)
3838

3939
def onSell(self, res: TradeResponse) -> None:
4040
if not res.success:
@@ -44,7 +44,7 @@ def onSell(self, res: TradeResponse) -> None:
4444
sold = res.volume*res.price
4545
profit = sold - self.bought
4646
self.profits += profit
47-
slog.critical('g->d:sold %.2f @ %.2f for %.2f - %.2f - %.2f' % (res.volume, res.price, sold, profit, self.profits))
47+
slog.critical('g->d:sold %.2f @ %.2f for %.2f - %.2f - %.2f', res.volume, res.price, sold, profit, self.profits)
4848
self.bought = 0.0
4949
self.bought_qty = 0.0
5050

algocoin/lib/exchanges/gemini.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ def run(self, engine) -> None:
5858

5959
self._running = True
6060

61-
log.info('')
62-
log.info('Starting algo trading')
61+
log.critical('\n\nStarting algo trading\n\n')
6362
try:
6463
while True:
6564
self.receive()
@@ -107,7 +106,7 @@ def buy(self, req: TradeRequest) -> TradeResponse:
107106
}'''
108107
# FIXME check these
109108
if order.get('result') == 'error':
110-
log.critical("Order Error - %s" % order)
109+
log.critical("Order Error - %s", order)
111110
raise Exception('Order Error!')
112111

113112
executed_amount = float(order['executed_amount'])
@@ -152,7 +151,7 @@ def sell(self, req: TradeRequest) -> TradeResponse:
152151
order_execution=None)
153152

154153
if order.get('result') == 'error':
155-
log.critical("Order Error - %s" % order)
154+
log.critical("Order Error - %s", order)
156155
raise Exception('Order Error!')
157156

158157
executed_amount = float(order['executed_amount'])

algocoin/lib/parser.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ def _parse_strategy(strategy, config) -> None:
7474
continue
7575
splits = [x for x in strat.split(',') if x]
7676
cls = locate(splits[0])
77-
args = tuple(splits[1:]) if len(splits) > 1 else ()
77+
78+
args = []
79+
for x in splits[1:]:
80+
args.append(float(x) if x.isdigit() else x)
81+
args = tuple(args)
82+
7883
strat_configs.append(StrategyConfig(clazz=cls, args=args))
7984
config.strategy_options = strat_configs
8085

@@ -113,7 +118,7 @@ def _parse_args_to_dict(argv: list) -> dict:
113118

114119

115120
def _parse_live_options(argv, config: TradingEngineConfig) -> None:
116-
log.critical("WARNING: Live trading. money will be lost ;^)")
121+
log.critical("\n\nWARNING: Live trading. money will be lost ;^)\n\n")
117122
if argv.get('exchange'):
118123
config.exchange_options.exchange_type = str_to_exchange(argv['exchange'])
119124
elif argv.get('exchanges'):
@@ -124,7 +129,8 @@ def _parse_live_options(argv, config: TradingEngineConfig) -> None:
124129

125130

126131
def _parse_sandbox_options(argv, config) -> None:
127-
log.critical("Sandbox trading")
132+
log.critical("\n\nSandbox trading\n\n")
133+
128134
if argv.get('exchange'):
129135
config.exchange_options.exchange_type = str_to_exchange(argv['exchange'])
130136
elif argv.get('exchanges'):
@@ -135,8 +141,7 @@ def _parse_sandbox_options(argv, config) -> None:
135141

136142

137143
def _parse_backtest_options(argv, config) -> None:
138-
log.critical("Backtesting")
139-
144+
log.critical("\n\nBacktesting\n\n")
140145
config.backtest_options = BacktestConfig()
141146

142147
if argv.get('exchange'):
@@ -181,7 +186,7 @@ def parse_command_line_config(argv: list) -> TradingEngineConfig:
181186
if argv.get('print'):
182187
config.print = True
183188

184-
log.critical("Config : %s", str(config))
189+
log.debug("Config : %s", str(config))
185190

186191
return config
187192

algocoin/lib/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def set_verbose(level):
270270
# dlog.propagate = False # too much
271271
# tlog.propagate = True
272272
# mlog.propagate = True
273-
if level > 1:
273+
if level >= 2:
274274
log.setLevel(logging.DEBUG)
275275
slog.setLevel(logging.DEBUG)
276276
dlog.setLevel(logging.DEBUG)

algocoin/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main(argv: list) -> None:
2020
te = TradingEngine(config)
2121
application = ServerApplication(te)
2222

23-
log.critical('Server listening on port: %s', port)
23+
log.critical('\n\nServer listening on port: %s\n\n', port)
2424
application.listen(port)
2525
t = threading.Thread(target=tornado.ioloop.IOLoop.current().start)
2626
t.daemon = True # So it terminates on exit

config/sandbox_gemini.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[general]
2-
verbose=2
2+
verbose=0
33
print=0
44
TradingType=sandbox
55

0 commit comments

Comments
 (0)