Skip to content

Commit

Permalink
add min price
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangxn committed Sep 26, 2019
1 parent 476c381 commit 5cad9e9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
17 changes: 9 additions & 8 deletions btsprice/feedapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,17 @@ def init_chain_info(self):

def encode_feed(self, asset, price, bts_price, custom={}):
feed_info = self.feed_temple.copy()
feed_info["settlement_price"]["base"]["asset_id"] = \
self.asset_info[asset]["id"]
feed_info["core_exchange_rate"]["base"]["asset_id"] = \
self.asset_info[asset]["id"]
feed_info["settlement_price"]["base"]["asset_id"] = self.asset_info[asset]["id"]
feed_info["core_exchange_rate"]["base"]["asset_id"] = self.asset_info[asset]["id"]
if "maintenance_collateral_ratio" in custom:
feed_info["maintenance_collateral_ratio"] = \
custom["maintenance_collateral_ratio"]
feed_info["maintenance_collateral_ratio"] = custom["maintenance_collateral_ratio"]
if "maximum_short_squeeze_ratio" in custom:
feed_info["maximum_short_squeeze_ratio"] = \
custom["maximum_short_squeeze_ratio"]
feed_info["maximum_short_squeeze_ratio"] = custom["maximum_short_squeeze_ratio"]

if 'min_price' in custom:
pmin = float(custom["min_price"])
if price < pmin:
price = pmin

bts_quote_precision = self.asset_info[self.quote_asset]["precision"]
if "quote_asset" in custom:
Expand Down
6 changes: 2 additions & 4 deletions btsprice/feedprice.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,13 @@ def check_publish(self, asset_list, my_feeds, real_price):
if asset not in my_feeds:
need_publish[asset] = real_price[asset]
continue
change = fabs(my_feeds[asset]["price"] - real_price[asset]) * \
100.0 / my_feeds[asset]["price"]
change = fabs(my_feeds[asset]["price"] - real_price[asset]) * 100.0 / my_feeds[asset]["price"]
if change >= self.config["price_limit"]["change_max"]:
continue
if asset not in my_feeds:
need_publish[asset] = real_price[asset]
continue
if time.time() - my_feeds[asset]["timestamp"] > \
self.feedapi.asset_info[asset]["feed_lifetime_sec"] - 600:
if time.time() - my_feeds[asset]["timestamp"] > self.feedapi.asset_info[asset]["feed_lifetime_sec"] - 600:
need_publish[asset] = real_price[asset]
continue
if change > self.config["price_limit"]["change_min"]:
Expand Down
2 changes: 1 addition & 1 deletion btsprice/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package = 'btsprice'
project = "btsprice"
project_no_spaces = project.replace(' ', '')
version = '0.3.1'
version = '0.3.2'
description = 'get price for BitShares'
authors = ['Alt','Necklace']
authors_string = ', '.join(authors)
Expand Down
3 changes: 2 additions & 1 deletion config.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"maintenance_collateral_ratio": 1750,
"maximum_short_squeeze_ratio": 1100,
"quote_asset": "BTS",
"quote_asset_id": "1.3.0"
"quote_asset_id": "1.3.0",
"min_price":0
},
"GCNY": {
"core_exchange_factor": 1.20,
Expand Down

0 comments on commit 5cad9e9

Please sign in to comment.