BennyThadikaran / stock-pattern

A python scanner to detect and plot common chart patterns
GNU General Public License v3.0
121 stars 25 forks source link

How to run the code step by step #54

Open Kusarok opened 2 months ago

Kusarok commented 2 months ago

Please create a video or a full page of descriptions that will help us run the code step by step because I get a lot of errors every time and I couldn't execute the code

My csv file from the API Oanda And that I have all the I edited the file columns as required by the code

BennyThadikaran commented 2 months ago

Hi Kusarok,

You havent attached the CSV file. Show me the error message. Also mention the python version and what OS you're running.

Please create a video or a full page of descriptions that will help us run the code step by step because I get a lot of errors every time and I couldn't execute the code

Apart from the README there is a Wiki section with several pages on how to use the program. There is also a discussion section for questions on usage or other aspects of the program.

Kusarok commented 2 months ago

xauusd_5minup.csv

I tried use in Google colab or debian terminal

But I didn't succeed in implementing and identifying any patterns In fact, Code failed to execute

And I tried very hard to use the functions in the Utils.py file separately, but I still didn't succeed and I got a lot of errors that I couldn't fix

Yes, on the first page, there have been instructions for executing the code, but none of them have been useful. Maybe I couldn't use it

That's why I want your guidance and help, because I need it so much.

Thank you very much for your response.

The second point I would like to add is that the code has a lot of complexities And not everyone can use it

BennyThadikaran commented 2 months ago

Ok I can see why you're having problems.

Lets say i want to scan a stock named INFY, I would run py init.py --sym infy. The program expects to find a file named infy.csv in the DATA_PATH folder you mentioned in your user.json.

If your file is named xauusd_5minup.csv, you have to run py init.py --sym xauusd_5minup.

You can add these names to a watchlist file and add the file path to SYM_LIST in your user.json.

The other issue is in your file. The first column must be a Date column. You have an unnamed index. You need to get rid of that first column. Screenshot from 2024-07-04 23-25-10

I assume you're using Pandas.so something like df.to_csv("xauusd_5minup.csv", index=False). There are many ways to do it.

I don't see any other issues in your file. I will try running the file tomorrow.

If you need help with the configuration, try running setup-config.py in the src folder. Just delete or move the existing user.json before you execute it. Just answer the questions and it should create a user.json for you. It not part of docs yet.

Let me know if you face any difficulties.

It helps to understand the problem first. I can now make changes to README. Else i have no idea what is missing. :smiley:

Kusarok commented 2 months ago

Thank you very much for your guide on this Subject

I will definitely run the code with the changes you said and I apply the changes

But if you don't get upset, I have an idea. It would be great if you presented the entire collection of identifying and finding patterns in the form of a library. And that if you make the necessary changes to the code in this way, it can be used much better and it will be very easy to develop it, unfortunately, it is not in my ability to develop such advanced code, otherwise I have a lot of ideas in my mind to develop the code.

But if you could make the whole code a set where its functions can be called, it would be much more interesting and practical For example, it can input the data that the whole complex wants to receive and make the necessary changes in it in the first step, Or, with the initial execution of the code, it displays an example of the example required for the CSV and the user himself changes it to resemble the example And in the next step, the user wants to enter or upload the file path or download the file from Google Drive with the Gdown library

And finally, after receiving the data and reviewing them Display or save the output in the appropriate format

After that, we can add a function to the code that will only check and analyze the initial 100 columns of the code or the specified number if we get a lot of data, because we need the latest price changes to analyze the market and not the entire market data.

Sorry for taking the conversation too long, but I'm really curious.

BennyThadikaran commented 2 months ago

I did run your file after deleting the unnamed column and everything is running fine without errors. I couldnt detect any patterns though. You could try with other scrips / symbols.

It would be great if you presented the entire collection of identifying and finding patterns in the form of a library.

Yes, you're right and its a good idea. I do have plans to convert the utils.py into a library and publish it on pypi. I just need the api to be stable, else its a lot of work and frustration for users if things keep changing. I have planned updates for the next few months. So this should definitely be on the cards.

But if you don't get upset, I have an idea.

I am grateful for so many users of my code. Your feedback is definitely constructive. If you tried the setup-config.py please do let me know how it goes. I will make changes in the documentation next week.

Kusarok commented 2 months ago

Hello again I just now actually had a few minutes ago And I was able to scan the CSV file. But he did not find any pattern that you yourself said But I know that there are a lot of patterns, and you can see that yourself.

In fact, it is known to the naked eye.

For the configured file, I did the rest of the settings with it, but I couldn't give it the address, so I edited the file myself and entered the address.

In your opinion, what is the reason why he has not been able to find the patterns? Screenshot 2024-07-06 133905

Screenshot 2024-07-06 133133

BennyThadikaran commented 2 months ago

Firstly only the last 160 candles are loaded and scanned. We calculate the high and low points on the chart (Pivots) and check for patterns within these pivots.

Pivots as you see below is a candle whose High or Low is unbroken by the 6 candles before and after. pivots

So one possible reason, is the pivot high or low was broken within the 6 candle range. I have provided a -l and -r option for left and right bars to configure the number of candles before and after.

py init.py -l 4 -r 4

Play around with the numbers. There are other rules and filters applied to make sure the pattern conforms to certain parameters.

Also try scanning a larger number of stocks. You're more likely to find them that way. You could also try backtest.py to look back 3 months or more if any patterns existed on the stock and how they performed. Its all mentioned in the wiki.

In the end it only detects patterns if its fits the rules.