Comments (5)
I can't replicate the issue on my end - the short order goes through successfully, which means that the form names are fine.
If mechanize cannot find the form when you run the code, it means that something goes wrong when you submit the trade order and you're never taken to the final submission page. Could you describe your Investopedia setup in more detail - what investing game you're part of, etc?
from investopedia-trading-api.
I created the account yesterday.
from investopedia-trading-api.
I think I figured out your error! It's not because of the API, it's an issue with your trade itself. When I tried to submit the order manually, in the Beginner game, I got the following message: "This order was not executed because it violated the game's diversification rule. The diversification rule refers to an in-game setting that prevents users from spending more than 25.00 % of their total funds in a single trade. The purpose of this rule is to make the experience more realistic. In real life, very few investors would be willing to risk their entire investment funds on just one or two positions. "
Buying 20 shares of SPY would be roughly 38% of your $10,000 portfolio at market price. Try changing the amounts or shares to fit the diversification rule, and the order should go through.
from investopedia-trading-api.
I tried buying cheap stock USO - $9. Still no cigar. Wonder whether i could introspect the html?
In [3]: client.trade("USO", Action.buy, 5)
---------------------------------------------------------------------------
FormNotFoundError Traceback (most recent call last)
<ipython-input-3-9b7f93ad469f> in <module>()
----> 1 client.trade("USO", Action.buy, 5)
/home/jopython/Downloads/investopedia-trading-api/investopedia.py in trade(self, symbol, orderType, quantity, priceType, price, duration)
92 self.fetch('/simulator/trade/tradestock.aspx')
93 handle = self.br
---> 94 handle.select_form(name="simTradePreview")
95
96 # input order type, quantity, etc.
/home/jopython/anaconda2/lib/python2.7/site-packages/mechanize/_mechanize.pyc in select_form(self, name, predicate, nr)
522 if orig_nr is not None: description.append("nr %d" % orig_nr)
523 description = ", ".join(description)
--> 524 raise FormNotFoundError("no form matching "+description)
525
526 def click(self, *args, **kwds):
```FormNotFoundError: no form matching name 'simTradePreview'
from investopedia-trading-api.
The form definitely exists - here's a screenshot of the HTML, with the form tag highlighted in blue.
Perhaps the issue is with your local Python setup? (version, etc.)
from investopedia-trading-api.
Related Issues (18)
- Not-so-brief Comments HOT 4
- name 'Account' is not defined
- Account statement HOT 1
- AttributeError: 'module' object has no attribute '_base' HOT 1
- AttributeError: 'str' object has no attribute 'value' HOT 3
- Gain_loss field not returned by get_current_securities function HOT 1
- pull request HOT 8
- No status report when doing an action HOT 2
- no connection could be made
- get_portfolio_status() returns AttributeError HOT 3
- Failed to handle prices more than 1000 HOT 1
- Is this API still useable? HOT 2
- Error when trying to log in. HOT 6
- 1 HOT 1
- error get portfolio_status() HOT 2
- Intraday trading and data using this API? HOT 1
- How to install investopedia-trading-api in ubuntu HOT 2
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 investopedia-trading-api.