西奥框架
theo-framework的Python项目详细描述
Theo框架
正是框架使项目的构建变得容易。
dictlist是一种方便、高效地控制数据的数据结构。 日志是通过打印和存储来记录程序的。 系统和组件使构建系统变得容易。
我很可能在等待任何形式的贡献。
西奥系列
框架:pip安装theo框架,https://github.com/TheodoreWon/python-theo-framework
数据库:pip安装theo数据库,https://github.com/TheodoreWon/python-theo-database
消息:pip install theo消息,https://github.com/TheodoreWon/python-theo-message
互联网:pip安装theo消息,https://github.com/TheodoreWon/python-theo-internet
trade:pip安装theo trade,https://github.com/TheodoreWon/python-theo-trade
如何使用
安装框架
pip install theo-framework
打印文档字符串
from theo.framework import DictList, Log, System, Component
print(DictList.__doc__)
print(Log.__doc__)
print(System.__doc__)
print(Component.__doc__)
简单示例(对于系统、组件,请参阅docstrings)
''' import theo-framework '''
from theo.framework import Log, DictList
''' print log using Log '''
Log.configure(print_enabled=True, store_enabled=True) : default of store_enable is False
log = Log('main')
log.print('info', 'Hello, theo-framework!')[2018-12-31 13:29:27,958][main][info] Hello, theo-framework! : log file will be stored.
''' print csv file using DictList '''
import os
kospi_dictlist = DictList('code')
kospi_dictlist.import_csv(os.path.join(os.getcwd(), 'kospi.csv'))
kospi_dictlist.print()DictList(num:1523/key:code) walkers(num:0)
0 {'code': '000020', 'tag': '', '250 days high': '13400.0', '250 days low': '7500.0', 'eps': '1683.0', 'market capitalization': '2623.0', 'net profit': '470.0', 'net sales': '2589.0', 'operating profit': '110.0', 'pbr': '0.88', 'per': '5.58', 'roe': '17.1'}
1 {'code': '000030', 'tag': 'kospi100/kospi50', '250 days high': '17400.0', '250 days low': '13550.0', 'eps': '2237.0', 'market capitalization': '108160.0', 'net profit': '15301.0', 'net sales': '85507.0', 'operating profit': '21567.0', 'pbr': '0.53', 'per': '7.15', 'roe': '7.4'}
2 {'code': '000040', 'tag': '', '250 days high': '760.0', '250 days low': '317.0', 'eps': '-263.0', 'market capitalization': '684.0', 'net profit': '-315.0', 'net sales': '417.0', 'operating profit': '-260.0', 'pbr': '1.51', 'per': '0.0', 'roe': '-61.3'}
...
1520 {'code': '590017', 'tag': '', '250 days high': '12600.0', '250 days low': '11020.0', 'eps': '0.0', 'market capitalization': '242.0', 'net profit': '0.0', 'net sales': '0.0', 'operating profit': '0.0', 'pbr': '0.0', 'per': '0.0', 'roe': '0.0'}
1521 {'code': '590018', 'tag': '', '250 days high': '13115.0', '250 days low': '7880.0', 'eps': '0.0', 'market capitalization': '173.0', 'net profit': '0.0', 'net sales': '0.0', 'operating profit': '0.0', 'pbr': '0.0', 'per': '0.0', 'roe': '0.0'}
1522 {'code': '900140', 'tag': '', '250 days high': '5650.0', '250 days low': '1750.0', 'eps': '311.0', 'market capitalization': '1209.0', 'net profit': '136.0', 'net sales': '3334.0', 'operating profit': '-226.0', 'pbr': '0.27', 'per': '8.11', 'roe': '3.4'}
''' get datum '''
print(kospi_dictlist.get_datum('000060')){'code': '000060', 'tag': '', '250 days high': '25750.0', '250 days low': '17400.0', 'eps': '3479.0', 'market capitalization': '23532.0', 'net profit': '3846.0', 'net sales': '64287.0', 'operating profit': '5136.0', 'pbr': '1.28', 'per': '5.95', 'roe': '22.5'}
''' get datum '''
print(kospi_dictlist.get_datum('roe', '17.1')){'code': '000020', 'tag': '', '250 days high': '13400.0', '250 days low': '7500.0', 'eps': '1683.0', 'market capitalization': '2623.0', 'net profit': '470.0', 'net sales': '2589.0', 'operating profit': '110.0', 'pbr': '0.88', 'per': '5.58', 'roe': '17.1'}
''' get data '''
print(kospi_dictlist.get_data([{'key': 'net sales', 'value': '0.0'}, {'key': 'net profit', 'value': '0.0'}]))[{'code': '000075', 'tag': '', '250 days high': '70900.0', '250 days low': '45050.0', 'eps': '0.0', 'market capitalization': '145.0', 'net profit': '0.0', 'net sales': '0.0', 'operating profit': '0.0', 'pbr': '0.0', 'per': '0.0', 'roe': '0.0'}, {'code': '000087', 'tag': '', '250 days high': '19200.0', '250 days low': '13550.0', 'eps': '0.0', 'market capitalization': '163.0', 'net profit': '0.0', 'net sales': '0.0', 'operating profit': '0.0', 'pbr': '0.0', 'per': '0.0', 'roe': '0.0'}, {'code': '000105', 'tag': '', '250 days high': '296000.0', '250 days low': '161000.0', 'eps': '0.0', 'market capitalization': '514.0', 'net profit': '0.0', 'net sales': '0.0', 'operating profit': '0.0', 'pbr': '0.0', 'per': '0.0', 'roe': '0.0'}, {'code': '000145', 'tag': '', '250 days high': '10700.0', '250 days low': '7020.0', 'eps': '0.0', 'market capitalization': '39.0', 'net profit': '0.0', 'net sales': '0.0', 'operating profit': '0.0', 'pbr': '0.0', 'per': '0.0', 'roe': '0.0'}, {'code': '000155', 'tag': '', '250 days high': '84300.0', '250 days low': '69800.0', 'eps': '0.0', 'market capitalization': '3427.0', 'net profit': '0.0', 'net sales': '0.0', 'operating profit': '0.0', 'pbr': '0.0', 'per': '0.0', 'roe': '0.0'}, ...
''' export '''
kospi_dictlist.import_mongodb('kospi', 'codes')
作者
Theodore Won-该项目的所有者
许可证
此项目是根据麻省理工学院的许可证授权的-有关详细信息,请参见许可证文件
版本控制
基本上,这个项目遵循“语义版本控制”。(https://semver.org/)
但是,为了通知新特性,我在语义版本控制中添加了几个简单的规则。
我想叫“Theo版本控制”。
- 版本格式为major.minor.patch
- 当api改变或提供新特性时,主版本会增加。
- 新功能不影响界面。
- 但是,为了通知新特性,新特性会生成主版本。
- 在正式版本发布(1.0.0)之前,主版本保持为0,次版本使用。
- 添加API时,次要版本已启动。(新功能)
- 修补程序版本在修复错误、上载测试代码、更新注释或文档或日志时解除。