semvec/pypi-packages huggingface dataset:
one-quant-data 0.1.9
Data engine for stockA quant

# one-quant-data

one_quant_data是A股量化数据引擎，用于为量化工具提供数据支撑

目前，本库的数据来源是基于tushare.pro接口，可以认为是tushare的数据接口封装

由于tushare的数据访问有一定的频率限制，为避免tushare的访问限制，将数据缓存到自己的数据库中
同时，由于数据在指定数据库中，因此又可以提供一些新的使用数据的角度


### 安装方法
```
    $ pip install one_quant_data 
```


### 使用方法
 1. 先建立配置文件config.json
```
{
    "data_engine":{
        "api":{
            "name":"tushare_pro",
            "token":"your_tusharepro_token"
        },
        "cache":{
            "db":"mysql",
            "host":"yourdbhost",
            "port":3306,
            "user":"yourusername",
            "password":"yourpasswd",
            "schema":"yourdbname"
            "start_date":"20190101"  #需要缓存数据的起始日期
        }
    }
}
```
  说明：
   - api的name可选tushare_pro或者offline，offline表示只使用数据库里的数据
 2. 引用数据包
```
    from one_quant_data import DataEngine
```  
 3. 初始化类DataEngine
```
    engine = DataEngine('../config.json')
```
 4. 同步数据，可以启动定时任务进行调用，第一次运行会建立数据库并缓存从起始日期到今天的所有数据，以后再调用时只会增量添加数据。同步数据时必须使用tushare_pro接口 
     同步数据的接口有两个：
       sync_data_iterate_date是按日期同步，适合每天运行同步交易数据
       sync_data_iterate_stock是按股票同步，用于更新不频繁的数据，可以隔一段时间再调用一次
```
    engine.sync_data_iterate_date()
```
 5. 使用数据，使用接口与tushare.pro保持一致,区别在于只会返回缓存的数据
```    
    df = engine.stock_basic()
    df = engine.pro_bar('000651.SZ',adj='qfq')
    df = engine.daily_basic(trade_date='20190926')
    df = engine.daily_basic('000651.SZ')
    df = engine.index_dailybasic(trade_date='20190926')
    df = engine.index_dailybasic('000001.SH')
    df = engine.index_daily('000001.SH')
    df = engine.fina_mainbz(ts_code='000627.SZ', type='P')
    df = engine.fina_mainbz_vip(period='20190630', type='P')
```
 6. 需要使用tushare接口时，使用DataEngine的pro字段来访问tushare
```
    pro = engine.pro
    df = pro.query()
```
 7. 自定义的接口

    | 接口 | 功能 | 输入参数 | 输出格式 | 说明 |
    | ---- | ---- | -------- | -------- | ---- |
    |index_codes| 返回缓存的指数代码| | list | |  
    |cached_range| 返回缓存的数据的开始，结束时间| | (cached_start,cached_end) |输出格式为tuple|
    |attach_stock_name| 根据一个dataframe的ts_code，添加股票名称|df|带name列的dataframe|必须有ts_code字段|
    |get_cached_trade_dates|获得所有缓存的数据日期| |list | |
kopper 0.1.1
This is a Korail seat reservation support service.         If you cannot make a reservation, we will tell you how to make a reservation             by adding an intermediate station.

