psemdel / py-trading-bot

Trading-bot in python using django, vertorbt lib and interactive-brokers
MIT License
141 stars 34 forks source link

Migration issue with SQLite #3

Closed psemdel closed 1 year ago

psemdel commented 1 year ago

Other topic below ;)

ben1628 commented 1 year ago

I'm still trying to get this working in my local machine. Currently running into No module named 'psycopg2', though I'm using sqlite and python 3.8

what do I expect to see once I python3 manage.py runserver. It looks like localhost/start_bot. A screen shot of the website will help me.

The Django I'm using is the latest version, 4.1.4

Any help is appreciated.

psemdel commented 1 year ago

[I think you posted in the wrong issue, but nevermind] Normally, pg is called only in settings from the Django project (line 191). Normally, no mention of pg or any database is performed in the code.

When you start runserver, you should get:

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
December 11, 2022 - 09:54:08
Django version 4.1.2, using settings 'trading_bot.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

No need to start anything before or after. start_bot is principally there to start the worker, which is not needed in the first place.

psemdel commented 1 year ago

Ok, I found it. In reporting/models.py I use from "django.contrib.postgres.fields import ArrayField". I look how to change that for the case of sqllite.

psemdel commented 1 year ago

So basically, I need to make a many-to-many relation instead of those ArrayField. I will have a problem between my "Indexes" and "Actions" as they are presently different objects. I think https://stackabuse.com/recursive-model-relationships-in-django/ should allow me merging both types and remove this source of bugs. It is a big change, so I cannot promise it will happen in the next hours :( . To test you can remove those ArrayField in reporting/models.

ben1628 commented 1 year ago

Thanks a lot.

I'm not too worry about it currently. Some background:

1/ I'm using wsl2 in windows 10, so it may be a bit different, but it seems to be fine 2/ Using Sqlite for now as I don't want to use the postgres yet 3/ Using VSCode, vectorbt (I could upgrade to pro but have to see how this works first

I like the ideas you have and that's the main reason why I will commit to get this working. My approach is

1/ Install Django as get this working as a basic website. This is done as I'm using the Django 4.1, it is working fine. 2/ Gradually migrate the other modules in your code to my local environment, make changes to vbt as I go along

ben1628 commented 1 year ago

I'm happy to report it is now working, of course, there will be some learning and road block I have to overcome

Thanks for your excellent work

psemdel commented 1 year ago

Good that it works for you. Don't hesitate to commit, it is still far from perfect.

ben1628 commented 1 year ago

Still trying to understand the workflow... If you care to comment on how you go about using this, that will help me.

Exploring ...

ben1628 commented 1 year ago

We can close this issue as I am now using PostgreSQL