nelsondane / public-invest-api Goto Github PK
View Code? Open in Web Editor NEWUnofficial reverse-engineered Public.com Invest API written in Python Requests
License: MIT License
Unofficial reverse-engineered Public.com Invest API written in Python Requests
License: MIT License
So I have 2 py files and 1 is where I have my account so I made my wife an account and when I go to the api and setup a py for her since its in the same laptop it is saying that
{"code":null,"message":"Invalid credentials."}
Traceback (most recent call last):
File "C:\Users\thesy\Documents\Python\Public\public2.py", line 4, in
public.login(
File "C:\Users\thesy\AppData\Local\Programs\Python\Python312\Lib\site-packages\public_invest_api\public.py", line 80, in login
raise Exception("Login failed, check credentials")
Exception: Login failed, check credentials
This is my code right now ( i took off the login info)
import sys
import yfinance as yf
from public_invest_api import Public
def get_current_price(stock_symbol):
stock_data = yf.Ticker(stock_symbol)
current_price = stock_data.history(period="1d")["Close"].iloc[-1]
return current_price
public = Public()
public.login(
username='@gmail.com',
password='',
wait_for_2fa=True # When logging in for the first time, you need to wait for the SMS code
)
while True:
action = input("Enter '1' to BUY or '2' to SELL: ")
if action == '1':
action = 'BUY'
break
elif action == '2':
action = 'SELL'
break
else:
print("Invalid input. Please enter '1' to BUY or '2' to SELL.")
stock_symbol = input("Enter the stock ticker: ")
quantity = int(input("Enter the quantity: "))
current_price = get_current_price(stock_symbol)
current_price += 0.001
current_price = round(current_price, 2)
order = public.place_order(
symbol=stock_symbol,
quantity=quantity,
side=action,
order_type='LIMIT',
limit_price=current_price,
time_in_force='DAY', # 'GTC' or 'IOC' or 'FOK'
is_dry_run=False, # If True, it will not actually place the order
tip=0 # The amount to tip Public.com
)
print(order)
Are you intentionally trying to not have a utils.py or some other sort of collection of shortcut/pattern functions and instead leaving it up to each person to craft what they need?
I don't mind cleaning mine up and committing it for you to consider, I just didn't want to waste the time if it's intentional; like maybe if you didn't want it to be 'too easy' for someone to stumble into yolo'ing SPY puts.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.