Comments (16)
we will be releasing a fix soon (already in this PR if you want to try it out before we do: #24)
from alpaca-backtrader-api.
Hey all. Thought I would post my solution. I tried to make minimal changes to the code to get it working. I made 2 changes:
- In the trade API, I changed the polygon
rest.py
so that the methodhistoric_agg
is just a pass through tohistoric_agg_v2
. - I changed one line in
alpacastore.py
so that it always looks for atimestamp
in the record dictionary.
I set it up so that every call to historic_agg
still throws a deprecation warning so that people know that it is just getting passed through to historic_agg_v2
.
My forks are here if you want to take a look at what/how I did it. I think it needs more work to be generalized, but the example runs now.
https://github.com/Nicholas-Schaub/alpaca-trade-api-python
https://github.com/Nicholas-Schaub/alpaca-backtrader-api
from alpaca-backtrader-api.
Sure. The way I did it was:
- Clone each repo
pip install path/to/clone/directory
(or pip3 depending on how you have your environment set up)
Note: This should uninstall what you currently have installed and install the cloned repo.
from alpaca-backtrader-api.
Oh sweet, thanks! I'll add that in. I haven't studied the Alpaca code very much so not sure what else needs to be done...just wanted to get it working asap.
from alpaca-backtrader-api.
@shlomikushchi for what it's worth, receiving the following errors when running your commit:
`RuntimeError: There is no current event loop in thread 'Thread-2'.
500 Server Error: Internal Server Error for url: https://api.polygon.io/v2/aggs/ticker/SPY/range/1/day/2015-01-01T00:00:00/2020-03-29T03:29:42.791724?unadjusted=False&apiKey=yaddayadda`
Pretty sure I've set everything correctly. I can run @Nicholas-Schaub 's forks just fine.
from alpaca-backtrader-api.
new version (v0.5) is on pypi and you could install it via pip. if there are no new problems with this issue, I will consider it resolved and close the issue. let me know if something is still not working.
from alpaca-backtrader-api.
Yep i was about to submit this as well..
alpacastore.py
calls this: (comment is my own)
# needs to be v2
response = self.oapi.polygon.historic_agg(granularity,
dataname,
_from=start_dt,
to=end_dt)
It should be calling historic_agg_v2
. I'm tinkering with it, but will take a bit since the params and responses are different
from alpaca-backtrader-api.
I did the following and it's working (although few issues with some assets, not sure if related):
alpacastore.py
395: field = 'timestamp'
344: end_dt = dtend.strftime('%Y-%m-%d')
353: start_dt = dtkwargs['start'].strftime('%Y-%m-%d')
355: response = self.oapi.polygon.historic_agg_v2(dataname, 1,
granularity,
_from=start_dt,
to=end_dt)
I also reached out to the Polygon team, who said they would talk to the Alpaca team about it.
from alpaca-backtrader-api.
Nice..! Could try using the compression
parameter instead of the 1
there.. pretty sure that's the typical backtrader variable for numeric portion of aggregation period
from alpaca-backtrader-api.
thank you too.. your date formatting saved me time :)
At a quick glance, it appears to be working, but i haven't had a chance to really see what differences there are in the 2 response types. But everything looks pretty sane with these changes
from alpaca-backtrader-api.
Glad I could help!
from alpaca-backtrader-api.
@Nicholas-Schaub sorry but could you point me in the direction of how I'd call these forks locally when running backtrader-alpaca scripts?
I tried something like this: pip3 install git+https://github.com/your-repo.git but am still getting 404's when running code
I know this is like Python 101..
from alpaca-backtrader-api.
Echoing @cole-seph, I also get the 500 Server Error:
500 Server Error: Internal Server Error for url: https://api.polygon.io/v2/aggs/ticker/VOO/range/1/minute/2020-02-20T00:00:00/2020-03-30T00:00:00?unadjusted=False&apiKey=##############
If I paste this into a browser I get the response:
{"error":"Could not parse from date. Use YYYY-MM-DD or Unix MS Timestamps","status":"ERROR"}
If I delete the T and the zeros manually in the url in the browser I get a response with data as expected:
https://api.polygon.io/v2/aggs/ticker/VOO/range/1/minute/2020-02-20/2020-03-30?unadjusted=False&apiKey=##############
I haven't been able to get @Nicholas-Schaub 's fork to work yet either but I will try and investigate more later.
from alpaca-backtrader-api.
I had to do the following to fix the above:
in alpacastore.py
344: end_dt = dtend.strftime('%Y-%m-%d')
353: start_dt = dtkwargs['start'].strftime('%Y-%m-%d')
seemed to work
from alpaca-backtrader-api.
@wstewarttennes Thanks! Think that has me working for now, our line numbers were slightly different but I think it's working. Appreciate the help everyone!
from alpaca-backtrader-api.
ok, I have fixed the issues as you pointed out. code is now in the master branch. you could pull it from there. let me know if there are still any issues.
new pypi version will be released soon
from alpaca-backtrader-api.
Related Issues (20)
- Not a reliable API
- backtrader-api uses deprecated alpaca-trade-api - will it be migrated to alpaca-py?
- Documentation for creating new Alpaca is broken. HOT 1
- Trading Calender - Package Issue HOT 3
- Cannot import alpaca-backtrader-api (Python 3.9.9 MacOS) HOT 5
- backtest not going back far enough HOT 2
- Multiple datas has connection limited error?
- alpaca-trade-api uses UTC while `_clear_out_of_market_hours` assumes NY Time. HOT 1
- Alpaca AttributeError: 'Asset' has not attribute 'status'
- Data websocket error with paper trading. Error code = 1002 (protocol error)
- Multiple WebSocket Open or Proxy - for multiple strategies
- Cannot purchase Long and create a trailing stop
- The Default Value for 'stocklike'
- only getting minute data until 12pm EST everyday in historical mode HOT 1
- Multiple datas sample no longer works HOT 1
- alpaca-trade-api-python is being deprecated by alpaca-py HOT 1
- Replay with historical data only retrieve daily bars instead replaying every minute
- module 'finplot' has no attribute 'add_order' HOT 1
- error installing on Windows 11, Python 3.9 HOT 3
- Wrong timezone for DataFactory
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alpaca-backtrader-api.