├── LICENSE ├── README.md ├── discord.py └── trade.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Andrew Sayadi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Webull-Trading-Bot 2 | Bot that scrapes Discord server for callouts and places appropriate option trade on Webull platform. 3 | 4 | Instructions: 5 | The only parts of the code you need to alter to make the program work for you is the token in discord.py and phone/password/trading PIN in trade.py. 6 | 7 | Phone is obviously your phone number that is associated with your Webull account and Password is the password that you use for your Webull account and place your Webull PIN that you use to unlock trading inside of wb.get_trade_token('') so that the program can unlock your account and allow access to trade. 8 | 9 | In order to get your token for discord.py to work, you need to open Discord in a BROWSER NOT THE APPLICATION. Then go to the server you want to be scraping messages from. Inspect the page (Control + Shift + c) and then type something in the textbox on discord on that server. If you select the "Network" tab at the top of inspect and then click on "typing" on the left side and scroll down the "Headers" tab to the right of "typing", you will see "authorization: " followed buy a string of random characters. That is your token, copy that and insert it into the provided space in discord.py 10 | 11 | Now that you have entered your phone number, password, and token. You should be able to scrape discord and let the bot place orders for you as they are called out on discord. That is unless you haven't installed the webull and websocket-client python packages... 12 | You can simply install those with pip if you have not already. 13 | 14 | Running Instructions: 15 | The verifcation process involves you answering a security question and providing the question ID. The answer to the question is based off of whatever you wrote for it when you created your Webull account. As for the question ID, just enter the ID that is printed out to the console that is provided with the question prompt. 16 | 17 | This program is not financial advise, use at your own risk and understand that you are responsible for understanding the code and what it is doing as well as that it is designed to place orders based off of call outs from discord trading servers. You should treat this program as an educational tool and if you want to use it for real world application you should make your own necessary tweaks to it to make it perform how YOU want it to. 18 | 19 | Again, I am not liable for any outcomes you get from using this code. Use your money at your own risk. 20 | -------------------------------------------------------------------------------- /discord.py: -------------------------------------------------------------------------------- 1 | import websocket 2 | import json 3 | 4 | def send_json_request(ws, request): 5 | ws.send(json.dumps(request)) 6 | 7 | def receive_json_response(ws): 8 | response = ws.recv() 9 | if response: 10 | return json.loads(response) #was json_loads(response) but that wasnt recognized 11 | 12 | ws = websocket.WebSocket() 13 | ws.connect("wss://gateway.discord.gg/?v=6&encording=json") 14 | heartbeat_interval = receive_json_response(ws)["d"]["heartbeat_interval"] 15 | 16 | token = "see README for instructions on how to get your token for this" 17 | 18 | payload = { 19 | "op": 2, 20 | "d": { 21 | "token": token, 22 | "intents": 513, 23 | "properties": { 24 | "$os": 'linux', 25 | "$browser": 'chrome', 26 | "$device": 'pc' 27 | } 28 | } 29 | } 30 | send_json_request(ws, payload) 31 | 32 | while True: 33 | event = receive_json_response(ws) 34 | try: 35 | content = event['d']['content'] 36 | author = event['d']['author']['username'] 37 | print(f'{author}: {content}') 38 | except: 39 | pass 40 | -------------------------------------------------------------------------------- /trade.py: -------------------------------------------------------------------------------- 1 | from webull import webull 2 | 3 | phone = '+1-phonenumber' #updated per user 4 | pw = 'your webull account password' #updated per user 5 | 6 | stockTik = 'SONY' 7 | expire = '2022-06-22' #YYY-MM-DD 8 | strikePrice = '97' 9 | 10 | wb = webull() 11 | 12 | print(wb.get_mfa(phone)) 13 | mfa_code = input("Verification Code: ") 14 | print(wb.get_security(phone)) 15 | answer = input("Security Question Answer: ") 16 | question_id = input("Question ID: ") #we can automate these with if statements if we know what all the security questions are 17 | data = wb.login(phone, pw, 'PythonTest', mfa_code, question_id, answer) 18 | print("Passed Verification") 19 | print(wb.get_trade_token('your trading PIN')) #updated per user 20 | 21 | #wb.place_order_option() 22 | 23 | orders = wb.get_current_orders() 24 | positions = wb.get_positions() 25 | acctStatus = wb.get_account() 26 | 27 | contract = wb.get_options_by_strike_and_expire_date(stock=stockTik, expireDate=expire, strike=strikePrice, direction='all') 28 | 29 | exp = wb.get_options_expiration_dates(stock=stockTik) 30 | 31 | print(acctStatus) 32 | 33 | #current situation: arent able to get proper thing to return to contract variable, could be the expire date. --------------------------------------------------------------------------------