All Projects → nladuo → Thstrader

nladuo / Thstrader

Licence: gpl-3.0
量化交易。同花顺免费模拟炒股软件客户端的python API。(Python3)

Projects that are alternatives of or similar to Thstrader

Quant Notes
Quantitative Interview Preparation Guide, updated version here ==>
Stars: ✭ 180 (-42.12%)
Mutual labels:  jupyter-notebook, finance, quant
Alpha Mind
quantitative security portfolio analysis. The analysis pipeline including data storage abstraction, alpha calculation, ML based alpha combining and portfolio calculation.
Stars: ✭ 171 (-45.02%)
Mutual labels:  jupyter-notebook, finance
Mixture model trading public
Stars: ✭ 166 (-46.62%)
Mutual labels:  jupyter-notebook, finance
Alphatools
Quantitative finance research tools in Python
Stars: ✭ 226 (-27.33%)
Mutual labels:  jupyter-notebook, quant
Datagene
DataGene - Identify How Similar TS Datasets Are to One Another (by @firmai)
Stars: ✭ 156 (-49.84%)
Mutual labels:  jupyter-notebook, finance
Algorithmictrading
This repository contains three ways to obtain arbitrage which are Dual Listing, Options and Statistical Arbitrage. These are projects in collaboration with Optiver and have been peer-reviewed by staff members of Optiver.
Stars: ✭ 157 (-49.52%)
Mutual labels:  jupyter-notebook, finance
Machine Learning And Reinforcement Learning In Finance
Machine Learning and Reinforcement Learning in Finance New York University Tandon School of Engineering
Stars: ✭ 173 (-44.37%)
Mutual labels:  jupyter-notebook, finance
Data Science Portfolio
A Portfolio of my Data Science Projects
Stars: ✭ 149 (-52.09%)
Mutual labels:  jupyter-notebook, finance
DeltaTrader
极简版Python量化交易工具
Stars: ✭ 174 (-44.05%)
Mutual labels:  finance, quant
pystockfilter
Financial technical and fundamental analysis indicator library for pystockdb.
Stars: ✭ 26 (-91.64%)
Mutual labels:  finance, quant
Beibo
🤖 Predict the stock market with AI 用AI预测股票市场
Stars: ✭ 46 (-85.21%)
Mutual labels:  finance, quant
Pyportfolioopt
Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity
Stars: ✭ 2,502 (+704.5%)
Mutual labels:  jupyter-notebook, finance
Alphalens
Performance analysis of predictive (alpha) stock factors
Stars: ✭ 2,130 (+584.89%)
Mutual labels:  jupyter-notebook, finance
Learnpythonforresearch
This repository provides everything you need to get started with Python for (social science) research.
Stars: ✭ 163 (-47.59%)
Mutual labels:  jupyter-notebook, finance
Simfin Tutorials
Tutorials for SimFin - Simple financial data for Python
Stars: ✭ 150 (-51.77%)
Mutual labels:  jupyter-notebook, finance
GOAi
No description or website provided.
Stars: ✭ 57 (-81.67%)
Mutual labels:  finance, quant
Python For Data Science
A blog for data analytics using data science technologies
Stars: ✭ 139 (-55.31%)
Mutual labels:  jupyter-notebook, finance
Finrl Library
FinRL: Financial Reinforcement Learning Framework. Please star. 🔥
Stars: ✭ 3,037 (+876.53%)
Mutual labels:  jupyter-notebook, finance
pandas-datareader-gdax
GDAX data for Pandas in the style of DataReader
Stars: ✭ 11 (-96.46%)
Mutual labels:  finance, quant
akshare
AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库
Stars: ✭ 5,155 (+1557.56%)
Mutual labels:  finance, quant

THSTrader

量化交易。同花顺免费模拟炒股软件客户端的python API。(Python3)

暂时无法更新

因为个人时间问题,这个项目搁置已久,断断续续更新过几次,10月份应该时间会闲下来很多,会争取完成更新。我先建了个群,感兴趣或者做这个的可以进来交流一下。

群号:399623752

为什么有这个项目

本来看到了这个easytrader这个项目,不过这个客户端已经过时了(被强制更新)。于是乎,自己看了一遍easytrader的源码,写了一个自己的版本。

安装说明

同花顺免费模拟炒股软件客户端安装

下载链接

这个版本是模拟炒股软件,但是可以添加不同券商的委托下单程序,是2015年更新的。 版本号:v8.10.44_20151010. 链接:https://pan.baidu.com/s/1H2rIxWZwBx-LuiFlXzc5Jg 提取码:5b15

python环境安装

pip3 install -r requirements.txt

操作接口(API)

操作演示视频见:https://www.bilibili.com/video/av46248487/

同花顺的安装使用方法:见视频的2p。

说明

首先登陆同花顺客户端下载委托程序,下载完退出同花顺客户端,只打开下单程序

注意:使用过程中请保证下单程序处于可视状态,不要最小化客户端。

示例代码

from THS.THSTrader import THSTrader


if __name__ == "__main__":
    trader = THSTrader(r"C:\同花顺软件\weituo\模拟炒股\xiadan.exe")    # 连接客户端

    print(trader.get_balance())                            # 获取当前可用资金

    print(trader.get_position())                           # 获取当前持有的股票

    print(trader.sell(stock_no="162411", amount=100, price=0.62))   # 卖出股票

    result = trader.buy(stock_no="162411", amount=100, price=0.541) # 买入股票
    print(result)

    if result["success"] == True:	 # 如果买入下单成功,尝试撤单
        print("撤单测试--->", end="")
        print(trader.cancel_entrust(entrust_no=result["entrust_no"]))

获取当前可用资金

trader.get_balance()

返回:

{
	'可用余额': 197264.69,
	'股票市值': 2869.4,
}

** 注意:这里总资产并不是可用余额+股票市值,有一些资金可能代表未成交的金额。 **

获取当前持有的股票

trader.get_position()

返回:

[{
	'证券代码': 2024,
	'证券名称': '苏宁易购',
	'股票余额': 100,
	'可用余额': 0,
	'冻结数量': 100,
	'盈亏': -0.31,
	'成本价': 13.123,
	'盈亏比例(%)': -0.02,
	'市价': 13.12,
	'市值': 1312.0,
	'交易市场': '深圳A股',
	'股东帐户': 101106569,
	'实际数量': 100,
	'可申赎数量': 100
}, {
	'证券代码': 162411,
	'证券名称': '华宝油气',
	'股票余额': 2600,
	'可用余额': 2600,
	'冻结数量': 0,
	'盈亏': 134.4,
	'成本价': 0.547,
	'盈亏比例(%)': 9.44,
	'市价': 0.6,
	'市值': 1557.4,
	'交易市场': '深圳A股',
	'股东帐户': 101106569,
	'实际数量': 2600,
	'可申赎数量': 2600
}]

买入股票

trader.buy(stock_no="162411", amount=100, price=0.541)

返回:

{
	'success': True,
	'msg': '您的买入委托已成功提交,合同编号:873674677。',
	'entrust_no': '873674677'
}

卖出股票

trader.sell(stock_no="162411", amount=100, price=0.62)

返回:

{
	'success': True,
	'msg': '您的卖出委托已成功提交,合同编号:873679996。',
	'entrust_no': '873679996'
}

买卖撤单

trader.cancel_entrust(entrust_no="873674677")

返回:

{
	'success': True,
	'msg': '您的撤单委托已成功提交,合同编号:873674677。',
	'entrust_no': '873674677'
}

LICENSE

GPL-3.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].