Giter VIP home page Giter VIP logo

pyally's People

Contributors

alienbrett avatar jtraversa avatar laikan57 avatar mm0 avatar rjfranssen avatar rob-valdez avatar salient avatar tianyu00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyally's Issues

[Proposal] Proposal for Collaboration

@alienbrett @mm0,

Not sure the best way to go about this request so I will just throw it down here bluntly...

I propose that the three of us join forces on this project. @mm0 has added some great contributions in their own fork and I have since been adding code and documentation quality improvements to their fork as well. I have also been servicing a few issues on this repo.

@alienbrett, in the interest having a better SLA on issues and PRs, would you be opposed to:

  1. Merging https://github.com/mm0/PyAlly back into this repo
  2. Inviting @mm0 and I as collaborators on this repo?

I propose we setup the following branch protection rule on master so that 2 people (author and reviewer) are required to merge a change to master (and publish to PyPI):

image

(@alienbrett, I believe as the repo owner you can still override the review process for your own PRs.)

LMK what you think and/or feedback on what else we should do in the meantime.

Alphanumeric Account Numbers

In the library, there is an assumption that account identifiers are numeric (integer) only. Accounts can actually have alphabet characters in them.

I am trying to locate canonical documentation about this.

If I have time, I will also submit a PR in to resolve this.

order details/status

Can you provide an example for retrieving details for recent orders, including fill status, side, quantity, price, and symbol. I have tried ally.Ally.orders(), but the response is not comprehensive.

Trailing Stop order returns 500 Error

import ally

class AllyTrader():
    def __init__(self, use_real_money):
        self.ally = ally.Ally()

        # True preview_order means we will only preview
        # the order, not exectute it.
        # False means the order will execute
        self.preview_order = not use_real_money


    def place_trailing_limit_order(self, ticker, trailing_percent, quantity):

        order_price = ally.Order.TrailingStop(True, trailing_percent)

        order = ally.Order.Order(
            buysell = 'sell',
            symbol = ticker,     
            price = order_price,
            time = 'gtc',
            qty = quantity
        )

        print(str(order))
        self.ally.submit(order, preview=self.preview_order)
        print(order.orderid)
        return order

ally_trader=AllyTrader(False)
order = ally_trader.place_trailing_limit_order("AAPL",5,5)
print(order.id)

Is the trailing stop order type implemented in this library or are you trying to use the deprecated Ally functionality, resulting in an error?

issue getting holdings when there is only 1 asset.

There is a corner case when there is only 1 asset in an account. The code below from holdings.py expects a list in response but for only one asset it doesn't return a list.

def extract ( self, response ):
"""Extract certain fields from response
"""
response = response.json()['response']
holdings = response['accountholdings']['holding']

	return list( map( Holdings._flatten_holding, holdings ) )

The fix that I am doing locally is this to get over the issue.

def extract ( self, response ):
"""Extract certain fields from response
"""
response = response.json()['response']
holdings = response['accountholdings']['holding']

	**if not isinstance(holdings, list):
		holdings = [holdings]**

	return list( map( Holdings._flatten_holding, holdings ) )

Options code sample is incorrect

