-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathkhRisk.py
More file actions
51 lines (39 loc) · 1.31 KB
/
khRisk.py
File metadata and controls
51 lines (39 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# coding: utf-8
from typing import Dict
class KhRiskManager:
"""风险管理类"""
def __init__(self, config):
self.config = config
# 风控参数
self.position_limit = config.position_limit # 持仓限制
self.order_limit = config.order_limit # 委托限制
self.loss_limit = config.loss_limit # 止损限制
def check_risk(self, data: Dict) -> bool:
"""风控检查
Args:
data: 行情数据
Returns:
bool: 是否通过风控
"""
# 检查持仓限制
if not self._check_position():
return False
# 检查委托限制
if not self._check_order():
return False
# 检查止损限制
if not self._check_loss(data):
return False
return True
def _check_position(self) -> bool:
"""检查持仓限制"""
# 实现持仓检查逻辑
return True
def _check_order(self) -> bool:
"""检查委托限制"""
# 实现委托检查逻辑
return True
def _check_loss(self, data: Dict) -> bool:
"""检查止损限制"""
# 实现止损检查逻辑
return True