Skip to main content

Suluoya

Project description

Suluoya

This is a package written by Suluoya not just for fun!

pip error

pip3 install --ignore-installed olefile

pip3 install --ignore-installed llvmlite

pip3 install --ignore-installed filelock

1. Upgrade Suluoya

import Suluoya as sly
sly.upgrade()

2. Welcome

import Suluoya as sly
sly.welcome()

3. Print

(1)If you wanna print error prettier...

import Suluoya as sly
sly.error()
print(1 / 0)

4. Text

(1)If you wanna get text from your clipboard...

import Suluoya as sly
sly.get_clipboard(show=True)
a = sly.get_clipboard()
print(a)

(2)If you wanna get content from a file...

Currently support 'doc','docx','ppt','pptx','txt'

import Suluoya as sly
content = sly.get_content(file=r'c:\lalala\1.docx')
print(content)

(3)get all combination from a list

import Suluoya as sly
comb=sly.combine(lists=['A', 'B', 'C'])

(4)translate both English and Chinese into each other

if "show=False",return instead of print

import Suluoya as sly
sly.translate(text='Welcome to use Suluoya!', show=True)

(5)compare the texts

accurate=True --> accurate match mode

accurate=False --> fuzzy match mode

show=False --> return ratio instead of print

import Suluoya as sly
sly.text_compare(text1='Suluoya', text2='suluoya', accurate=True, show=True)

(6)word frequency

count the number of times words appear

import Suluoya as sly
sly.word_frequency(key='Suluoya', text='Welcome to use Suluoya!', show=True)

5. Analyse

(1)If you wanna analyse your dataframe...

import Suluoya as sly
import pandas as pd
df = pd.read_csv('https://sakai.unc.edu/access/content/group/3d1eb92e-7848-4f55-90c3-7c72a54e7e43/public/data/bycatch.csv')
sly.report(df)
#This will make a html,just look for and open it!

(2)sentiment analysis

language='C'-->Chinese

language='E'-->English

To download the necessary data,simply run "python -m textblob.download_corpora" before using it,if something goes wrong,then click https://zhuanlan.zhihu.com/p/272181552 or https://www.cnblogs.com/liweikuan/p/14052001.html,https://mp.weixin.qq.com/s?__biz=MzI1NzczMDIwNw==&mid=2247483777&idx=1&sn=cd985f3f7fe0472df9560de94753d86d&chksm=ea13b271dd643b67a591485d249ca9f64aaa380db3ff16c462c0d2def5ccce114e3c938b955e&token=445308227&lang=zh_CN#rd

import Suluoya as sly
sly.sentiment_analysis(text='',language='C',show=True)

(3)guess gender

name should be a Chinese name!

show=False --> return instead of print

import Suluoya as sly
sly.gender_guess(name='Suluoya',show=True)

6. Import

If you wanna auto import some packages...

use"import Suluoya.Import as SI" instead of "import pandas as pd,import numpy as np"...

#pass
import pandas as pd
import numpy as np
...
df = pd.Dataframe()
#now
import Suluoya.Import as SI
df = pd.Dataframe() # directly
SI.check() # just to check your import by using SI,can be omitted
# ps. go and see a file named "auto_imports.py"!

7. Crawl

from Suluoya.crawl import slycrawl as sc
sc=sc(url='',headers={},params={},cookies={},timeout=5)
print(sc.url)
print(sc.response)
print(sc.html)
print(sc.headers)
print(sc.params)
print(sc.cookies)
'''parsel.css'''
print(sc.selector)
'''BeautifulSoup'''
print(sc.soup)
'''it will return a **dic** which contain title,text,description,keywords,tags,image,infomation and the raw_html'''
print(sc.text)
'''it will return a dictionary which contain text,title,html,author,image,movies,keywords and summary.'''
print(sc.news)
'''url links'''
print(sc.links)
'''pandas.read_html'''
print(sc.tables)

get proxies

from Suluoya.crawl import GetProxy as gp
proxies=gp(number=1)
print(proxies)

8. Download

from Suluoya.crawl import slydownload as sd
sd=sd(url='')

(1)download music

sd.download_music(path='d:\\')

(2)download video

sd.download_video()

(3)download anything you want with an URL

sd.download()

(4)download a big file

sd.download_big_file()

9. QRcode...

import Suluoya as sly

(1)make a QRcode

fill in an url or some strings in content

