-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 64486fb
Showing
1,610 changed files
with
590,559 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.idea/ | ||
.vscode/ | ||
*.py[cod] | ||
__init__.cpython-36.pyc | ||
*cpython-36.pyc | ||
**/__init__.cpython-36.pyc | ||
**cpython-36** | ||
*$py.class | ||
*..pyc~Stashed changes | ||
__pycache__/ | ||
**/__pycache__/ | ||
**/migrations/* | ||
!**migrations/__init__.py | ||
*_initial.py | ||
*_auto*.py | ||
*.pyc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
language: python | ||
sudo: true | ||
os: | ||
- linux | ||
python: | ||
- "3.6" | ||
# 使用的服务,必要的数据库服务 | ||
services: | ||
- mysql | ||
env: | ||
global: | ||
- TRAVIS=true | ||
- DJANGO=2.1.15 | ||
- CODECOV_TOKEN="54368210-ad7d-4e89-82ba-e535fea06ff7" | ||
# command to install dependencies | ||
before_install: | ||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then | ||
brew update; | ||
brew install python3 redis memcached; | ||
virtualenv -p python3 ~/py-env; | ||
. ~/py-env/bin/activate; | ||
fi | ||
- pip install codecov | ||
- pip install coverage | ||
|
||
install: | ||
- pip install -r requirements.txt | ||
# - pip install boxx/ | ||
# command to run tests | ||
script: | ||
- mysql --version | ||
- mysql -e 'CREATE DATABASE IF NOT EXISTS stocktrading;' | ||
- mysql -e 'create user "trading"@"localhost" identified by "trading";' | ||
- mysql -e 'grant all ON *.* to "trading"@"localhost";' | ||
- python manage.py makemigrations | ||
- python manage.py migrate | ||
- coverage run manage.py test | ||
after_success: | ||
- codecov | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
# 基于Django的个性化股票交易管理系统 | ||
|
||
|
||
## 安装说明 | ||
|
||
本项目基于Python3.6、Django2.1、MySql8.0与股票信息工具包TuShare实现。 | ||
|
||
1. 打开该项目 | ||
|
||
2. 创建或激活对应Python开发环境 | ||
|
||
这里使用了conda来管理环境,避免不同环境包干扰、依赖的问题。 | ||
```bash | ||
$ conda activate Webdev | ||
(Webdev)$ | ||
# 或者 | ||
$ conda create -n Webdev python=3.6 | ||
$ conda activate Webdev | ||
(Webdev)$ | ||
``` | ||
|
||
3. 安装所需要的依赖包 | ||
|
||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
本项目依赖的核心包有:Django 2.1.15与tushare pro,前者作为主要开发框架,后者是爬取股票数据的核心包。tushare需要依赖pandas等包,用于数据分析和处理。 | ||
my-fake-useragent用于生成伪请求头,爬取相应的新闻数据。 | ||
django-mptt用于生成树形多级评论。 | ||
|
||
|
||
4. 创建对应数据库(stocktrading)和用户(trading) | ||
```sql | ||
create database stocktrading; | ||
create user 'trading'@'localhost' identified by trading; | ||
grant all privileges on stocktrading to 'trading'@'localhost'; | ||
flush privileges; | ||
``` | ||
|
||
5. 执行迁移命令,创建模型数据表映射 | ||
|
||
改命令会根据`models.py`文件中定义的模型创建数据表结构(无数据)。 | ||
|
||
```bash | ||
$ python manage.py makemigrations | ||
$ python manage.py migrate | ||
``` | ||
|
||
6. 将`config/`下的sql文件导入数据库中 | ||
|
||
在mysql环境中执行,会将`stocktrading.sql`中定义的表结构和数据全部导入。 | ||
|
||
```sql | ||
use stocktrading; | ||
source stocktrading.sql; | ||
``` | ||
|
||
7. 开始运行和测试 | ||
|
||
```bash | ||
python manage.py runserver | ||
``` | ||
|
||
打开localhost:8000端口即可查看应用。 | ||
|
||
## 运行情况 | ||
|
||
### 登录界面 | ||
|
||
 | ||
|
||
可以点击上方注册按钮注册。 | ||
|
||
### 注册页面 | ||
|
||
 | ||
|
||
输入相应信息即可完成注册。 | ||
但是考虑到已经导入数据库sql文件,那么数据库中应该有了相当数量可以直接登录的用户。可以任取一个进行测试。 | ||
|
||
username: `10071539640` | ||
password: `65815609` | ||
|
||
### 用户首页 | ||
|
||
 | ||
|
||
首页可以分为4个模块,传递的信息也是比较的丰富。分别是: | ||
1. 热门牛股:根据每天的股票收盘价格和次日的开盘价格计算差值和涨幅,按照涨幅进行排序得到的前10只热门牛股; | ||
2. 重大新闻:管理员自己发布或者通过爬虫获取到东方财富网上刊登的重大新闻简要信息,筛选后推荐给用户。可以点击`换一波瞅瞅`查看更多其他感兴趣的新闻资讯。有可以点击新闻标题进入新闻详情。 | ||
3. 看大盘模块:展示了通过tushare模块抓取的上证指数变化情况。 | ||
4. 我的评论模块:展示了我(该登录用户)近期所发布的对股票的评论信息。也可以点击评论标题进入评论详情。 | ||
5. 左侧的控制菜单面板,可通过该面板进入其他模块进行管理。 | ||
|
||
|
||
### 个人信息管理 | ||
|
||
 | ||
|
||
点击左侧`用户信息`或者上方导航栏的头像,可以进入用户信息界面,在此查看个人信息,并可以进行修改。若修改需要输入密码并确认密码。 | ||
|
||
点击修改头像可以修改头像。 | ||
|
||
 | ||
|
||
### 查看股票列表 | ||
|
||
 | ||
|
||
点击左侧`股票列表`即可查看股票列表,采用了DataTable组件进行列表展示。其中红色表示股价上涨的股票, | ||
绿色表示下跌的股票。用户可以点击详情页面进行查看股票详情。 | ||
|
||
### 股票详情 | ||
|
||
 | ||
|
||
|
||
用户在此页面可以进行买入操作,也可以查看返回到上级页面查看股票列表。 | ||
左上方图表显示了这支股票的股价变化日K线图与实时股价,右侧是该股票的股权占比,均是通过tushare | ||
提供接口进行抓取获得的。 | ||
|
||
下方是关于股票的评论信息,同时用户可以发表自己关于这支股票的评论信息。 | ||
|
||
|
||
### 管理我的股票 | ||
|
||
 | ||
|
||
|
||
点击`管理我的股票`,即可查看已经购入的股票列表。 | ||
点击详情页面,进入抛售股票页面。 | ||
|
||
 | ||
|
||
### 管理我的评论 | ||
|
||
 | ||
|
||
点击`管理我的评论`,即可查看我已经发表过的评论信息。 | ||
|
||
详情页面可以查看所有对评论的回复信息,同时自己也可以回复自己的评论。 | ||
|
||
。 | ||
|
||
点击回复评论的用户名,可以查看该用户的详细信息,也可以为他(她)点赞。 | ||
|
||
 | ||
|
||
同时用户可以在`我的评论`列表将评论删除。 | ||
|
||
|
||
### 查看新闻详情 | ||
|
||
 | ||
|
||
点击新闻标题,可以进入新闻的详情页面。可以在这个页面点击查看上一条或者下一条新闻。 | ||
|
||
### 管理员首页 | ||
|
||
可以使用如下命令创建管理员: | ||
|
||
```bash | ||
python manage.py createsuperuser | ||
``` | ||
提示输入用户名,邮箱与密码, | ||
这里依次输入`superuser1`,空,`superuser1`。 | ||
|
||
这样就可以以超级管理员身份登录后台了。 | ||
|
||
 | ||
|
||
|
||
管理员界面与用户界面大同小异,只是内容更加丰富了一些。 | ||
|
||
|
||
### 用户信息管理 | ||
|
||
点击左侧`用户信息管理`进入用户信息管理详情页面。可以看到全部用户列表。 | ||
|
||
 | ||
|
||
点击`详情`进入用户信息详情。 | ||
|
||
 | ||
|
||
在此界面,管理员可以修改部分用户的信息,不包括密码。管理员可以冻结用户的账号,使其 | ||
无法参与股票交易,管理员也可以删除用户。 | ||
|
||
### 管理股票列表 | ||
|
||
 | ||
|
||
 | ||
|
||
### 管理交易记录 | ||
|
||
 | ||
|
||
### 股票信息维护 | ||
|
||
 | ||
|
||
|
||
在此界面,管理员可以点击面板上的按钮,进行每天股票信息的维护操作。 | ||
|
||
点击`更新实时数据`按钮后,可以在控制台看到数据库更新的打印信息。 | ||
|
||
### 新闻管理 | ||
|
||
 | ||
|
||
在新闻管理页面,管理员可以添加新闻信息,也可以使用爬虫工具自动获取一些新闻信息,当然也可以进入新闻 | ||
页面的详情,对新闻的信息进行编辑或删除。 | ||
|
||
### 评论管理 | ||
|
||
 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import pymysql | ||
pymysql.install_as_MySQLdb() |
Oops, something went wrong.