The query value is incorrect in the code sample (https://github.com/alienbrett/PyAlly/wiki/Option-Contracts)

Incorrect: query='xdate-eq:20201231',

It should be an array:
query=["xdate-eq:20201231","strikeprice-eq:180"]

The is the code sample:
available_options = a.search_options(
symbol='SPY',
query='xdate-eq:20201231', # Mature on 2020-12-31
fields=['bid','ask'] # 'bid,ask' also works. Function properly formats a list or a string
)

Order Status

Is there a way that we can get a list of order status?
According to the Api documentation here it appears that you can using the URL you are using in the order_history, however I am unable to retrieve a pending order status. Am I looking at this incorrectly?

Thanks for your help.

Documentation

Need to write documentation on how to use. Currently have to dig through the source code to figure out how to use it.

Invalid JSON Format

Hello Everyone,
Hope everyone is doing good and everyone is healthy. I ran into an issue relating to the JSON response format. According to the API documentation here the JSON response is expected in double quotes versus a single. I ran into this issue when I was trying to parse for error messages in another application. A find and replace fixed the issue for me before handling, but I wanted to come here and mentioned it.

{'response': {'@id': 'bfc6dcdf-e6dd-48e1-9ce3-231e0c6b15ef', 'elapsedtime': '0', 'estcommission': '0', 'marginrequirement': '0', 'netamt': '0', 'principal': '0', 'secfee': '0', 'error': 'You are placing a stop order on the wrong side of the market by either (1) purchasing at a price below the current ask price or (2) selling at a price above the current bid price.'}

As always thanks for your help.

Order Cancellation Fails

Since Friday (November 13, 2020), I get the following error whenever I try to cancel an order:

Order rejected, please resubmit with an order type field.

I tried all three approaches listed at https://alienbrett.github.io/PyAlly/trading.html#modifying-and-cancelling-outstanding-orders. Submitting and modifying orders still works as before. From what I can tell, this issue is on Ally's side. I see the same error even when I manually create the request as described under the "Cancel Order" section here:

https://www.ally.com/api/invest/documentation/trading/

Does anyone else observe this problem?

Accounts fails to parse when multiple accounts exist

I have three ally stock accounts and when running:

a.accounts()

the json data returned by Ally is not parsed properly into a dataframe. It contains only one row/column with all the json data in it. Also, I might expect it to only return info for the account number listed when instantiating the ally object, rather than all accounts.

Works fine with accounts(dataframe=False) but then has to be parsed manually. No big deal, but thought I would point it out.

KeyError: 'OrdID'

Hello,

I get KeyError: 'OrdID' when I try to run

ALLY_OBJECT = ally.Ally("key.json")
orders = ALLY_OBJECT.orders()

Any ideas?

Thanks!

Timesales

A method encapsulating this API would be awesome, allowing a user to retrieve a limited historical dataset of a symbol/list of symbols on a given interval.

Add Market API

I can add this if you're interested. Also let me know if you need help with anything else (e.g. proper types for holdings info). I was planning on writing something similar!

questions

Hi,

Great project! I have 2 questions. How can I view or use the response headers? And I didn't see an example for multi-leg options. Is there a way to buy and sell credit/debit spreads, etc.?

Thanks.

Problem with order placing

Hi,

I'm trying to place an order using this API.

Here is the code I'm running:

account1 = ally.Ally(params1)
order = ally.Order.Order(
    buysell='buy',
    symbol='f',  # case insensitive
    price=ally.Order.Market(),
    time='day',
    qty=2
)
order_id = account1.submit(order, preview=False)

I'm getting this traceback:

Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.1\plugins\python-ce\helpers\pydev\pydevd.py", line 1448, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.1\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Owner/PycharmProjects/stacky/ally_api.py", line 128, in
order_id = account1.submit(order, preview=False)
File "C:\Users\Owner\PycharmProjects\stacky\venv\lib\site-packages\ally\Order\Submit.py", line 154, in submit
result = Submission(
File "C:\Users\Owner\PycharmProjects\stacky\venv\lib\site-packages\ally\Api.py", line 206, in init
super().init(auth,**kwargs)
File "C:\Users\Owner\PycharmProjects\stacky\venv\lib\site-packages\ally\Api.py", line 171, in init
send_params, send_data = self.req_body (**kwargs)
File "C:\Users\Owner\PycharmProjects\stacky\venv\lib\site-packages\ally\Order\Submit.py", line 92, in req_body
data = self._order.fixml
File "C:\Users\Owner\PycharmProjects\stacky\venv\lib\site-packages\ally\Order\order.py", line 190, in fixml
d.update(self.pricing.fixml)
File "C:\Users\Owner\PycharmProjects\stacky\venv\lib\site-packages\ally\Order\classes.py", line 99, in fixml
return self._tag
AttributeError: 'Market' object has no attribute '_tag'

Extended hours support

Not specific to your wrapper, but in general I've never been able to figure out how to submit extended hours orders? Do you have any idea?

Sell to Close Error, Similar to Issue #7

Hello everyone,
I while trying to submit a market sell order today I got the error below:

We do not accept Sell Short Against the Box orders online

It appears that the order.Sell(to_open=False) is executing a sell short versus closing position. Maybe I am missing something tho. See the order construct below:

def market_sell(sym,quan):
	mktsell = ally.order.Order(
		timespan = ally.order.Timespan('day'),
		type = ally.order.Sell(to_open=False ),
		price = ally.order.Market(),
		instrument = ally.instrument.Equity(sym),
		quantity = ally.order.Quantity(quan)
	)
	return mktsell

Thanks for your help

Error XXXX is not a valid symbol for trading for option trading

I'm on PyAlly 1.1.2, buy call option api is giving me errors, other api seems ok

The example code below keeps giving me errors of 500 error MOS210226C00032000 is not a valid symbol for trading., but I know this symbol is correct because I hold this option currently so has the symbol for it (print out from .holding() method), and I have tried to open order on the website seems working also fine (no permission or site issue)
I was wondering if u might know what might be wrong w the API call or something else like a regression? or anyone has been able to place a successful option call order.

Thanks in advance!

call = ally.utils.option_format(
    symbol='mos',
    exp_date='2021-02-26',
    strike=32,
    direction='call'
)
buyOptionOrder = ally.Order.Order(
    buysell='buy',
    symbol=call,
    price=ally.Order.Limit(limpx=0.51),  # or  None || Market()
    qty=1,
    time='day'
)
try:
    orderIDoption = a.submit(buyOptionOrder, preview=False)
except Exception as e:
    print('\n', e)

question related to logging in

Two questions.

  1. Is it possible to place trades using the PyAlly module without first manually logging in to the Ally website? If so, how do you do this?

  2. Is it possible to prevent being automatically logged out of the Ally invest website due to inactivity?

Why do you have pyximport; pyximport.install()?

I see you import these at the beginning of every file. I'm not quite sure what they are doing in your code and everything works fine for me after I removed them. I'm not a python expert so I would love to know and learn something here. I'm just paranoid about security when it comes to my finances.

holdings() not working?

Looks like 1.0.4 changed the interface, when I was trying to pull my account holdings, an error was displayed:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-28-c7a8b39d842f> in <module>()
----> 1 a.holdings()

5 frames
/usr/local/lib/python3.6/dist-packages/ally/utils.py in format_strike(strike)
     65         # Pad strike with zeros
     66         def format_strike (strike):
---> 67                 x       = str(int(strike)) + "000"
     68                 return "0" * (8-len(x)) + x
     69         # Assemble

ValueError: invalid literal for int() with base 10: '7.5'

X-RateLimit-Used

Is there a way that we can obtain the limit header information?
I am getting timeout errors and although I am almost sure I am staying way below the limits, I can't rule out if the crappy code I am writing is causing issues.

Is this possible

Rate Limiting Info Here

I am getting this error randomly
Exception has occurred: ReadTimeout
HTTPSConnectionPool(host='api.tradeking.com', port=443): Read timed out. (read timeout=3)

Options endpoint updated on ally api

The fixml changed for options orders and I have been getting the error:
ally.exception.ExecutionException: This symbol is not valid for this request
when submitting with py ally the fixml should be:

<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
  <Order TmInForce="0" Typ="2" Side="1" Px="21.00" PosEfct="O" Acct="12345678">
    <Instrmt CFI="OC" SecTyp="OPT" MatDt="2014-01-18T00:00:00.000-05:00" StrkPx="190" Sym="IBM"/>
    <OrdQty Qty="4"/>
  </Order>
</FIXML>

instead of the given:

<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
  <Order AcctTyp="5" Typ="2" Px="8.5" Side="1" TmInForce="0">
     <Instrmt SecTyp="CS" Sym="NFLX220422C00300000" />
     <OrdQty Qty="1" />
  </Order>
</FIXML>

according to the link:
[https://www.ally.com/api/invest/documentation/trading/]

get all quote attributes

Forgive me if I am totally missing something here, I am new to pandas. I see the default is to get all data fields, but I cannot get that to return anything useful

>>> quotes = a.quote(symbols=['spy','gLD','F','Ibm'])
>>> quotes
Empty DataFrame
Columns: []
Index: [SPY, F, GLD, IBM]

But if I call out individual attributes, no problem. How do I specify to get all fields?

>>> quotes = a.quote(symbols=['spy','gLD','F','Ibm'],fields=['bid','ask','last','name','volatility12'])
>>> quotes
           ask     bid  ...                                  name volatility12
symbol                  ...                                                   
F        10.50   10.49  ...                   FORD MOTOR CO. (DE)       0.5766
GLD     173.36  172.91  ...                       SPDR GOLD TRUST       0.2010
SPY     369.45  369.33  ...                SPDR S&P 500 ETF TRUST       0.3403
IBM     119.02  119.01  ...  INTERNATIONAL BUSINESS MACHINES CORP       0.4239

[4 rows x 5 columns]

Sell to_open=False results in short sell

I just tested out a bogus sale with the following to see if everything worked.

    order = ally.order.Order(
        type = ally.order.Sell(to_open=False),
        timespan = ally.order.Timespan('day'),
        price = ally.order.Limit(price),
        instrument = ally.instrument.Equity(ticker),
        quantity = ally.order.Quantity(qty)
    )
    a.submit_order(order, preview=False)

I did expect it to bounce back... but it looks like this is being interpreted as a short sell rather than closing a position.

Sell Short | 100 | ABC | ALPHABETSOUP INC | Limit $187.14 | 194.92 | 194.95 | Day |   | 01/31/20 3:40 PM ET | SVR-6091077263 | RejectedThe limit price you have entered is significantly away from the current market price.

ally.order.Sell(to_open=True) makes it a sell to close.

Also, that API is dangerously confusing.

repeated same limit pricing

I get the same price for different limits on multiple stocks. After the first order is submitted all of the orders keep that price when they are submitted.

KeyError: 'quotes' line 358, in submit_order

Hello Everyone,
I am running into an error when submitting an order. The order is placed successfully however, I receive the error below:
2020-04-26 15:08:02 Traceback (most recent call last): File "text-script", line 25, in <module> print(fill_order(order)) File "text-script", line 19, in fill_order preview=False File "~/ally/api_calls.py", line 357, in submit_order del results['quotes'] KeyError: 'quotes'

The error references this part of the api_calls.py, but I am unable to decipher the purpose of these lines.

if verbose:
	# Notice results will have different type, depending on verbose
	print(results['request'])
	print(results['response'])

else:
	# optionally throw away unsightly extra bullshit
	if discard_quotes:
	del results['quotes']

Hope everyone is safe and healthy 👍🏾👍🏾

Error when cancelling an order

I am trying to cancel an order by ID.

I have setup the order to be cancelled as such:

cxl = ally.Order.Order(
      orderid=order, 
      type_=ally.Order.OType.Cancel
)

I originally attempted to submit this by simply doing broker.submit(cxl, preview=False) , however this presented me with the following server error:

  File "/home/xxxx/xxxxx/env/lib/python3.8/site-packages/ally/Api.py", line 154, in request
    x.raise_for_status()
  File "/home/xxxx/xxxxx/env/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://api.tradeking.com/v1/accounts/my_account_number/orders.json

Afterwards, I checked the preview and received:

ally.exception.ExecutionException: We cannot process your request at this time. Please contact your account representative.

Lastly, I also checked str(cxl) and got:

(OType.Cancel) None 0 units of "None" None, None

I'm using v1.1.1 on Ubuntu. Does anyone have an ideas on this?

StopLimit arguments

I have tried to get a StopLimit according to the documentation but I am unable to get it working. Can you please provide insight into what is the correct format?

See troubleshooting below:

ally.order.StopLimit()
TypeError: StopLimit() missing 2 required positional arguments: 'stopOrder' and 'limitOrder

ally.order.StopLimit()
TypeError: StopLimit() missing 2 required positional arguments: 'stopOrder' and 'limitOrder

ally.order.StopLimit(stopOrder(10),limitOrder(9))
NameError: name 'stopOrder' is not defined

ally.order.StopLimit(Stop(10),Limit(9))
NameError: name 'Stop' is not defined

ally.order.StopLimit(stopOrder=(10),limitOrder=(9))
TypeError: 'int' object is not subscriptable

ally.order.StopLimit(stopOrder=10,limitOrder=9)
TypeError: 'int' object is not subscriptable

ally.order.StopLimit(10,9)
TypeError: 'int' object is not subscriptable

JSON URL Assembly

Thanks for this great package. In the init.py file, line 305, I had to remove the letter "x" from "orderxs" in theURL assembly in order to get it to work. After doing so, I was able to submit orders. I don't know if others will have that issue as well.

Now for me it looks like the following:

# Assemble URL
url = self.endpoints['base'] +\
'accounts/' +\
str(account) +\
'/orders' +\
('/preview' if preview else '') +\
'.json'

Market orde doesn't work?

HELP! First time using this and tried it with market order and had the following error

The code: (just use as the example in your document): allyO is the ally object that has been verified to work for many other functions like balances, quote and timesales

o = ally.Order.Order(buysell = 'buy', symbol='AAPL', price = ally.Order.Market(), time='day', qty=1)
allyO.submit(o,preview=False)

The error message:

allyO.submit(o,preview=False)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ally\Order\Submit.py", line 159, in submit
block = block
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ally\Api.py", line 206, in init
super().init(auth,**kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ally\Api.py", line 171, in init
send_params, send_data = self.req_body (**kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ally\Order\Submit.py", line 92, in req_body
data = self._order.fixml
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ally\Order\order.py", line 190, in fixml
d.update(self.pricing.fixml)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ally\Order\classes.py", line 99, in fixml
return self._tag
AttributeError: 'Market' object has no attribute '_tag'

watchlists not functional

Was hoping to draw in a watchlist to run analysis, but I don't think this is working any more. Not complaining, just contributing how I can.

Just to show I am connected...

>>> a.quote('intc',fields='last')
         last
symbol       
INTC    58.18
>>> a.watchlists
<ally.Watchlist.Watchlist object at 0x7ffb6bfaa400>
>>> list(a.watchlists)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/theo/.local/lib/python3.8/site-packages/ally/Watchlist/__init__.py", line 189, in __iter__
    return self._all.__iter__()
  File "/home/theo/.local/lib/python3.8/site-packages/ally/Watchlist/__init__.py", line 175, in _all
    return self._lists
AttributeError: 'Watchlist' object has no attribute '_lists'
>>> list(a.watchlist['options1'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Ally' object has no attribute 'watchlist'

Stop Order incorrect Parameter used

Hello All,
I found a bug attributed to a typo included in the orders.py line 183.
The code currently using a StopPX parameter that is causing an empty stop price while submitting a stop order. Replacing StopPX with StopPx resolves this issue.

The current code below submits an empty stop price:

def Stop(stop):
	return {
		'__execution' :'stop',
		'Typ'	:'3',
		'StopPX' : str(float(stop))
	}

The below works properly

def Stop(stop):
	return {
		'__execution' :'stop',
		'Typ'	:'3',
		'StopPx' : str(float(stop))
	}

fmt_query not defined

o/
Thanks for the project, real clean with great examples.

I'm working from within PyCharm, env variables set and working. Other functions like a.get_strike_prices() or a.get_exp_dates() working fine. Having an issue with the options search listed on the Wiki/Options-Contract.

import ally

a = ally.Ally()

available_options = a.search_options(
    symbol='SPY',
    query='xdate-eq:20201231', # Mature on 2020-12-31
    fields=['bid','ask'] # 'bid,ask' also works. Function properly formats a list or a string
)

print(available_options)

Getting the following error:

C:\Dev\options_ally\venv\Scripts\python.exe C:/Dev/options_ally/run.py
Traceback (most recent call last):
    File "C:/Dev/options_ally/run.py", line 7, in
        available_options = a.search_options(
    File "C:\Dev\options_ally\venv\lib\site-packages\ally\option_info.py", line 72, in search_options
        'query':fmt_query,
NameError: name 'fmt_query' is not defined

Process finished with exit code 1

When I look at the option_info.py file, I can see fmt_query defined under options_chain but not search_options. Not sure if that's the issue.

Thanks for the help.

Account History

Hello,
Are you guys able to get Account History, I swore I was able to do this in previous versions, specifically .3.3. Have anyone of you guys run into this problem?
Account History Results

Issue setting Environment Variables?

Hey alienbrett,

I'm trying to get into API's specifically for Ally and I stumbled onto your python API which looks awesome. Everything is almost running but thought that it would be helpful to know when setting the environment variables, the export ALLY_OATH_TOKEN should be ALLY_OAUTH_TOKEN and same thing goes for the oauth secret (on the website the U is missing). Also, when looking at the code for init.py there is a repeat of the ALLY_CONSUMER_KEY of which I've attached a picture. Let me know what you think.

Capture

ChunkedEncodingError when streaming quotes outside market hours

I'm not sure if this is just an issue on Ally's end, BUT I've found that outside market hours, I get the following error when streaming quotes:

Traceback (most recent call last):
  File "/Users/zena.hirsch/Code/.virtualenvs/laboratory/lib/python3.9/site-packages/urllib3/response.py", line 697, in _update_chunk_length
    self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zena.hirsch/Code/.virtualenvs/laboratory/lib/python3.9/site-packages/urllib3/response.py", line 438, in _error_catcher
    yield
  File "/Users/zena.hirsch/Code/.virtualenvs/laboratory/lib/python3.9/site-packages/urllib3/response.py", line 764, in read_chunked
    self._update_chunk_length()
  File "/Users/zena.hirsch/Code/.virtualenvs/laboratory/lib/python3.9/site-packages/urllib3/response.py", line 701, in _update_chunk_length
    raise InvalidChunkLength(self, line)
urllib3.exceptions.InvalidChunkLength: InvalidChunkLength(got length b'', 0 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zena.hirsch/Code/.virtualenvs/laboratory/lib/python3.9/site-packages/requests/models.py", line 753, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/Users/zena.hirsch/Code/.virtualenvs/laboratory/lib/python3.9/site-packages/urllib3/response.py", line 572, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/Users/zena.hirsch/Code/.virtualenvs/laboratory/lib/python3.9/site-packages/urllib3/response.py", line 793, in read_chunked
    self._original_response.close()
  File "/usr/local/Cellar/[email protected]/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/zena.hirsch/Code/.virtualenvs/laboratory/lib/python3.9/site-packages/urllib3/response.py", line 455, in _error_catcher
    raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zena.hirsch/Code/laboratory/stock-watcher.py", line 82, in <module>
    main()
  File "/Users/zena.hirsch/Code/laboratory/stock-watcher.py", line 72, in main
    for quote in a.stream(SYMBOL):
  File "/Users/zena.hirsch/Code/.virtualenvs/laboratory/lib/python3.9/site-packages/ally/Api.py", line 242, in request
    for chunk in x.iter_content( chunk_size=1 ):
  File "/Users/zena.hirsch/Code/.virtualenvs/laboratory/lib/python3.9/site-packages/requests/models.py", line 756, in generate
    raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

I am streaming quotes like so:

for quote in a.stream(SYMBOL):
    print(quote)
    bid_price = float(quote['bid'])

Is this a known issue? Something I should report to Ally? Thank you!

get_quote error when submitting a list of symbols

It looks as though some deprecated code was inadvertently left in the get_quote function and returns {} if a list of symbols is used. Deleting lines 241-243 resolves the issue.

  1. Ensure correctly-typed input
  2. if not utils.check(symbols):
  3. return {}

The error is shown below using t4 of tests.py
Before deletion:
image
After deletion:
image

intermittent problems with get quote

I have been pulling real time quotes once a second and frequently will see a couple of minutes when I am unable to retrieve any quotes. Has anyone seen this? Probably an issue on the Ally side but curious if anyone else has seen this.

get_holdings needs account #

Though the documentation appears to indicate that an account # is not necessary to execute get_holdings, it appears that the function returns a Keyerror searching for an account value if you do not provide one.

I am unsure of whether this is an issue with documentation or the wrapper as I haven't looked into ally's documentation on the call as of yet.

No module named 'pyximport'

Good Morning,
Thanks for the update boss, however it appears that there is an additional bug relating to a missing module named pyximport. I tried to find reference to this module in the code but I was unable to, although the error persist after commenting it out. Maybe there is something on my end that I am missing, or I am just not looking int he right place..

Screen Shot 2020-03-28 at 6 26 03 AM
Screen Shot 2020-03-28 at 6 25 24 AM

Thanks for all your help, on this man I'll make sure to provide some beer money :D I appreciate you and your efforts man

Setting Environment Parameters for Windows

I am still a rookie programmer, so I do not operate in a Linux environment (I still use windows). Unsurprisingly, I am unable to export the necessary environment parameters. Is there a way I can set the 'base', 'request_token', 'user_auth', and 'resource_owner_key' in my algorithm's source code without exporting the tokens to the os environment?

0.3.7 behavior unchanged

Hello Brett,
it appears that the behavior is unchanged, unless I am missing something.

Thanks for your help man..

Screen Shot 2020-04-18 at 12 22 29 PM

Thanks for bringing this to my attention, this is fixed in V0.3.7

Originally posted by @alienbrett in #26 (comment)

Error with "orders()" - "Invalid literal for int() with base 10"

Hi,

I'm not sure if it's just my account, but in my case it has letters in the account number. So, when you're trying to convert it to an "INT()" at line 283 in ally/Order/order.py", it fails with an error.

In test you specify account as all digits, however in reality it could be alpha-numeric.

I changed line 238 to just "self.account = str(account[:8]" and it works.

Sincerely,

Mike

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.