fill in the name of the png in name

sly.QRcode(content='', name='')

(2)contact

If you wanna contact Suluoya...

sly.contact(mode='wechat')
sly.contact(mode='qq')

9. Fun

import Suluoya as sly

(1)draw a heart

#draw a Suluoya heart
sly.draw_a_heart()
#draw any hearts you want
sly.draw_a_heart(name='any name you like')

(2)xkcd

#you do know what I mean!
sly.xkcd()

(3)standard time

get standard time

show=False --> return instead of print

sly.standard_time(show=True)

(4)voice synthesis

really make a sound

sly.voice_synthesis(text='Welcome to use Suluoya!')

10. Stock

(1)initialize

from Suluoya.stock import slystock as sk
sk=sk(names=['隆基股份','贵州茅台'],
     start_date='2020-12-01', 
     end_date='2020-12-31',
     frequency="w")#d→day,w→week,m→month
print(
    sk.start_date,
    sk.end_date,
	sk.frequency,
    sk.names,
    sk.combinations,
    sk.information,
    sk.codes,
    sk.stock_pair,
    sk.data
)

(2)stock data

reference: http://baostock.com/baostock/index.php/Python_API%E6%96%87%E6%A1%A3

#adjustflag:复权类型,默认不复权:3;1:后复权;2:前复权。已支持分钟线、日线、周线、月线前后复权。

#frequency:数据类型,默认为d,日k线;d=日k线、w=周、m=月、5=5分钟、15=15分钟、30=30分钟、60=60分钟k线数据,不区分大小写;指数没有分钟线数据;周线每周最后一个交易日才可以获取,月线每月最后一个交易日才可以获取
from Suluoya.stock import getstock
#initialize
gk = getstock(names=['隆基股份','贵州茅台'], 
                  start_date='2020-12-01', 
                  end_date='2020-12-31',
                  frequency='w'     
                  )
combination=gk.comnine # return a dataframe
stockpair=gk.stock_pair
stockdata=gk.stock_data # return codes, stock pair, stock data
gk.quit() #Please don't forget it!

(3)calculate sharp ratio

#dic_sharp contains weights,risk,rate of return and sharp ratio
#eg. weights=[0.1,0.2,0.3,0.4],stock_list=['隆基股份','五粮液','贵州茅台','宁德时代']
#The stock_list should be in the names!
#no_risk_rate means “无风险收益率”
from Suluoya.stock import slystock as sk
dic_sharp = sk.sharp(weights=[], stock_list=[], no_risk_rate=0.45/5200)
print(dic_sharp)
sk.quit()#Please don't forget it!

(4)Markowit

from Suluoya.stock import slystock as sk
sk=sk(names=['隆基股份','贵州茅台'],
     start_date='2020-12-01', 
     end_date='2020-12-31',
     frequency="w"
     )
#if stock_list = [], stock_list = names
#accurate:True→gradient descent,False→500 random weights
markowit=sk.Markowit(stock_list=[],
                     accurate=True, 
                     number=500, 
                     no_risk_rate=0.45/5200)
print(markowit)

sk.quit()#Please don't forget it!

(5)investment portfolio

from Suluoya.stock import slystock as sk
sk=sk(names=['隆基股份','贵州茅台'],
     start_date='2020-12-01', 
     end_date='2020-12-31',
     frequency="w"
     )
#accurate=False
result = sk.portfolio(accurate=False, number=500, no_risk_rate=0.45/5200)
print(result)
#accurate=True
print(sk.save_result())

sk.quit()#Please don't forget it!

(6)choose good stocks

#get data from "http://fund.eastmoney.com/data/rankhandler.aspx"
from Suluoya.stock import getgoodstock as gs
df=gs.get_good_stock(page=5)
print(df)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Suluoya-1.5.5.tar.gz (15.6 kB view details)

Uploaded Source

File details

Details for the file Suluoya-1.5.5.tar.gz.

File metadata

  • Download URL: Suluoya-1.5.5.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.6.5

File hashes

Hashes for Suluoya-1.5.5.tar.gz
Algorithm Hash digest
SHA256 410624941d013db2f777c09bd9148a6c9f5928954ed0148ff9f151cc19312ea0
MD5 2bb77b2a6258a027a73dfe6d440b2e59
BLAKE2b-256 fc60b8d53c50bb680b01659321bea730f93900447f8b4f20181a78994045df7f

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page