|
1 | 1 | # Description: This file contains the settings for trading.
|
2 |
| -from utils.wall_api_client import print_status |
3 |
| - |
4 | 2 |
|
5 | 3 | """ Step 1: ‼️ Important. Set up the broker name ‼️ """
|
6 | 4 | TRADING_BROKER = 'MooMoo' # set up the broker name based on the broker class name
|
|
12 | 10 | 'SCHWAB': SchwabBroker,
|
13 | 11 | """
|
14 | 12 |
|
15 |
| - |
16 | 13 | """ Step 2: ‼️ Important. Please choose qty decision mode, revise qty setting for each stock ‼️ """
|
17 | 14 | # Option 1: FUND_MODE, calculate the trading quantity based on the initial fund
|
18 | 15 | FUND_MODE = True # default to True, set to False if you want to use fixed qty
|
|
26 | 23 | ONE_PERCENT_TRADING_QTY_FOR_SOXL = 1 # default to 1, set the trading quantity for 1% of the initial fund
|
27 | 24 | ONE_PERCENT_TRADING_QTY_FOR_IBIT = 1 # default to 1, set the trading quantity for 1% of the initial fund
|
28 | 25 |
|
29 |
| - |
30 | 26 | """ Step 3: ‼️ Important. Please choose which level and which ticker you want to trade ‼️ """
|
31 | 27 | TRADING_LIST = ['TQQQ', 'SOXL', 'IBIT'] # set the trading list, delete the stock if you don't want to trade
|
32 | 28 | TRADING_LEVEL = ['L0', 'L1', 'L2', 'L3', 'L4'] # set the trading level, delete the level if you don't want to trade
|
33 | 29 |
|
34 |
| - |
35 |
| -""" Step 4 (Optional): Account settings, don't change the default setting unless you know what you are doing """ |
| 30 | +""" (Optional): Account settings, don't change the default setting unless you know what you are doing """ |
36 | 31 | TRADING_CONFIRMATION = True # default to True, set to False if you want to stop trading
|
37 | 32 | TRADING_CASH_THRESHOLD = 1 # set the minimum cash balance requirement after each trade
|
38 | 33 | TRADING_CASH_MARGIN_CONTROL = True # default to True, set to False if you want to use margin
|
39 | 34 | TRADING_ALLOW_PRE_POST_MARKET_ORDER = True # default to True, set to False if you don't want to trade in pre/post market
|
40 | 35 |
|
41 |
| - |
42 | 36 | """ Please don't change the code below, unless you know what you are doing """
|
43 |
| -level_positions = { |
| 37 | +""" Specific Trading Control Settings """ |
| 38 | +# trading position control: |
| 39 | +LEVEL_POSITIONS = { |
44 | 40 | # this is the default setting, which corresponds to the trading strategy for WallTrading Bot
|
45 | 41 | # please don't change the default setting, unless you know what you are doing
|
46 | 42 | # please contact the dev team for any questions
|
47 | 43 | 0: { # L0
|
48 | 44 | 'depth': {0: 0.01, 1: 0.01, 2: 0.01, 3: 0.00, 4: 0.00, 5: 0.02, 6: 0.02, 7: 0.03, 8: 0.04, 9: 0.04, 10: 0.05},
|
49 |
| - 'code': {3: 0.02} |
| 45 | + 'code': {3: 0.02}, |
| 46 | + 'enable': True # default to True, set to False if you don't want to trade at this level |
50 | 47 | },
|
51 | 48 | 1: { # L1
|
52 | 49 | 'depth': {0: 0.01, 1: 0.01, 2: 0.01, 3: 0.00, 4: 0.00, 5: 0.02, 6: 0.02, 7: 0.03, 8: 0.04, 9: 0.04, 10: 0.05},
|
53 |
| - 'code': {3: 0.03} |
| 50 | + 'code': {3: 0.03}, |
| 51 | + 'enable': True # default to True, set to False if you don't want to trade at this level |
54 | 52 | },
|
55 | 53 | 2: { # L2
|
56 | 54 | 'depth': {0: 0.02, 1: 0.02, 2: 0.02, 3: 0.00, 4: 0.00, 5: 0.00, 6: 0.04, 7: 0.04, 8: 0.05, 9: 0.06, 10: 0.07},
|
57 |
| - 'code': {3: 0.04} |
| 55 | + 'code': {3: 0.04}, |
| 56 | + 'enable': True # default to True, set to False if you don't want to trade at this level |
58 | 57 | },
|
59 | 58 | 3: { # L3
|
60 | 59 | 'depth': {0: 0.03, 1: 0.03, 2: 0.03, 3: 0.04, 4: 0.08, 5: 0.00, 6: 0.00, 7: 0.00, 8: 0.00, 9: 0.00, 10: 0.00},
|
61 |
| - 'code': {3: 0.08} |
| 60 | + 'code': {3: 0.08}, |
| 61 | + 'enable': True # default to True, set to False if you don't want to trade at this level |
62 | 62 | },
|
63 | 63 | 4: { # L4
|
64 | 64 | 'depth': {0: 0.15, 1: 0.22, 2: 0.22, 3: 0.25, 4: 0.25, 5: 0.00, 6: 0.00, 7: 0.00, 8: 0.00, 9: 0.00, 10: 0.00},
|
65 |
| - 'code': {3: 0.22} |
| 65 | + 'code': {3: 0.22}, |
| 66 | + 'enable': True # default to True, set to False if you don't want to trade at this level |
66 | 67 | }
|
67 | 68 | }
|
68 | 69 |
|
69 |
| -""" Please don't change the code below: """ |
70 |
| - |
71 |
| - |
72 |
| -def decision_qty(json_data) -> tuple[int, float]: |
73 |
| - """ |
74 |
| - :param json_data: |
75 |
| - :return: qty, position_pct |
76 |
| - """ |
77 |
| - |
78 |
| - level = int(json_data["level"][1:]) |
79 |
| - depth = int(json_data["depth"]) |
80 |
| - codeNum = int(json_data["codeNum"]) |
81 |
| - price = float(json_data["price"]) |
82 |
| - |
83 |
| - position_pct = 0 |
84 |
| - |
85 |
| - if level in level_positions: |
86 |
| - if depth in level_positions[level]['depth']: |
87 |
| - position_pct += level_positions[level]['depth'][depth] |
88 |
| - if codeNum in level_positions[level]['code']: |
89 |
| - position_pct += level_positions[level]['code'][codeNum] |
90 |
| - |
91 |
| - # check if the trading data is in the trading list and trading level |
92 |
| - if json_data["ticker"] not in TRADING_LIST: |
93 |
| - print_status("Decision QTY Handler", f"Warning, ticker not in the trading list, qty is 0, please check the trading settings", "WARNING") |
94 |
| - return 0, position_pct |
95 |
| - if json_data["level"] not in TRADING_LEVEL: |
96 |
| - print_status("Decision QTY Handler", f"Warning, level not in the trading level, qty is 0, please check the trading settings", "WARNING") |
97 |
| - return 0, position_pct |
98 |
| - |
99 |
| - # calculate the trading quantity, FUND_MODE |
100 |
| - if FUND_MODE: |
101 |
| - initial_fund = 0 |
102 |
| - |
103 |
| - if json_data["ticker"] == "TQQQ": |
104 |
| - initial_fund = INITIAL_FUND_FOR_TQQQ |
105 |
| - elif json_data["ticker"] == "SOXL": |
106 |
| - initial_fund = INITIAL_FUND_FOR_SOXL |
107 |
| - elif json_data["ticker"] == "IBIT": |
108 |
| - initial_fund = INITIAL_FUND_FOR_IBIT |
109 |
| - qty = int((position_pct * initial_fund) / price) |
110 |
| - # if qty < 1: |
111 |
| - # qty = 1 |
112 |
| - # print_status("Decision QTY Handler - FUND MODE", f"Warning, qty reset to: {qty}, please check the trading settings", "WARNING") |
113 |
| - # delete, choose to strictly follow the position percentage |
114 |
| - print_status("Decision QTY Handler - FUND MODE", f"Decision, qty is {qty}, please check the trading settings", "INFO") |
115 |
| - return qty, position_pct |
116 |
| - |
117 |
| - # calculate the trading quantity, QTY_MODE |
118 |
| - elif QTY_MODE: |
119 |
| - qty_one_percent = 1 |
120 |
| - if json_data["ticker"] == "TQQQ": |
121 |
| - qty_one_percent = ONE_PERCENT_TRADING_QTY_FOR_TQQQ |
122 |
| - elif json_data["ticker"] == "SOXL": |
123 |
| - qty_one_percent = ONE_PERCENT_TRADING_QTY_FOR_SOXL |
124 |
| - elif json_data["ticker"] == "IBIT": |
125 |
| - qty_one_percent = ONE_PERCENT_TRADING_QTY_FOR_IBIT |
126 |
| - qty = int(position_pct * 100) * qty_one_percent |
127 |
| - # if qty < 1: |
128 |
| - # qty = 1 |
129 |
| - # print_status("Decision QTY Handler - QTY MODE", f"Warning, qty reset to: {qty}, please check the trading settings", "WARNING") |
130 |
| - # delete, choose to strictly follow the position percentage |
131 |
| - print_status("Decision QTY Handler - QTY MODE", f"Decision, qty is {qty}, please check the trading settings", "INFO") |
132 |
| - return qty, position_pct |
| 70 | +# trading direction control: |
| 71 | +# buy side |
| 72 | +ENABLE_BUY_TQQQ = True # default to True, set to False if you don't want to buy TQQQ |
| 73 | +ENABLE_BUY_SOXL = True # default to True, set to False if you don't want to buy SOXL |
| 74 | +ENABLE_BUY_IBIT = True # default to True, set to False if you don't want to buy IBIT |
| 75 | +# sell side |
| 76 | +ENABLE_SELL_TQQQ = True # default to True, set to False if you don't want to sell TQQQ |
| 77 | +ENABLE_SELL_SOXL = True # default to True, set to False if you don't want to sell SOXL |
| 78 | +ENABLE_SELL_IBIT = True # default to True, set to False if you don't want to sell IBIT |
133 | 79 |
|
134 |
| - else: |
135 |
| - print_status("Decision QTY Handler", f"Warning, wrong decision mode, qty is 0, please check the trading settings", |
136 |
| - "WARNING") |
137 |
| - return 0, position_pct |
0 commit comments