shirosaidev / stockbot Goto Github PK
View Code? Open in Web Editor NEWAlpaca algo stock trading bot
License: Apache License 2.0
Alpaca algo stock trading bot
License: Apache License 2.0
get_barset
was deprecated in favor of get_bars
. We also need to use TimeFrame.Day
. There are likely many other issues related to this, but I'm still working through them.
for d in data['data']['table']['rows']:
# Get daily price data for stock symbol over the last n trading days.
- barset = api.get_barset(d['symbol'], 'day', limit=MOVED_DAYS)
+ barset = api.get_bars(d['symbol'], TimeFrame.Day, limit=MOVED_DAYS)
if not barset[d['symbol']]:
print('stock symbol {} not found'.format(d['symbol']))
continue
Suggested fix:
# times to buy/sell
if startbuytime == 'buyatopen':
- get_stocks_h, get_stocks_m = BAO_GET_STOCKS_TIME.split(':')
- buy_sh, buy_sm = BAO_BUY_START_TIME.split(':')
- buy_eh, buy_em = BAO_BUY_END_TIME.split(':')
- sell_sh, sell_sm = BAO_SELL_START_TIME.split(':')
- sell_eh, sell_em = BAO_SELL_END_TIME.split(':')
+ get_stocks_h, get_stocks_m = list(map(int, BAO_GET_STOCKS_TIME.split(':')))
+ buy_sh, buy_sm = list(map(int, BAO_BUY_START_TIME.split(':')))
+ buy_eh, buy_em = list(map(int, BAO_BUY_END_TIME.split(':')))
+ sell_sh, sell_sm = list(map(int, BAO_SELL_START_TIME.split(':')))
+ sell_eh, sell_em = list(map(int, BAO_SELL_END_TIME.split(':')))
else: # buy at close
- get_stocks_h, get_stocks_m = BAC_GET_STOCKS_TIME.split(':')
- buy_sh, buy_sm = BAC_BUY_START_TIME.split(':')
- buy_eh, buy_em = BAC_BUY_END_TIME.split(':')
- sell_sh, sell_sm = BAC_SELL_START_TIME.split(':')
- sell_eh, sell_em = BAC_SELL_END_TIME.split(':')
+ get_stocks_h, get_stocks_m = list(map(int, BAC_GET_STOCKS_TIME.split(':')))
+ buy_sh, buy_sm = list(map(int, BAC_BUY_START_TIME.split(':')))
+ buy_eh, buy_em = list(map(int, BAC_BUY_END_TIME.split(':')))
+ sell_sh, sell_sm = list(map(int, BAC_SELL_START_TIME.split(':')))
+ sell_eh, sell_em = list(map(int, BAC_SELL_END_TIME.split(':')))
This really inhibits the usefulness of the application.
Would it be hard to have it load your current positions when it starts up?
I believe it also is the reason it throws the following error on startup:
2021-02-19T09:34:22.064436-05:00 selling stock if it goes up by 3%... Traceback (most recent call last): File "stockbot.py", line 638, in <module> main() File "stockbot.py", line 451, in main for stock in bought_stocks: UnboundLocalError: local variable 'bought_stocks' referenced before assignment
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.