Error in alpaca-trade-api-python

Installed alpaca-trade-api-python using pip3 and tried running one of the place order examples posted under the API documentation and got these errors:

File “”, line 5
SECRET-KEY = “kJ/UM8hGCaDc7f86Hkf9YLAu66A0fiifdndaLwmf”
SyntaxError: can’t assign to operator
callie@DESKTOP-B3QDS5B:/mnt/c/Documents/codewall/Trading/Alpaca$ python3
Traceback (most recent call last):
File “”, line 1, in
import alpaca_trade_api as tradeapi
File “/usr/local/lib/python3.6/site-packages/alpaca_trade_api/”, line 1, in
from .rest import REST # noqa
File “/usr/local/lib/python3.6/site-packages/alpaca_trade_api/”, line 12, in
from .entity import (
File “/usr/local/lib/python3.6/site-packages/alpaca_trade_api/”, line 1, in
import pandas as pd
File “/usr/local/lib/python3.6/site-packages/pandas/”, line 55, in
from pandas.core.api import (
File “/usr/local/lib/python3.6/site-packages/pandas/core/”, line 24, in
from pandas.core.groupby import Grouper, NamedAgg
File “/usr/local/lib/python3.6/site-packages/pandas/core/groupby/”, line 1, in
from pandas.core.groupby.generic import ( # noqa: F401
File “/usr/local/lib/python3.6/site-packages/pandas/core/groupby/”, line 44, in
from pandas.core.frame import DataFrame
File “/usr/local/lib/python3.6/site-packages/pandas/core/”, line 88, in
from pandas.core.generic import NDFrame, _shared_docs
File “/usr/local/lib/python3.6/site-packages/pandas/core/”, line 70, in
from import DataFrameFormatter, format_percentiles
File “/usr/local/lib/python3.6/site-packages/pandas/io/formats/”, line 48, in
from import _expand_user, _stringify_path
File “/usr/local/lib/python3.6/site-packages/pandas/io/”, line 3, in
import bz2
File “/usr/local/lib/python3.6/”, line 23, in
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named ‘_bz2’

I’m running Ubuntu 16.04

This if the file I’m running:

import alpaca_trade_api as tradeapi

not working

place new orders

api = tradeapi.REST()

Submit a market order to buy 1 share of Apple at market price


Submit a limit order to attempt to sell 1 share of AMD at a

particular price ($20.50) when the market opens


use google youll find an answer

client_order_id = ‘AAPL001’
api.submit_order(‘AAPL’, 100, ‘buy’, ‘market’, ‘day’, client_order_id=client_order_id)

try this. the difference I see is you are specifying symbol = ‘blah’. the module doesnt say to do that except for a few of the optional extras like client_order_id. Im not a python expert, but i believe the order you put those items into the function matter so that AAPL pairs with symbol automatically.

1 Like