Closed pq219 closed 9 months ago
Hello @pq219,
Thanks!
Also, can you tell us more about your environment?
Do you have TA Lib also installed in your environment?
$ pip list
Have you tried the development version?
$ pip install -U git+https://github.com/twopirllc/pandas-ta.git@development
psar
and many other indicators have had some fixes and speed improvements since v0.3.14bI am very new to coding and python so bare with me: In file
psar.py
, it works great in finding the PSAR but i am unable to move forward from this point and get robin-stocks to use this information to actually place a trade. any help or suggestions would be appreciated!
Whenever I am learning something new, I spend some time familiarizing myself with the documentation. Since you are using robin_stocks
, I would start with their documentation and examples.
Try this to calculate psar
with robin_stocks
. It's not perfect because I do not use Robinhood, so you may need a little tweaking. Additionally, you will need to do some post analysis of your psar
calculation to determine when to buy/sell etc.
from numpy import nan as npNaN
from pandas import DataFrame, Series
from pandas_ta.utils import get_offset, verify_series, zero
import robin_stocks.robinhood as rs
# Get your username and password from your Robinhood account
username, password = "xxxxxxx", "xxxxxxx"
# Asset ticker/symbol to retreive
ticker = "kold"
# Create a session with the Robinhood API
session = rs.login(username, password)
# Get the current stock price for KOLD as a single Python dictionary
# kold_price = rs.stocks.get_stock_quote_by_symbol("kold")
# Instead, use get_stock_historicals() which returns a list of dictionaries
# so it can be converted to a Pandas DataFrame
data = rs.stocks.get_stock_historicals(ticker, interval="day", span="year", bounds="regular")
# Convert data into a Pandas DataFrame
assetdf = DataFrame(data)
print(f"{assetdf.size=}")
assetdf.ta.psar(append=True) # Appends `psar` to assetdf
print(f"{assetdf.size=}") # Should be larger than the prior size
print(f"{ticker=}\n{assetdf}")
Kind Regards, KJ
Hello @pq219,
I assume by no response that the solution provided was sufficient. Thus I will be closing this issue in a few days.
Kind Regards, KJ
First, i would like to give a shout out to the creator of this because I have been trying every avenue to get a psar script that works. This one does!
I am very new to coding and python so bare with me: In file psar.py, it works great in finding the PSAR but i am unable to move forward from this point and get robin-stocks to use this information to actually place a trade. any help or suggestions would be appreciated!
This is what I have in VSC: