Momentum-Trading-Example
Momentum-Trading-Example copied to clipboard
Swap out Alpaca live data with Polygon API directly?
I'm not a US citizen and therefore can't access live data from Alpaca within my demo account.
I'm implementing Polygon via seems to work.
def get_polygon_credentials(alpaca_key=None):
#try:
# alpaca_key, _, _ = get_credentials(alpaca_key, 'ignored')
#except ValueError:
# pass
key_id = '######################' # os.environ.get('POLYGON_KEY_ID') or alpaca_key
#if key_id is None:
# raise ValueError('Key ID must be given to access Polygon API'
# ' (env: APCA_API_KEY_ID or POLYGON_KEY_ID)')
return key_id
plus
from polygon import RESTClient
from polygon import WebSocketClient, STOCKS_CLUSTER
I could not get macd to recognise. So using:
from ta import trend
Then:
hist = trend.MACD
Are there any other ways advised to use Polygon data alongside Alpaca and can I therefore trade using ?
My output. Do the markets need to be live to run fully?
Getting current ticker data... Success. Tracking 0 symbols. Getting historical data... Success. Watching 0 symbols.