Giter VIP home page Giter VIP logo

Comments (5)

kirkthaker avatar kirkthaker commented on August 26, 2024

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.

JoePython1 avatar JoePython1 commented on August 26, 2024

I created the account yesterday.

firefox_screenshot_2016-01-14t13-15-23 446z

And the screen for trading.
investopedia stock simulator - trade a stock 2016-01-14 08-22-28

from investopedia-trading-api.

kirkthaker avatar kirkthaker commented on August 26, 2024

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.

JoePython1 avatar JoePython1 commented on August 26, 2024

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.

kirkthaker avatar kirkthaker commented on August 26, 2024

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.)
screen shot 2016-01-14 at 10 07 22 pm

from investopedia-trading-api.

Related Issues (18)

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.