Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_000778_holder_trading():
result: List[HolderTrading] = fundamental.get_holder_trading(session=session, provider=Provider.EASTMONEY,
return_type='domain',
codes=['000778'],
end_timestamp='2018-09-30',
start_timestamp='2018-09-30',
order=HolderTrading.holding_pct.desc())
assert len(result) == 6
assert result[0].holder_name == '新兴际华集团有限公司'
assert result[0].change_pct == 0.0205
assert result[0].volume == 32080000
assert result[0].holding_pct == 0.3996
correct_timestamps = ['2018-09-30', '2018-06-30', '2018-03-31', '2017-12-31', '2017-09-30', '2017-06-30',
'2017-03-31', '2016-12-31', '2016-09-30', '2016-06-30', '2016-03-31', '2015-12-31',
'2015-09-30', '2015-06-30', '2015-03-31', '2014-12-31', '2014-09-30', '2014-06-30',
'2014-03-31', '2013-12-31', '2013-09-30', '2013-06-30', '2013-03-31', '2012-12-31',
'2012-09-30', '2012-06-30', '2012-03-31', '2011-12-31', '2011-09-30', '2011-06-30',
'2011-03-31', '2010-12-31', '2010-09-30', '2010-06-30', '2010-03-31', '2009-12-31',
'2009-09-30', '2009-06-30', '2009-03-31', '2008-12-31', '2008-09-30', '2008-06-30',
'2008-03-31', '2007-12-31', '2007-09-30', '2007-06-30', '2007-03-31', '2006-12-31',
'2006-09-30', '2006-06-30', '2006-03-31', '2005-12-31', '2005-09-30', '2005-06-30',
'2005-03-31', '2004-12-31', '2004-09-30', '2004-06-30', '2004-03-31', '2003-12-31',
'2003-09-30', '2003-06-30', '2003-03-31', '2002-12-31', '2002-09-30', '2002-06-30',
'2002-03-31', '2001-12-31', '2001-06-30', '2000-12-31', '2000-06-30', '1999-12-31',
'1999-06-30', '1998-12-31', '1998-06-30', '1997-12-31', '1997-06-30', '1996-12-31',
'1996-06-30', '1995-12-31', '1995-06-30', '1994-12-31', '1994-06-30', '1993-12-31',
'1992-12-31', '1991-12-31', '1990-12-31', '1989-12-31']
result = fundamental.get_balance_sheet(session=session, provider=Provider.EASTMONEY, return_type='domain',
codes=['000001'], end_timestamp='2018-09-30',
order=BalanceSheet.timestamp.desc())
assert len(correct_timestamps) == len(result)
timestamps = [to_time_str(item.timestamp) for item in result]
assert set(correct_timestamps) == set(timestamps)
latest: BalanceSheet = result[0]
assert latest.fi_cash_and_deposit_in_central_bank == 287600000000
assert latest.fi_deposit_in_other_fi == 95310000000
assert latest.fi_expensive_metals == 72020000000
assert latest.fi_lending_to_other_fi == 88100000000
assert latest.fi_financial_assets_effect_current_income == 103500000000
assert latest.fi_financial_derivative_asset == 25650000000
assert latest.fi_buying_sell_back_fi__asset == 32760000000
assert latest.accounts_receivable == 22830000000
assert latest.fi_interest_receivable == 18310000000
def test_000778_spo_detial():
result = fundamental.get_spo_detail(session=session, provider=Provider.EASTMONEY, return_type='domain',
codes=['000778'], end_timestamp='2018-09-30',
order=SPODetail.timestamp.desc())
assert len(result) == 4
latest: SPODetail = result[0]
assert latest.timestamp == to_pd_timestamp('2017-04-01')
assert latest.spo_issues == 347600000
assert latest.spo_price == 5.15
assert latest.spo_raising_fund == 1766000000
def test_000778_top_ten_tradable_holder():
result: List[TopTenHolder] = fundamental.get_top_ten_tradable_holder(session=session, provider=Provider.EASTMONEY,
return_type='domain',
codes=['000778'], end_timestamp='2018-09-30',
start_timestamp='2018-09-30',
order=TopTenTradableHolder.shareholding_ratio.desc())
assert len(result) == 10
assert result[0].holder_name == '新兴际华集团有限公司'
assert result[0].shareholding_numbers == 1525000000
assert result[0].shareholding_ratio == 0.389
assert result[0].change == 38560000
assert result[0].change_ratio == 0.0259
def test_000778_top_ten_holder():
result: List[TopTenHolder] = fundamental.get_top_ten_holder(session=session, provider=Provider.EASTMONEY,
return_type='domain',
codes=['000778'], end_timestamp='2018-09-30',
start_timestamp='2018-09-30',
order=TopTenHolder.shareholding_ratio.desc())
assert len(result) == 10
assert result[0].holder_name == '新兴际华集团有限公司'
assert result[0].shareholding_numbers == 1595000000
assert result[0].shareholding_ratio == 0.3996
assert result[0].change == 32080000
assert result[0].change_ratio == 0.0205
def test_000778_manager_trading():
result: List[ManagerTrading] = fundamental.get_manager_trading(session=session, provider=Provider.EASTMONEY,
return_type='domain',
codes=['000778'],
end_timestamp='2018-09-30',
start_timestamp='2017-09-30',
order=ManagerTrading.holding.desc())
assert len(result) == 1
assert result[0].trading_person == '巩国平'
assert result[0].volume == 8400
assert result[0].price == None
assert result[0].holding == 18700
assert result[0].trading_way == '增持'
assert result[0].manager_position == '职工监事'
assert result[0].manager == '巩国平'
assert result[0].relationship_with_manager == '本人'
def test_000778_dividend_financing():
result = fundamental.get_dividend_financing(session=session, provider=Provider.EASTMONEY, return_type='domain',
codes=['000778'], end_timestamp='2018-09-30',
order=DividendFinancing.timestamp.desc())
assert len(result) == 22
latest: DividendFinancing = result[1]
assert latest.timestamp == to_pd_timestamp('2017')
assert latest.dividend_money == 598632026.4
assert latest.spo_issues == 347572815.0
assert latest.rights_issues == 0
assert latest.ipo_issues == 0
'2017-03-31', '2016-12-31', '2016-09-30', '2016-06-30', '2016-03-31', '2015-12-31',
'2015-09-30', '2015-06-30', '2015-03-31', '2014-12-31', '2014-09-30', '2014-06-30',
'2014-03-31', '2013-12-31', '2013-09-30', '2013-06-30', '2013-03-31', '2012-12-31',
'2012-09-30', '2012-06-30', '2012-03-31', '2011-12-31', '2011-09-30', '2011-06-30',
'2011-03-31', '2010-12-31', '2010-09-30', '2010-06-30', '2010-03-31', '2009-12-31',
'2009-09-30', '2009-06-30', '2009-03-31', '2008-12-31', '2008-09-30', '2008-06-30',
'2008-03-31', '2007-12-31', '2007-09-30', '2007-06-30', '2007-03-31', '2006-12-31',
'2006-09-30', '2006-06-30', '2006-03-31', '2005-12-31', '2005-09-30', '2005-06-30',
'2005-03-31', '2004-12-31', '2004-09-30', '2004-06-30', '2004-03-31', '2003-12-31',
'2003-09-30', '2003-06-30', '2003-03-31', '2002-12-31', '2002-09-30', '2002-06-30',
'2002-03-31', '2001-12-31', '2001-09-30', '2001-06-30', '2001-03-31', '2000-12-31',
'2000-06-30', '1999-12-31', '1999-06-30', '1998-12-31', '1998-06-30', '1997-12-31',
'1997-06-30', '1996-12-31', '1996-06-30', '1995-12-31', '1995-06-30', '1994-12-31',
'1994-06-30', '1993-12-31', '1993-06-30', '1992-12-31', '1991-12-31', '1990-12-31',
'1989-12-31']
result = fundamental.get_finance_factor(session=session, provider=Provider.EASTMONEY, return_type='domain',
codes=['000001'], end_timestamp='2018-09-30',
order=FinanceFactor.timestamp.desc())
assert len(correct_timestamps) == len(result)
timestamps = [to_time_str(item.timestamp) for item in result]
assert set(correct_timestamps) == set(timestamps)
latest: FinanceFactor = result[0]
assert latest.basic_eps == 1.14
assert latest.deducted_eps == 1.13
assert latest.diluted_eps == 1.14
assert latest.bps == 12.538
assert latest.capital_reserve_ps == 3.2886
assert latest.undistributed_profit_ps == 5.3566
assert latest.op_cash_flow_ps == -0.6587
assert latest.total_op_income == 86660000000
assert latest.net_profit == 20460000000
ma_selector.run()
finance_selector = FundamentalSelector(security_type=security_type, exchanges=exchanges, codes=codes,
start_timestamp=start_timestamp, end_timestamp=end_timestamp)
finance_selector.run()
self.selectors.append(ma_selector)
self.selectors.append(finance_selector)
print(ma_selector.get_df())
print(finance_selector.get_df())
if __name__ == '__main__':
FoolTrader(start_timestamp='2019-01-01',
end_timestamp='2019-05-01', provider=Provider.NETEASE).run()
def request(self, url=None, method='get', param=None, path_fields=None):
security_item = param['security_item']
start_timestamp = param['start_timestamp']
# 不复权
df = get_price(to_jq_security_id(security_item), start_date=to_time_str(start_timestamp),
end_date=now_time_str(),
frequency='daily',
fields=['open', 'close', 'low', 'high', 'volume', 'money'],
skip_paused=True, fq=None)
df.index.name = 'timestamp'
df.reset_index(inplace=True)
df['name'] = security_item.name
df.rename(columns={'money': 'turnover'}, inplace=True)
df['timestamp'] = pd.to_datetime(df['timestamp'])
df['provider'] = Provider.JOINQUANT.value
df['level'] = param['level']
return df.to_dict(orient='records')