Code Monkey home page Code Monkey logo

gmcache's Introduction

gm_cache 掘金API缓存

安装

pip install gmcache

使用

from gm.api import * 改成 from gmcache import * 所有数据查询API加了一层代理,数据API默认优先走缓存(保存7天),其他API还是走掘金API

from gmcache import *  # 回测环境使用缓存API,实时运行的时候再改回去
# from gm.api import *  

set_token("XXXXXX")  # 第一次设置会保存到.gmcache/config.json 下次import 会自动加载token执行set_token 

df = get_instruments(exchanges='SZSE,SHSE',sec_types=1, df=True) # 缓存读取大约花费1-3ms

# 清理所有缓存
clear_cache()

原理说明

数据查询API会根据方法名和参数值生成key,检查缓存里是否已经有数据,没有就会走掘金API,返回值会加入到缓存,下次调用如果参数没变,就会直接走本地缓存 多次回测的情况,取数据API参数如果没变化,能极大加快回测速度

gmcache's People

Contributors

yiliuyan161 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.