python - Cython syntax for dataframe of dates and dictionaries as inputs to the function
问题描述
I am a python user with moderate experience in writing codes and recently I noticed that I can use cython for sequential models like backtesting codes to make it faster. The problem is that imagine I have a function called backtesting with arguments given below:
def backtest(daterange,price_dict,tickers_dict,):
return result
where daterange is a dataframe of dates.
price_dict is a dictionary of daily prices based on company ticker and date given (so it is a dictionary with 2 levels of keys --> price_dict[ticker][date] -> price
tickers_dict is a dictionary of picked tickers based on dates so it is like tickers_dict[date] --> gives a list of tickers
result is a dataframe with daily equity values of the portfolio calculated inside the function.
How can I define all of these in cython using cdef or cpdef? what is the syntax for it? It has driven me crazy t o find the right syntax! thanks
解决方案
推荐阅读
- python - 添加来自两个文本文件的数据
- android - 如何让我的 android 应用程序连接到实时 firebase 数据库以在实时数据库中创建更新 toast?
- go - os.FileInfo 中的 Sys() 是什么?
- sql - 寻找更有效的'for循环'sql
- django - “detail”:“JSON 解析错误 - 预期值:第 1 行第 1 列(字符 0)”django rest 框架
- ios - 如何快速将扫描保存到用户的照片库
- php - 有没有办法在php的不同位置包含相同的文件
- flutter - Flutter 中更新 state 对象后 hookwidget 不重新渲染
- python - 如何从函数返回布尔值?
- node.js - 我在 discord.js 中的静音命令不起作用