[Korail](http://www.letskorail.com/) 에서 기차 예매를 진행할 때,
출발역에서 도착역까지 예매를 할 수 없는 경우 중간 정차역을 껴서 예매가
가능한 구간이 있는 지 확인하는 코드입니다.

|            | $Seat_{n-1}$ | $Seat_{n}$ | $Seat_{n+1}$ | $Seat_{n+k}$ |
|----------- | ------------ | ---------- | ------------ | ------------ |
| 서울-천안 | X | O | X | X |
| 천안-부산 | X | X | O | X |

서울에서 부산까지 완전히 비어있는 좌석이 없으므로 예약할 수 없지만, (서울 - 천안), (천안 - 부산) 구간에서 티켓을 구매할 수 있습니다.

* * * * *

## 0. 설치

```bash
$ pip install kopper
```


## 1. 기차 정보 조회

```python
from kopper import *

kopper = Kopper()

# 기차 기본 정보 (최대 10개 조회)
trains_info = kopper.trains_info("20200315", "60000", STATIONS.광명, STATIONS.부산, TRAIN_TYPE.KTX)


for train_info in trains_info:
    print(train_info)

"""
No.00101     KTX     광명(053100) ------ 부산(075100)
No.00103     KTX     광명(054600) ------ 부산(081700)
No.00105     KTX     광명(061600) ------ 부산(083700)
No.00201     KTX_산천      광명(062100) ------ 부산(085400)
No.00107     KTX     광명(065100) ------ 부산(091600)
No.00109     KTX     광명(071600) ------ 부산(094000)
No.00111     KTX     광명(074600) ------ 부산(100200)
No.00113     KTX     광명(080900) ------ 부산(100700)
No.00115     KTX     광명(081700) ------ 부산(104300)
No.00119     KTX_산천      광명(095100) ------ 부산(122400)
"""
```


## 2. 기차 시간표 조회

```python
# 기차 선택
selected_train_info = trains_info[0]

# 선택한 기차 시간표 조회
selected_train_schedule = kopper.train_schedule(selected_train_info) 

print(selected_train_schedule)

"""
광명 (05:31) - 대전 (06:10) 
대전 (06:12) - 동대구 (06:56) 
동대구 (06:58) - 신경주 (07:15) 
신경주 (07:16) - 울산_통도사 (07:27) 
울산_통도사 (07:29) - 부산 (07:51)
"""
```


## 3. 선택한 기차 칸 번호 조회

```python
selected_train_srcar_length = kopper.train_srcar_length(selected_train_info)

print(selected_train_srcar_length)

"""
['1', '5', '6', '7', '8', '9', '10', '11', '12', '13', '15', '17', '18']
"""
```


## 4. 예매할 수 있는 구간 출력

```python
# 보통 약 10 ~ 20초 정도 크롤링 시간 소요
dict_selected_train_seats = kopper.train_seats_by_schedule(selected_train_info, selected_train_schedule, selected_train_srcar_length)

kopper.report_routes(selected_train_schedule, dict_selected_train_seats)

"""
광명 (05:31) - 부산 (07:51)
"""
```
xuerui-stat 0.0.8
A statistical package to manage and analyse data
Requires Python: >=3.7

# xuerui-stat
[![Build Status](https://www.travis-ci.org/Xuerui-Yang/xuerui-stat.svg?branch=master
)](https://www.travis-ci.org/Xuerui-Yang/xuerui-stat)

An open-source Python package for using statistical tools and methods.

## Source code
https://github.com/Xuerui-Yang/xuerui-stat

## Installation
```
pip install xuerui-stat
```

## Tools and methods

### DataManager
+ Description

It is a tool to manage data files. Once a data file is imported, the tool would move it to a specified data directory automatically. And when importing data, the tool can search files in the data directory.

+ Example
```python
from xuerui_stat import DataManager
dm = DataManager(enable=True)
```
This command defines a class to name the tool. For the first use, users should use the command 'set_dir(yourpath)' with your prefered path to set your data directory, for example,
```python
dm.set_dir('/home/xuerui/Documents/Data/')
```
Once it is done, the directory path is printed like this:

>Data directory: '/home/xuerui/Documents/Data/'

The parameter 'enable' for the class can be set as True or False. When it is True, the data file imported by the command below would be moved to the data directory automatically. 
```python
df=dm.import_data('/home/xuerui/Documents/PythonProjects/FactorAnalysis/example.csv')
```
Otherwise users can manually move the files using the such command:
```python
dm.addto_dir('/home/xuerui/Documents/example.csv')
```
The moved data files are renamed by adding the script names, in order to identify them. For example, 'example.csv' is imported in 'my_example.py' using the above command. So it would be moved to the data directory and renamed as 'MyExample_example.csv'. 

Users can also check the contents under the data directory using
```python
dm.list_dir()
```

### DecisionTree, PlotTree, RandomForest
+ Description

These commands give users tools for data mining by using tree relevant methods.

+ Example

As above, the following commands import the data which is to be analyse.
```python
from xuerui_stat import *
dm = DataManager(enable=False)
data=dm.import_data("/home/xuerui/Documents/PythonProjects/test.csv")
```

The decision tree method can be applied to the data by specifying the name of category.
```python
dt=DecisionTree(data,'Cat')
dt.train()
t=dt.tree
print(t)

pt=PlotTree(dt)
pt.tree_structure_plot()

dt.test()
pt.confusion_matrix_plot()
```

The tree and confusion matrix can be plotted via the 'PlotTree' module.

Furthermore, the random forest can also be used as follows:
```python
rf=RandomForest(data,'Cat')
rf.train(num_tree=300,max_depth=0,min_gini=0)
print(rf.oob_error)
dt.test()
print(dt.confusion_matrix)
```


```
readwise-django-rq-scheduler 1.1.4
A database backed job scheduler for Django RQ

# Readwise Django RQ Scheduler

A database backed job scheduler for Django RQ.

## Requirements

Currently, when you pip install Django RQ Scheduler the following packages are also installed.

* django >= 2
* django-model-utils >= 2.4
* django-rq >= 0.9.3 (Django RQ requires RQ >= 0.5.5)
* rq-scheduler >= 0.6.0
* pytz >= 2015.7
* croniter >= 0.3.24

Testing also requires:

* factory_boy >= 2.6.1
* psycopg2 >= 2.6.1


## Usage

### Install

Use pip to install:

```
pip install django-rq-scheduler
```


### Update Django Settings

1. In `settings.py`, add `django_rq` and `scheduler` to  `INSTALLED_APPS`:

	INSTALLED_APPS = [
    	...
    	'django_rq',
    	'scheduler',
    	...
	]

2. Configure Django RQ. See https://github.com/ui/django-rq#installation


### Migrate

The last step is migrate the database:

```
./manage.py migrate
```

## Creating a Job

See http://python-rq.org/docs/jobs/ or https://github.com/ui/django-rq#job-decorator

An example:

**myapp.jobs.py**

.. code:: python

    @job
    def count():
        return 1 + 1

## Scheduling a Job

### Scheduled Job

1. Sign into the Django Admin site, http://localhost:8000/admin/ and locate the **Django RQ Scheduler** section.

2. Click on the **Add** link for Scheduled Job.

3. Enter a unique name for the job in the **Name** field.

4. In the **Callable** field, enter a Python dot notation path to the method that defines the job. For the example above, that would be `myapp.jobs.count`

5. Choose your **Queue**. Side Note: The queues listed are defined in the Django Settings.

6. Enter the time the job is to be executed in the **Scheduled time** field. Side Note: Enter the date via the browser's local timezone, the time will automatically convert UTC.

7. Click the **Save** button to schedule the job.

### Repeatable Job

1. Sign into the Django Admin site, http://localhost:8000/admin/ and locate the **Django RQ Scheduler** section.

2. Click on the **Add** link for Repeatable Job

3. Enter a unique name for the job in the **Name** field.

4. In the **Callable** field, enter a Python dot notation path to the method that defines the job. For the example above, that would be `myapp.jobs.count`

5. Choose your **Queue**. Side Note: The queues listed are defined in the Django Settings.

6. Enter the time the first job is to be executed in the **Scheduled time** field. Side Note: Enter the date via the browser's local timezone, the time will automatically convert UTC.

7. Enter an **Interval**, and choose the **Interval unit**. This will calculate the time before the function is called again.

8. In the **Repeat** field, enter the number of time the job is to be ran. Leaving the field empty, means the job will be scheduled to run forever.

9. Click the **Save** button to schedule the job.


## Reporting issues or Features

Please report issues via [GitHub Issues](https://github.com/istrategylabs/django-rq-scheduler/issues) .