0bps

Strategy vault / Other

Altcoin Index 20180222 Base Point 1000

Covers the price index of altcoins to BTC, with the base point of 1000 as of 2018.02.22. Newly added altcoins will be listed.

PythonOther
Author
小草
Complexity
Starter · 45 lines
Parameters
0

Covers the price index of altcoins to BTC, with the base point of 1000 as of 2018.02.22. Newly added altcoins will be listed.

Source Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-coding
import time
import urllib2
import json
import pickle
            
def updateTicker():
    global index,initPrice
    ticker = json.loads(urllib2.urlopen('https://api.binance.com/api/v3/ticker/price',timeout=10).read())
    change = []
    for t in ticker:
        if t['symbol'][-3:] == 'BTC':
            if t['symbol'][:-3] in initPrice.keys():
                change.append(float(t['price'])/initPrice[t['symbol'][:-3]])
            else:
                initPrice[t['symbol'][:-3]] = float(t['price'])
                f=open('price.pkl','w')
                pickle.dump(initPrice,f,0)
                f.close()
                Log(t['symbol'][:-3],' added')
    if len(change)>0:
        index = 1000*sum(change)/len(change)
    


initPrice = {}
price = {}
index = 1000
try:
    f=open('price.pkl','r')  
    initPrice=pickle.load(f)  
    f.close()
except:
    initPrice = {}
Log('Total altcoins included:', len(initPrice))
def main():
    while True:
        try:
            updateTicker()
            LogProfit(round(index,4))
        except Exception as e:
            pass
        Sleep(3600000)

Published by 小草 on the FMZ strategy square · last modified 2019-07-03. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Altcoin-Index-20180222-Base-Point-1000.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open