• 量化接口代码能不能用?


    网上有很多量化接口的代码,这些代码到底能不能用?今日我们来解答一下这个问题。

    如果这套量化接口代码是你自己写的,你清楚明白你自己需要的是什么,每一行代码代表什么,那量化接口代码绝对是可以用的,毕竟很多技术好的投资者也都是自己写量化接口的,他们用起来也是得心应手,甚至帮助他们赚到不是钱。

    但相反,你只是在网上看到一组代码,你对编程没太多认识,只是简单了解而已,通过一组代码来制作量化接口,那估计还是不太可能的,下面我们来举个例子。


    # Cumulative strategy returns
    df_mg['cumulative_returns'] = (df_mg.returns+1).cumprod()
     
    # Plot cumulative returns
    plt.figure(figsize=(10,5))
    plt.plot(df_mg.cumulative_returns)
    plt.grid()
     
    # Define the label for the title of the figure
    plt.title('Cumulative Returns for Martingale strategy', fontsize=16)
     
    # Define the labels for x-axis and y-axis
    plt.xlabel('Date', fontsize=14)
    plt.ylabel('Cumulative Returns', fontsize=14)
     
    # Define the tick size for x-axis and y-axis
    plt.xticks(fontsize=12)
    plt.yticks(fontsize=12)
     
    plt.show()


    # Intialise 'quantity' column 
    df_anti_mg['quantity'] = 0
     
    # Start with $10,000 cash long position
    cash = 10000
    df_anti_mg['signal'].iloc[0] = 1
     
    # Strategy to double the trade volume or quantity on losing trades
    for i in range(df_anti_mg.shape[0]):
      if i == 0:
        df_anti_mg['quantity'].iloc[0] = 1
      else:
        if df_anti_mg['signal'].iloc[i] == 1:
          df_anti_mg['quantity'].iloc[i] = df_anti_mg['quantity'].iloc[i-1]*2
        if df_anti_mg['signal'].iloc[i] == -1:
          df_anti_mg['quantity'].iloc[i] = df_anti_mg['quantity'].iloc[i-1]/2
        if df_anti_mg['signal'].iloc[i] == 0:
          df_anti_mg['quantity'].iloc[i] = df_anti_mg['quantity'].iloc[i-1]
     
    df_anti_mg.head()


    估计大家看完都还是云里雾里的,因为大家根本不知道这代码具体代表什么,你可能会说,那是因为上面的解释都是用英文写的,但小编想说,即使用的是中文,大家也用不了,因为这里面根本没给到dll动态库,而量化接口的关键就在这里,没有动态化,再多的代码也没什么用。

  • 相关阅读:
    Vector容器(黑马程序员)
    肠道微生物如何影响骨骼发育和代谢
    电商(淘宝1688京东拼多多等)API接口服务:提升商业效率和用户体验的关键
    汇编-EQU伪指令(数值替换)
    Redis常用命令
    51单片机可调幅度频率波形信号发生器( proteus仿真+程序+原理图+报告+讲解视频)
    ts+axios 定义接口返回值的类型
    Leetcode——1636. 按照频率将数组升序排序
    学习笔记-Secure-Win
    实例Python对比两个word文档并找出不同
  • 原文地址:https://blog.csdn.net/qq1841085904/article/details/126484997