-
Notifications
You must be signed in to change notification settings - Fork 5
/
feed-script-config.py
168 lines (155 loc) · 7.61 KB
/
feed-script-config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/env python3
################################################################################
##
## D E F A U L T C O N F I G U R A T I O N
##
## This configuration represents a working example. Prices published are very
## close to what they "should be". However, every witness has to judge on his
## own as to whether these settings fit his needs.
##
################################################################################
import subprocess
import os
import feedsources
core_symbol = "BTS"
feedsources.core_symbol = core_symbol
################################################################################
## RPC-client connection information (required)
################################################################################
host = "localhost" # machine that runs a cli-wallet with -H parameter
port = 8092 # RPC port, e.g.`-H 127.0.0.1:8092`
user = "" # API user (optional)
passwd = "" # API user passphrase (optional)
unlock = "" # password to unlock the wallet if the cli-wallet is locked
################################################################################
## Script runtime parameters
################################################################################
ask_confirmation = False # if true, a manual confirmation is required
################################################################################
## Witness Feed Publish Parameters
################################################################################
producer_name = "fakeusd-feed-producer"
################################################################################
## Publishing Criteria
################################################################################
#
# Publish price if any of these are valid:
#
# 1.) price feed is older than maxAgeFeedInSeconds
# 2.) price has moved from my last published price by more than change_min
#
# Do NOT publish if
#
# * Price has moved more than 'change_max'
# AND
# * Manual confirmation is 'false'
#
# A feed becomes invalid if it is older than 24h. Hence, it should be force
# published once a day (e.g. every 12h) Note that the script should be run more
# frequently and publishes only those prices that fit the publishing criteria
maxAgeFeedInSeconds = 12 * 60 * 60 # max age of 12h
change_min = 0.5 # Percentage of price change to force an update
change_max = 5.0 # Percentage of price change to cause a warning
################################################################################
## Asset specific Settings
################################################################################
_all_assets = ["SILVER", "GOLD", "CNY", "EUR", "USD"]
_bases = ["CNY", "USD", "BTC", "EUR"]
asset_config = {
"default" : { ## DEFAULT BEHAVIOR
#
# how to derive a single price from several sources
# Choose from: "median", "mean", or "weighted" (by volume)
"metric" : "weighted",
#
# Select sources for this particular asset. Each source
# has its own fetch() method and collects several markets
# any market of an exchanges is considered but only the
# current asset's price is derived
#
# Choose from: - "*": all,
# - loaded exchanges (see below)
"sources" : [
## Required Exchanges for FIAT
"btcavg", # To get from BTC into USD/CNY/EUR
#"yahoo", # To get from USD/CNY/EUR into other FIAT currencies
## BTC/BTS exchanges (include BTC/* if available)
"poloniex",
#"ccedk",
#"bittrex",
#"btc38",
#"yunbi",
## BTC/* exchanges
#"okcoin", # no trading-fees
#"btcchina", # no trading-fees
#"huobi", # no trading-fees
],
# Core exchange factor for paying transaction fees in
# non-BTS assets. This is a factor: 0.95 = 95%
"core_exchange_factor" : 0.95,
# Call when collateral only pays off 175% the debt.
# This is denoted as: 1750 = 175% = 1.75
"maintenance_collateral_ratio" : 1750,
# Stop calling when collateral only pays off 110% of the debt
# This is denoted as: 1100 = 110% = 1.10
"maximum_short_squeeze_ratio" : 1001,
},
}
## Other assets that are derived or something else.
## Currently available:
##
## "sameas" : x ## uses the same asset price as a MPA above
##
##
## Note:
## The usual asset specific parameters have to be set in "asset_config",
## otherwise they will be ignored!
secondary_mpas = {
"PEG.FAKEUSD" : {
"sameas" : "USD"
},
}
################################################################################
## Exchanges and settings
##
## scaleVolumeBy: a multiplicative factor for the volume
## allowFailure: bool variable that will (if not set or set to False) exit the
## script on error
################################################################################
feedSources = {}
#feedSources["yahoo"] = feedsources.Yahoo()
feedSources["btcavg"] = feedsources.BitcoinAverage()
#
feedSources["poloniex"] = feedsources.Poloniex(allowFailure=True)
#feedSources["ccedk"] = feedsources.Ccedk(allowFailure=True)
#feedSources["bittrex"] = feedsources.Bittrex(allowFailure=True)
#feedSources["yunbi"] = feedsources.Yunbi(allowFailure=True)
#feedSources["btc38"] = feedsources.Btc38(allowFailure=True)
#
#feedSources["btcchina"] = feedsources.BtcChina(allowFailure=True)
#feedSources["okcoin"] = feedsources.Okcoin(allowFailure=True)
#feedSources["huobi"] = feedsources.Huobi(allowFailure=True)
#
#feedSources["btcid"] = feedsources.BitcoinIndonesia(allowFailure=True)
#feedSources["bter"] = feedsources.Bter(allowFailure=True)
################################################################################
# Blame mode allows to verify old published prices
# All data requires is stored in the blame/ directoy. Filename is the head block
# number at the time of script execution.
# To recover a price (will not publish) simply set blame to the block number of
# an existing(!) file.
#
# Default: "latest" # Will fetch prices from exchanges and publish it
################################################################################
blame = "latest"
#blame = "1428190"
################################################################################
# Git revision for storage in blame files
# (do not touch this line)
################################################################################
try :
configPath = os.path.dirname(__file__)
gittag = subprocess.check_output(["git", "-C", configPath, "rev-parse", "HEAD"]).decode("ascii").strip("\n")
except :
pass
# coding=utf8 sw=4 expandtab ft=python