Skip to content

Commit

Permalink
fix bugs for strategy code
Browse files Browse the repository at this point in the history
  • Loading branch information
msaltnet committed Mar 31, 2023
1 parent 3403c69 commit 4bdc03e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion smtm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
result = MassSimulator.make_config_json(
title=args.title,
budget=args.budget,
strategy_num=args.strategy,
strategy_code=args.strategy,
currency=args.currency,
from_dash_to=args.from_dash_to,
offset_min=args.offset,
Expand Down
4 changes: 2 additions & 2 deletions smtm/mass_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def draw_graph(return_list, mean=0, filename="mass-simulation-result.jpg"):
def make_config_json(
title="",
budget=50000,
strategy_num=0,
strategy_code="BNH",
interval=0.000001,
currency="BTC",
from_dash_to="210804.000000-210811.000000",
Expand Down Expand Up @@ -388,7 +388,7 @@ def make_config_json(
"title": title,
"description": "write descriptionf here",
"budget": budget,
"strategy": int(strategy_num),
"strategy": strategy_code,
"interval": interval,
"currency": currency,
"period_list": [],
Expand Down
2 changes: 1 addition & 1 deletion smtm/strategy_bnh.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class StrategyBuyAndHold(Strategy):

ISO_DATEFORMAT = "%Y-%m-%dT%H:%M:%S"
COMMISSION_RATIO = 0.0005
NAME = "BnH"
NAME = "Buy and Hold"
CODE = "BNH"

def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion smtm/telegram_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def __init__(self, token=None, chatid=None):
self.data_provider = None
self.trader = None
self.command_list = []
self._create_command()
self._update_strategy()
self._create_command()
self.currency = None
self.is_demo = False
if token is not None:
Expand Down
6 changes: 3 additions & 3 deletions tests/mass_simulator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_analyze_result_should_call_file_write_correctly(self, mock_file):
expected = [
"Title: BnH-2Hour\n",
"Description: mass-simluation-unit-test\n",
"Strategy: BnH, Budget: 50000, Currency: BTC\n",
"Strategy: Buy and Hold, Budget: 50000, Currency: BTC\n",
"2020-04-30T17:00:00 ~ 2020-04-30T20:00:00 (3)\n",
"수익률 평균: 1.793\n",
"수익률 편차: 0.595\n",
Expand Down Expand Up @@ -220,7 +220,7 @@ def test_make_config_json_should_make_json_file_correctly(self, mock_file, mock_
result = MassSimulator.make_config_json(
title="get_money",
budget=50000000000,
strategy_num=7,
strategy_code="SMA",
interval=0.777,
currency="USD",
from_dash_to="210804.000000-210804.030000",
Expand All @@ -230,7 +230,7 @@ def test_make_config_json_should_make_json_file_correctly(self, mock_file, mock_
config = mock_json.call_args[0][0]
self.assertEqual(config["title"], "get_money")
self.assertEqual(config["budget"], 50000000000)
self.assertEqual(config["strategy"], 7)
self.assertEqual(config["strategy"], "SMA")
self.assertEqual(config["interval"], 0.777)
self.assertEqual(config["currency"], "USD")
self.assertEqual(len(config["period_list"]), 2)
Expand Down
4 changes: 2 additions & 2 deletions tests/simulator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def test__set_budget_should_set_value(self):

def test__set_strategy_should_set_value(self):
simulator = Simulator()
simulator._set_strategy("2")
self.assertEqual(simulator.strategy, 2)
simulator._set_strategy("BNH")
self.assertEqual(simulator.strategy, "BNH")
self.assertEqual(type(simulator.budget), int)

def test__print_score_should_call_operator_get_score(self):
Expand Down

0 comments on commit 4bdc03e

Please sign in to comment.