Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
stockPriceTack
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘长帅
stockPriceTack
Commits
38646681
Commit
38646681
authored
Jun 02, 2022
by
liucx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 只能新4个字段
parent
1cb1a151
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
11 deletions
+37
-11
AssetStockPositionService.java
...ket/service/business/asset/AssetStockPositionService.java
+1
-0
AssetStockPositionServiceImpl.java
...ce/impl/business/asset/AssetStockPositionServiceImpl.java
+26
-0
AssetStockPriceTask.java
...ech/telmarket/task/followAccount/AssetStockPriceTask.java
+10
-11
No files found.
src/main/java/com/zfxftech/telmarket/service/business/asset/AssetStockPositionService.java
View file @
38646681
...
...
@@ -129,6 +129,7 @@ public interface AssetStockPositionService {
AssetMarketDetailsVO
createMarketDetailsVO
(
MemberBase
memberBase
,
List
<
AssetStockPosition
>
stockPositions
,
BigDecimal
funding
,
AssetAccountProductRelation
accountProductRelation
,
Long
marketId
);
AssetMarketDetailsVO
createMarketDetailsVOTask
(
List
<
AssetStockPosition
>
stockPositions
,
BigDecimal
funding
,
AssetAccountProductRelation
accountProductRelation
);
AssetStockVO
createStockVO
(
AssetStockPosition
stockPosition
,
Map
<
String
,
Quote
>
codeAndQuoteMapping
);
...
...
src/main/java/com/zfxftech/telmarket/service/impl/business/asset/AssetStockPositionServiceImpl.java
View file @
38646681
...
...
@@ -1362,6 +1362,32 @@ public class AssetStockPositionServiceImpl extends ServiceImpl<AssetStockPositio
return
marketDetailsVO
;
}
@Override
public
AssetMarketDetailsVO
createMarketDetailsVOTask
(
List
<
AssetStockPosition
>
stockPositions
,
BigDecimal
funding
,
AssetAccountProductRelation
accountProductRelation
)
{
AssetMarketDetailsVO
marketDetailsVO
=
new
AssetMarketDetailsVO
();
List
<
String
>
codes
=
stockPositions
.
stream
().
map
(
AssetStockPosition:
:
getCode
).
collect
(
Collectors
.
toList
());
//批量获取股票当前价格
Map
<
String
,
Quote
>
codeAndPriceMapping
=
stockCodeService
.
batchQueryStockPrice
(
codes
);
//计算股票总市值(当前)
BigDecimal
stocksTotalPrice
=
assetFinanceCalculateService
.
calculateTotalAssets
(
stockPositions
,
codeAndPriceMapping
);
//计算总值
BigDecimal
totalPrice
=
BigDecimalUtil
.
add
(
funding
,
stocksTotalPrice
);
//计算仓位
BigDecimal
position
=
BigDecimalUtil
.
div
(
stocksTotalPrice
,
totalPrice
);
//盈亏比例
BigDecimal
totalProfitRate
=
assetFinanceCalculateService
.
calculateProfitRate
(
totalPrice
,
accountProductRelation
.
getInitialFunding
());
//总盈亏(股票当前市值和成本总值的差值)
BigDecimal
totalProfit
=
assetFinanceCalculateService
.
calculateProfit
(
totalPrice
,
accountProductRelation
.
getInitialFunding
());
marketDetailsVO
.
setPosition
(
position
.
toPlainString
());
marketDetailsVO
.
setTotalPrice
(
totalPrice
.
toPlainString
());
marketDetailsVO
.
setTotalProfit
(
totalProfit
.
toPlainString
());
marketDetailsVO
.
setTotalProfitRate
(
totalProfitRate
.
toPlainString
());
return
marketDetailsVO
;
}
@Override
public
List
<
AssetStockPosition
>
getCode
(
Long
id
)
{
LambdaQueryWrapper
<
AssetStockPosition
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
...
...
src/main/java/com/zfxftech/telmarket/task/followAccount/AssetStockPriceTask.java
View file @
38646681
...
...
@@ -148,34 +148,33 @@ public class AssetStockPriceTask implements ApplicationRunner {
String
type
=
SIMULATED
.
getCode
();
OptionalUtil
.
checkNull
(
accountProductRelation
,
"当前用户产品关系不存在"
);
//查询客户信息
Long
customerId
=
accountProductRelation
.
getCustomerId
();
MemberBase
memberBase
=
memberBaseService
.
queryUsMemberBaseById
(
customerId
);
Long
marketId
=
accountProductRelation
.
getSimulatedMarketId
();
OptionalUtil
.
checkNull
(
memberBase
,
"查询用户数据不存在"
);
//查询持仓信息
BigDecimal
funding
=
null
;
//获取可用资金
if
(
REAL
.
getCode
().
equals
(
type
))
{
funding
=
accountProductRelation
.
getRealFunding
()
;
return
;
}
if
(
SIMULATED
.
getCode
().
equals
(
type
))
{
funding
=
accountProductRelation
.
getSimulatedFunding
();
}
AssetAccountProductRelation
productRelation
=
new
AssetAccountProductRelation
();
productRelation
.
setId
(
accountProductRelation
.
getId
());
//获取所有买入过的股票
List
<
AssetStockPosition
>
stockPositions
=
stockPositionService
.
queryStockPositions
(
marketId
);
//汇总数据
AssetMarketDetailsVO
marketDetailsVO
=
stockPositionService
.
createMarketDetailsVO
(
memberBase
,
stockPositions
,
funding
,
accountProductRelation
,
marketId
);
AssetMarketDetailsVO
marketDetailsVO
=
stockPositionService
.
createMarketDetailsVO
Task
(
stockPositions
,
funding
,
accountProductRelation
);
//示范盈亏比例
accountP
roductRelation
.
setSimulatedTotalProfit
(
new
BigDecimal
(
marketDetailsVO
.
getTotalProfitRate
()));
p
roductRelation
.
setSimulatedTotalProfit
(
new
BigDecimal
(
marketDetailsVO
.
getTotalProfitRate
()));
//示范盘总资产
accountP
roductRelation
.
setSimulatedTotalPrice
(
new
BigDecimal
(
marketDetailsVO
.
getTotalPrice
()));
p
roductRelation
.
setSimulatedTotalPrice
(
new
BigDecimal
(
marketDetailsVO
.
getTotalPrice
()));
//示范持仓比
accountP
roductRelation
.
setSimulatedProportion
(
new
BigDecimal
(
marketDetailsVO
.
getPosition
()));
p
roductRelation
.
setSimulatedProportion
(
new
BigDecimal
(
marketDetailsVO
.
getPosition
()));
//示范盘持仓数量
accountP
roductRelation
.
setPositionCount
(
ObjectUtils
.
isEmpty
(
stockPositions
.
size
())
?
0
:
stockPositions
.
size
());
p
roductRelation
.
setPositionCount
(
ObjectUtils
.
isEmpty
(
stockPositions
.
size
())
?
0
:
stockPositions
.
size
());
//示范盘盈亏金额
accountP
roductRelation
.
setProfitAmount
(
new
BigDecimal
(
marketDetailsVO
.
getTotalProfit
()));
accountProductRelationService
.
updateAccountProductRelation
(
accountP
roductRelation
);
p
roductRelation
.
setProfitAmount
(
new
BigDecimal
(
marketDetailsVO
.
getTotalProfit
()));
accountProductRelationService
.
updateAccountProductRelation
(
p
roductRelation
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment