1 Star 3 Fork 1

qhy_zoe/事件驱动量化交易框架

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test.py 3.00 KB
一键复制 编辑 原始数据 按行查看 历史
qhy_zoe 提交于 2024-11-25 11:51 . add new func
from config import Config
from quant_server_new.event_bus import EventBus
from utils.log_util import get_logger
from quant_server_new.data_feed import BacktestBarFeed
import pandas as pd
import numpy as np
import time
logger = get_logger()
# 手动创建一个DF数据
def try_pd():
# df1 = pd.DataFrame(["a", "b", "c", "d"])
# print(df1)
# # 创建二维的np数组,可以直接用np的数组的方法和属性
# df2 = pd.DataFrame([["a", "A"], ["b", "B"], ["c", "C"], ["d", "D"]])
# print(df2, df2.shape)
arr1 = np.array([["a", "A"], ["b", "B"], ["c", "C"], ["d", "D"]])
df3 = pd.DataFrame(arr1, columns=["lowercase", "uppercase"], index=["一", "二", "三", "四"])
df4 = pd.DataFrame(df3, columns=["lowercase"])
print(df4.index, df4.columns, df4.values)
def read_column(file_path, column, start=None, end=None) -> pd.Series:
read_csv = pd.read_csv(file_path)
prices = read_csv[column][-50:]
if start and not end:
return prices[start:]
if end and not start:
return prices[0:end]
if start and end:
return prices[start:end]
def try_func():
pass
def init_system():
logger.info(Config.PARENT_DIR)
file = Config.DATA_DIR+"sh000001.csv"
logger.info(file)
test_event_bus = EventBus(sample_freq=1)
bt_bar_feed = BacktestBarFeed(test_event_bus,file)
bt_bar_feed.start()
class Cat:
def __int__(self):
# self.name = name
print("cat init get called")
def __new__(cls,value):
obj = object.__new__(cls)
obj.age = value
print("cat new get called")
return obj
def test():
print(float("inf"))
class Trie:
def __init__(self):
self.children = {}
def add_word(self,word):
cur = self
for l in word:
if l not in cur.children:
cur.children[l] = Trie()
cur = cur.children[l]
def self_print(self):
for l, Tries in self.children.items():
print(l)
Tries.self_print()
from functools import cache
class Solution:
def minValidStrings(self, words, target: str) -> int:
inf = float("inf")
root = Trie()
n=len(target)
for i, word in enumerate(words):
cur = root
for c in word:
if c not in cur.children:
cur.children[c] = Trie()
cur = cur.children[c]
@cache
def dfs(i):
if i == n:
return 0
node=root
res=inf
for j in range(i,n):
if target[j] not in node.children:
break
node=node.children[target[j]]
print(target[j+1:],dfs(j+1))
res=min(res,dfs(j+1)+1)
return res
self.ans=dfs(0)
return self.ans if self.ans != inf else -1
if __name__ == "__main__":
words =["abc","aaaaa","bcdef"]
target = 'abc'
print(Solution().minValidStrings(words,target))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/diane_lee/event_driven_trading_sys.git
git@gitee.com:diane_lee/event_driven_trading_sys.git
diane_lee
event_driven_trading_sys
事件驱动量化交易框架
main

搜索帮助