Is it possible to do the following with VB .NET?-VBForums
Results 1 to 5 of 5

Thread: Is it possible to do the following with VB .NET?

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    1

    Is it possible to do the following with VB .NET?

    I want to do the following, and was wondering if its possible with VB .NET:

    A program that access a stock website:

    -> If the stock price reaches a certain value, click on the "Sell" button of the website.

    -> Then, if the stock price reduces to certain value, click on "Buy".

    Considerations: The stock price fluctuates constantly and every second, so the program needs to be able to read the website stock's price constantly

  2. #2
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,269

    Re: Is it possible to do the following with VB .NET?

    How you decide to implement this dramatically affects how hard it will be.

    If you find a stock site with a "check prices" and "buy/sell" API, then this is fairly easy to write.

    If you want to scrape an HTML web page for the prices and pretend like you're a browser clicking on things, it's going to be a nightmare. This is usually against the terms of service for whoever publishes the pages. They often take active measures to make it harder. They frequently change those measures, so your program will frequently break. Occasionally, they might ban your account. It's really not worth it to go that route.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    31,284

    Re: Is it possible to do the following with VB .NET?

    It is possible, but you shouldn't do it...actually, the bit about clicking the button is likely not possible, and even if it is, it may fail at any time.

    The first things to do is to check for an API for the site. They have made the data available to you, so they are likely interested in making it available to you, so an API is reasonable. Whether they have one or not is largely due to attitude, intent, and time, so it's harder to say.

    The problem is that web sites can be built in numerous different ways, and site designers delight in changing technologies. For this reason, web scraping is an attempt to hit a moving target. Even if you get it working today, it could utterly fail tomorrow, because the elements that you were looking at have been turned into something totally different. An API avoids that by being both more stable, and VASTLY easier data to work with.

    As for clicking the button, that takes you firmly into bot territory. You actually ARE creating a bot with that design, whatever you think of that word, and sites often don't like bots. Therefore, that which you think is a button may not be a button, and there may be steps taken to make it as difficult as humanly (or inhumanly) possible, which includes constantly changing what the button actually is. An API helps with that, too. Therefore, if there is an API, use the API. If there isn't an API, get in touch with the site and ask about it. They often are quite willing to talk about that, and even build stuff for you.

    EDIT: Cross-posted with Sitten ,but it's a pretty similar message.
    My usual boring signature: Nothing

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,336

    Re: Is it possible to do the following with VB .NET?

    Not to mention that if you're buying or selling online by clicking a button, then there's login information to deal with... and with exchanges and financials being involved... that's not going to be easy, plus depending on the site, they may have strict regulations preventing this kind of automation. Further more, if they are reputable, and and worth it, odds are they have trigger trading available to execute orders when conditions are met, you don't even need to be sitting there or logged in for it to happen.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    31,284

    Re: Is it possible to do the following with VB .NET?

    Well, THAT opens up a whole other can of worms....but this is a programming forum, not an investment site.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.