Better help yourself in stock trading (losing money-.-)
2022-12-08 Update
The project code is currently being reconstructed. The directory structure may be slightly different from the description below. It will be slowly updated and modified later. Thank you for your attention and support.
analysis/data analysis part
datahub/ data collection part
fund/ Fund-related analysis part
*futu/Basic usage of Futu Niuniu interface*
hk_stock/ Hong Kong stocks section
k-line/ K-line technical form part
machine_learning/ machine learning prediction
trader/ trading part
ptrade/ptrade automatic trading real code
log/ storage log
common/ common functions and libraries
configure database connection and configuration
Usage tutorial:
- Modify configure/sample_config.json The configuration file is named configure/config.json. According to different projects, modify the fields inside and modify your mysql, mongodb user name and password. If mysql, mongodb, etc. are not used in the project , no modification is required. The corresponding mapping relationship can be found in the source code in this file. This setting is mainly to facilitate switching between online and local databases with the same set of code, and does not use environment variables to store user passwords. Friends who need it can also change it themselves.
configure/setting.py
def config(self, db_type='mysql', local='ubuntu'):
db_dict = self.json_data[db_type][local]
user = db_dict['user']
password = db_dict['password']
host = db_dict['host']
port = db_dict['port']
return (user, password, host, port)
def get_engine(self, db, type_='ubuntu'):
from sqlalchemy import create_engine
user, password, host, port = self.config(db_type='mysql', local=type_)
try:
engine = create_engine(
'mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8'.format(user, password, host, port, db))
except Exception as e:
print(e)
return None
return engine
def get_mysql_conn(self, db, type_='ubuntu'):
import pymysql
user, password, host, port = self.config(db_type='mysql', local=type_)
try:
conn = pymysql.connect(host=host, port=port, user=user, password=password, db=db, charset='utf8')
except Exception as e:
print(e)
return None
else:
return conn
def mongo(self, location_type='ubuntu', async_type=False):
user, password, host, port = self.config('mongo', location_type)
connect_uri = f'mongodb://{user}:{password}@{host}:{port}'
if async_type:
from motor.motor_asyncio import AsyncIOMotorClient
client = AsyncIOMotorClient(connect_uri)
else:
import pymongo
client = pymongo.MongoClient(connect_uri)
return client
At the end of the article, there are benefits for brokers: providing an automated order placing interface for brokers
Quantitative trading for coders, write their experiences into code and push it to github. The code and strategies will be kept updated. If you have good strategies or ideas and questions that you want to communicate, you can add a WeChat message at the end of the article.
New:
analysis directory data analysis section
- analysis/get_zt_info Analyze the daily limit strength in the new sector
- analysis/diagnose_stock stock diagnosis, whether there is a black history and Northeastern stocks
- analysis/ipospeed Correlation between IPO issuance speed and index
- analysis/fd_money The price limit of A-share orders within a certain period of time
fund
- fund/LOFShareDection.py monitors LOF and ETF market share changes
- fund/ark_funds.py obtains the daily position data of ARK ETF and writes it to mongodb
- fund/fund_share_update.py Shanghai Stock Exchange, Shenzhen Stock Exchange fund exchange fund share monitoring
- fund/fund_share_monitor.py Shanghai Stock Exchange, Shenzhen Stock Exchange fund share query, size changes
- fund/fund_info_spider.py Jisilu Fund, Tencent Securities Fund discount rate, premium rate crawler
- fund/etf_info.py Monitoring of market index fund holdings
- fund/ttjj.py Get daily fund data
- fund/xueqiu_private_fund.py Snowball private equity acquisition
- fund/danjuan_fund.py Snowball Egg Roll Fund data acquisition
- fund/danjuan_fund_data_analysis.py Snowball Egg Roll Fund Analysis
datahub (data source)
- datahub/foreignexchange.py USD/CNY exchange rate monitoring
- datahub/niwen.py Download Ningwen Convertible Bonds
- datahub/public_private_fund_members.py Cemetery private equity fund member data
- datahub/jucao_ammouncement.py Juchao announcement batch acquisition + PDF download
- datahub/bond_industry_info.py Convertible bond industry distribution
- datahub/ceiling_break.py daily limit board closure monitoring
k-line (K-line technical form recognition)
- k-line/recognize_form.py Recognize common forms through talib, such as three crows, etc.
Already have:
- datahub/black_list_sql.py records the list of all stocks with black history in the A-share market and stores them in the database
- big_deal.py monitors daily large transactions in the A-share market
- bond_monitor convertible bond monitoring
- ceiling_break.py How many days after the opening of the new stock market can the new stock return to the opening price?
- delivery_order.py exports the delivery order to Mysql, making it easy to find traces of the operation history of a certain clearance stock, and you can see your operation records at a glance
- fetch_each_day.py -- Get the top 50 popular stocks with daily turnover rate
- filter_stock.py Select stocks through different factor strategies, common ones such as price-earnings ratio, liquidity, number of shareholders, number of fund holdings, etc.
- foreign_exchange.py gets the daily trend of the US dollar exchange rate and stores it in Mysql
- get_break_high.py -- Get the stocks that broke 50-day highs on the day. Why not get 60 days? Because everyone is using it, and if there are too many people using it, it won’t be allowed.
- ipospeed.py counts the correlation between the daily IPO new stock issuance speed and the market
- ipo_stock.py new stock statistics
- jisilu.py Get convertible bond market information from Jisilu
- jubi.py - Get real-time data from domestic altcoin platforms
- new_stock_break Analyze the opening timing of new stocks
- new_stock_fund Obtain new funds and select funds that won the Science and Technology Innovation Board
- pledged_validation.py Equity pledge data compilation
- push_msn.py - SMS to remind you that the price or increase of a certain stock you set reaches your requirements
- relationship_case.py The relationship between the released stocks and the market index every month
- select_stock.py - Stock selection strategy, stocks selected based on your own experience.
- SPSIOP_PRICE.py - Huabao oil and gas valuation obtains data through crawlers and then calculates it
- stockInfo.py crawls market stock news messages and stores them in the ElasticSearch database
- strategy_verify.py gets Snowball’s strategy and verifies it
- simulation.py records its own simulation warehouse
- strategy_verify.py - Get Snowball’s live trading strategy
- win_or_lost_each_day.py -- Evaluate your daily profit and loss of each stock with 100% completion
- zdt.py --The daily limit popularity of the stock market
Welfare
Brokerage quantitative order interface
Supports python language, can be deployed in the cloud or run locally, and supports A-share market stocks, convertible bonds, funds and other varieties.
Interface documentation
Rate
Low transaction fees:
Stocks in case; convertible bonds 0.4 million; fund ETF, LOF 0.5 million
After opening the quantitative interface, there is no additional fee and it can be used permanently.
Activation conditions: Different brokers have different thresholds
- Broker 1: Deposit 1W after opening an account to open the account
- Broker 2: After opening an account, you can open it by depositing 20,000 yuan.
Of course, there are also other mainstream brokers to choose from, such as Huatai, GF, Huabao, China Merchants, China International Finance Corporation, Galaxy Securities, etc., which can basically cover mainstream brokers.
Activation method:
Scan code
Note: Open an account.
Follow the developer’s public account: Quantitative analysis of convertible bonds