• Resolved arandomgoodguy

    (@arandomgoodguy)


    Hi, I extremely appreciate your fantastic work since this plugin solves a lot of my worries!

    After reading the documentation, I am not entirely sure whether existing features actually fit my need. Therefore, I have a question that really require your response.

    I want to know whether this plugin can let user filter stocks by checking boxes, something like price > MA50 etc. Besides, can I create that kind of custom box?

    For example, user start by seeing a table with many stocks on a web page. Then, if they check some filtering boxes, the filtering result instantly reflects. In other words, only stocks which meets their criteria remain on the web page. ( like features in this video https://www.youtube.com/watch?v=5GorMC2lPpk )

    Is this possible? Thanks!

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @arandomgoodguy,

    Thank you for your compliment and your interest in the plugin! 🙂

    You can add your own custom filter to a publication or a Data Project. In the video attached to your message, the filter consists of text fields and checkboxes. You can create a custom filter using similar fields.

    To add a filter on a specific column, you can add an URL argument to your request. Your parameter name needs to match this pattern:
    wpda_search_column_<column_name>

    The plugin will automatically pickup your filters. This is documented here:
    https://wpdataaccess.com/docs/documentation/data-publisher/adding-filters/
    See section: URL parameters

    The plugin uses a like operator for your filter values, which allows you to use wildcards. If you need to add a more specialized filter (use <, >, between, and so on), you can write your own extension (= WordPress filter). This is documented here:
    https://wpdataaccess.com/2020/01/29/filter-wpda-construct-where-clause-to-add-custom-search-behaviour/

    An alternative search algorithm extension, written by Charles Godwin, can be found here:
    https://github.com/CharlesGodwin/wpda-cwg-extensions

    Is this what you are looking for? Does this help?

    Best regards,
    Peter

    Thread Starter arandomgoodguy

    (@arandomgoodguy)

    Thanks for your kindly response. It really helps me out.

    In order to make sure that my idea is viable, I do need to ask another question although it is not quite related to your plugin.

    The question is about the next step of stock screening features asked above.

    To begin with, I have a python script that takes stock tickers as input and outputs portfolio allocation weights. The question is how to add this kind of function on WordPress so users can input their selected stock tickers and get the weight results.

    By searching on Google, I know one can execute a custom python script in WordPress as a plugin. However, I am not sure whether the input and output of the python script can also be displayed on the web page.

    For instance, there is an input block that lets users key in tickers. After the execution of my script, a data frame indicates the ticker, and shares can also be printed out on the same web page as a table like your plugin.

    As a result, when different tickers are inputted by users, different weight results can be printed.

    Is this possible? Thanks again!

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @arandomgoodguy,

    This is what I understand from your question:
    (1) Your python script accepts input
    (2) You need to perform a database query (or insert|update?) from your python script
    (3) You want to process the result from step 2
    Is this correct?

    If my presumption is correct, you could write a small web service to perform your database query and return a result. This could be done with the Code Manager:
    https://code-manager.com/

    The Code Manager is a very powerful plugin that allows you to write your own PHP code blocks. You’ll need the premium version which allows you to write your own web services. The free version only supports shortcodes, which is not suitable for your requirements. Free downloadable example code can be downloaded here:
    https://code-manager.com/code/
    Please search for: web service

    This will give you a number of code blocks to create and use web service. You can change the code according to your needs.

    Does this help?

    Best regards,
    Peter

    Thread Starter arandomgoodguy

    (@arandomgoodguy)

    Yes! Your understanding is completely correct!

    From my understanding, Code Manager can perform highly flexible and specific features which existing WordPress plugins may lack for.

    As a result, I think what I need to do is rewriting my Python script like an API and translating it into a PHP code snippet. Is it correct? Or I can just simply use PHP to execute my Python script?

    Following this notion, it leads to another question I am really interested. I will be extraordinarily grateful if you can also answer my worry below.

    Normally, one can build a web page using package like Flask / FastAPI to deploy a machine learning model, and the web page mainly serves for single purpose.

    However, if one needs more than that, one may feel difficult integrating it with WordPress so one is not able to enjoy a lot of handy WordPress plugins.

    To sum up, I wonder if it is also possible to directly deploy model in WordPress by using Code Manager, without the need of maintaining a web page and a WordPress website.

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @arandomgoodguy,

    I’m missing the big picture to answer your question. Maybe you can use the contactform on the plugin website to give me some more background information?

    Generally, the Code Manager is a WordPress plugin. It only works on a WordPress server. If you want to use the Code Manager, you must have WordPress installed.

    You might be able to use flask only, or you as well be able to use WP Data Access. Probably even without the Code Manager. It depends on your requirements.

    Let me know!

    Best regards,
    Peter

    Thread Starter arandomgoodguy

    (@arandomgoodguy)

    Sorry, perhaps I wasn’t clear enough.

    To elaborate, I want a WordPress website that can do the things below.

    —————————————————————————————

    1.stock screener features
    (my first question and it is solved)

    2.input tickers and then output weight on the web page features
    (my second question and it is acheivable by using the Code Manager premium)

    3.my third question (Since it is a little complicated, the whole process is described as follows.)

    First of all, I put a trained model on my website. Then, users can use it by inputting something and clicking a button. After clicking, the trained model is told to predict the input which is given by users. Finally, its prediction is returned on the web page so users can get the results.

    —————————————————————————————

    From your second response, you said the second feature that I want (the code in my python script) can be achieved by using the Code Manager as a web service. Therefore, I wonder how to actually do that. Does that mean I must translate my python script into PHP or I can just write simple PHP code only to execute my python script?

    Besides, deploying a machine learning model can also be done by building a web service.
    A normal way to do that is using something like Flask, but that does not what I want since I also want to use some handy WordPress plugins like WP Data Access.

    What I wish is to use only WordPress and Code Manager to deploy a machine learning model like the features of Flask, but I am not sure whether it is possible. Also, if it is possible, is rewriting the code which is written in python originally into PHP the way to do that?

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Thanks for the explanation!

    >>> Does that mean I must translate my python script into PHP or I can just write simple PHP code only to execute my python script?

    If you are using flask, is your python service accessible over HTTP? If so, you can just call your service from PHP. If not, you might consifer rewriting your code in PHP.

    The disadvantage of calling your python service over HTTP is that you add a second request which might slow down your user request. But that does not necessarily needs to be an issue. Are they on the same server? Or on different servers?

    If your python code is a good, I would use it! 😉

    Good luck,
    Peter

    Thread Starter arandomgoodguy

    (@arandomgoodguy)

    I haven’t used flask yet. Although I can make them on the same server, that is my last resort. Can I just use WordPress and the Code Manager to do what flask can do?

    It seems that rewriting is the way to do it. But the problem is that my python script includes some functions from other python packages, so I don’t think rewriting it into PHP will be very easy. Are there any other solutions?

    I truly appreciate all your help on this matter!

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @arandomgoodguy,

    If you can run your python script with flash on the same server, you can save yourself a lot of work! 😉 But you need to do a bit of PHP coding to access your flash service. That part is not yet on my Code Manager website, but here is something to get started with:

    <?php
      // Use curl to access your flash service
      // see: https://www.php.net/manual/en/book.curl.php
      $ch = curl_init();
      curl_setopt( $ch, CURLOPT_URL, 'http://your-flash-request/');
      curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
      $response = curl_exec( $ch );
      curl_close( $ch);
    
      // Handle XML request (in case your service returns an XML response)
      // $doc = new DOMDocument("1.0", "utf-8");
      // $doc->loadXML( $response );
      // $doc is a DOMDocument and allows easy XML access
      // see: https://www.php.net/manual/en/class.domdocument.php
    
      // Handle JSON request (in case your service returns an JSON response)
      // $json = json_decode( $response );
      // $json is an object
      // OR
      // $json = json_decode( $response, true );
      // $json is an associative array
    ?>

    Sound like an interesting project. 🙂 Hope this helps you to get started!

    Best regards,
    Peter

    Thread Starter arandomgoodguy

    (@arandomgoodguy)

    flash or flask service? What do you mean by saving a lot of work?

    Given that it may be difficult to build some custom features using only WordPress and the Code Manager, is using both Python (take care of my features) and PHP (take care of other parts) the most straightforward way to solve this issue?

    To elaborate, first I make my python script as a web service page using something like Flask. Then, I also create a WordPress website. Finally, I let my WordPress website call my API to perform custom features when users make a request. Is this idea viable?

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @arandomgoodguy,

    Sorry! I meant flask! 🙂

    >>> Is this idea viable?
    Yes!

    How many requests are you expecting?

    Thanks,
    Peter

    Thread Starter arandomgoodguy

    (@arandomgoodguy)

    Alright.

    Since that feature does not need frequent requests, it depends on how many users use it each day. Is it ok?

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    In that case: go for it! 🙂

    Can I close this issue?

    Thanks,
    Peter

    Thread Starter arandomgoodguy

    (@arandomgoodguy)

    Sure, you help me a lot! Thanks again!

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Your’re welcome! 🙂

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Filtering features like screener’ is closed to new replies.