Skip to content

Commit

Permalink
Adapt base/quote asset for inverse contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierXIEXIN committed Jun 11, 2020
1 parent 450db13 commit a82a9e0
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 40 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ binance_futures.egg-info/*
*.ipynb

# Mac system
.DS_Store
.DS_Store

# VSCode
.vscode

# Python venv
.venv
.binance_futures
10 changes: 5 additions & 5 deletions binance_d/model/candlestick.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def __init__(self):
self.close = 0.0
self.volume = 0.0
self.closeTime = 0
self.quoteAssetVolume = 0.0
self.baseVolume = 0.0
self.numTrades = 0
self.takerBuyBaseAssetVolume = 0.0
self.takerBuyQuoteAssetVolume = 0.0
self.takerBuyBaseAssetVolume = 0.0
self.ignore = 0.0

@staticmethod
Expand All @@ -25,10 +25,10 @@ def json_parse(json_data):
result.close = val[4]
result.volume = val[5]
result.closeTime = val[6]
result.quoteAssetVolume = val[7]
result.baseVolume = val[7]
result.numTrades = val[8]
result.takerBuyBaseAssetVolume = val[9]
result.takerBuyQuoteAssetVolume = val[10]
result.takerBuyQuoteAssetVolume = val[9]
result.takerBuyBaseAssetVolume = val[10]
result.ignore = val[11]

return result
10 changes: 5 additions & 5 deletions binance_d/model/candlestickevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def __init__(self):
self.volume = 0.0
self.numTrades = 0
self.isClosed = False
self.quoteAssetVolume = 0.0
self.takerBuyBaseAssetVolume = 0.0
self.baseVolume = 0.0
self.takerBuyQuoteAssetVolume = 0.0
self.takerBuyBaseAssetVolume = 0.0
self.ignore = 0.0

@staticmethod
Expand All @@ -35,9 +35,9 @@ def json_parse(json_data):
data_obj.volume = json_data.get_float("v")
data_obj.numTrades = json_data.get_int("n")
data_obj.isClosed = json_data.get_boolean("x")
data_obj.quoteAssetVolume = json_data.get_float("q")
data_obj.takerBuyBaseAssetVolume = json_data.get_float("V")
data_obj.takerBuyQuoteAssetVolume = json_data.get_float("Q")
data_obj.baseVolume = json_data.get_float("q")
data_obj.takerBuyQuoteAssetVolume = json_data.get_float("V")
data_obj.takerBuyBaseAssetVolume = json_data.get_float("Q")
data_obj.ignore = json_data.get_int("B")

return data_obj
Expand Down
10 changes: 5 additions & 5 deletions binance_d/model/continuouscandlestickevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def __init__(self):
self.volume = 0.0
self.numTrades = 0
self.isClosed = False
self.quoteAssetVolume = 0.0
self.takerBuyBaseAssetVolume = 0.0
self.baseVolume = 0.0
self.takerBuyQuoteAssetVolume = 0.0
self.takerBuyBaseAssetVolume = 0.0
self.ignore = 0.0

@staticmethod
Expand All @@ -35,9 +35,9 @@ def json_parse(json_data):
data_obj.volume = json_data.get_float("v")
data_obj.numTrades = json_data.get_int("n")
data_obj.isClosed = json_data.get_boolean("x")
data_obj.quoteAssetVolume = json_data.get_float("q")
data_obj.takerBuyBaseAssetVolume = json_data.get_float("V")
data_obj.takerBuyQuoteAssetVolume = json_data.get_float("Q")
data_obj.baseVolume = json_data.get_float("q")
data_obj.takerBuyQuoteAssetVolume = json_data.get_float("V")
data_obj.takerBuyBaseAssetVolume = json_data.get_float("Q")
data_obj.ignore = json_data.get_int("B")

return data_obj
Expand Down
4 changes: 2 additions & 2 deletions binance_d/model/exchangeinformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def json_parse(json_data):
element.marginAsset = item.get_string("marginAsset")
element.pricePrecision = item.get_int("pricePrecision")
element.quantityPrecision = item.get_int("quantityPrecision")
# element.baseAssetPrecision = item.get_int("baseAssetPrecision")
# element.quotePrecision = item.get_int("quotePrecision")
element.baseAssetPrecision = item.get_int("baseAssetPrecision")
element.quotePrecision = item.get_int("quotePrecision")
element.orderTypes = item.get_object("orderTypes").convert_2_list()
element.timeInForce = item.get_object("timeInForce").convert_2_list()

Expand Down
10 changes: 5 additions & 5 deletions binance_d/model/indexcandlestickevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def __init__(self):
self.volume = 0.0
self.numTrades = 0
self.isClosed = False
self.quoteAssetVolume = 0.0
self.takerBuyBaseAssetVolume = 0.0
self.baseVolume = 0.0
self.takerBuyQuoteAssetVolume = 0.0
self.takerBuyBaseAssetVolume = 0.0
self.ignore = 0.0

@staticmethod
Expand All @@ -36,9 +36,9 @@ def json_parse(json_data):
data_obj.volume = json_data.get_float("v")
data_obj.numTrades = json_data.get_int("n")
data_obj.isClosed = json_data.get_boolean("x")
data_obj.quoteAssetVolume = json_data.get_float("q")
data_obj.takerBuyBaseAssetVolume = json_data.get_float("V")
data_obj.takerBuyQuoteAssetVolume = json_data.get_float("Q")
data_obj.baseVolume = json_data.get_float("q")
data_obj.takerBuyQuoteAssetVolume = json_data.get_float("V")
data_obj.takerBuyBaseAssetVolume = json_data.get_float("Q")
data_obj.ignore = json_data.get_int("B")

return data_obj
Expand Down
10 changes: 5 additions & 5 deletions binance_d/model/markpricecandlestickevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def __init__(self):
self.volume = 0.0
self.numTrades = 0
self.isClosed = False
self.quoteAssetVolume = 0.0
self.takerBuyBaseAssetVolume = 0.0
self.baseVolume = 0.0
self.takerBuyQuoteAssetVolume = 0.0
self.takerBuyBaseAssetVolume = 0.0
self.ignore = 0.0

@staticmethod
Expand All @@ -36,9 +36,9 @@ def json_parse(json_data):
data_obj.volume = json_data.get_float("v")
data_obj.numTrades = json_data.get_int("n")
data_obj.isClosed = json_data.get_boolean("x")
data_obj.quoteAssetVolume = json_data.get_float("q")
data_obj.takerBuyBaseAssetVolume = json_data.get_float("V")
data_obj.takerBuyQuoteAssetVolume = json_data.get_float("Q")
data_obj.baseVolume = json_data.get_float("q")
data_obj.takerBuyQuoteAssetVolume = json_data.get_float("V")
data_obj.takerBuyBaseAssetVolume = json_data.get_float("Q")
data_obj.ignore = json_data.get_int("B")

return data_obj
Expand Down
4 changes: 2 additions & 2 deletions binance_d/model/mytrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self):
self.orderId = None
self.price = 0.0
self.qty = 0.0
self.quoteQty = 0.0
self.baseQty = 0.0
self.realizedPnl = 0.0
self.side = ""
self.symbol = ""
Expand All @@ -28,7 +28,7 @@ def json_parse(json_data):
result.orderId = json_data.get_int("orderId")
result.price = json_data.get_float("price")
result.qty = json_data.get_float("qty")
result.quoteQty = json_data.get_float("quoteQty")
result.baseQty = json_data.get_float("baseQty")
result.realizedPnl = json_data.get_float("realizedPnl")
result.side = json_data.get_string("side")
result.symbol = json_data.get_string("symbol")
Expand Down
6 changes: 3 additions & 3 deletions binance_d/model/symbolminitickerevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def __init__(self):
self.close = 0.0
self.high = 0.0
self.low = 0.0
self.totalTradedBaseAssetVolume = 0.0
self.totalTradedQuoteAssetVolume = 0.0
self.totalTradedBaseAssetVolume = 0.0

@staticmethod
def json_parse(json_wrapper):
Expand All @@ -21,6 +21,6 @@ def json_parse(json_wrapper):
result.close = json_wrapper.get_float("c")
result.high = json_wrapper.get_float("h")
result.low = json_wrapper.get_float("l")
result.totalTradedBaseAssetVolume = json_wrapper.get_float("v")
result.totalTradedQuoteAssetVolume = json_wrapper.get_float("q")
result.totalTradedQuoteAssetVolume = json_wrapper.get_float("v")
result.totalTradedBaseAssetVolume = json_wrapper.get_float("q")
return result
6 changes: 3 additions & 3 deletions binance_d/model/symboltickerevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def __init__(self):
self.open = 0.0
self.high = 0.0
self.low = 0.0
self.totalTradedBaseAssetVolume = 0.0
self.totalTradedQuoteAssetVolume = 0.0
self.totalTradedBaseAssetVolume = 0.0
self.openTime = 0
self.closeTime = 0
self.firstId = None
Expand All @@ -34,8 +34,8 @@ def json_parse(json_wrapper):
ticker_event.open = json_wrapper.get_float("o")
ticker_event.high = json_wrapper.get_float("h")
ticker_event.low = json_wrapper.get_float("l")
ticker_event.totalTradedBaseAssetVolume = json_wrapper.get_float("v")
ticker_event.totalTradedQuoteAssetVolume = json_wrapper.get_float("q")
ticker_event.totalTradedQuoteAssetVolume = json_wrapper.get_float("v")
ticker_event.totalTradedBaseAssetVolume = json_wrapper.get_float("q")
ticker_event.openTime = json_wrapper.get_int("O")
ticker_event.closeTime = json_wrapper.get_int("C")
ticker_event.firstId = json_wrapper.get_int("F")
Expand Down
4 changes: 2 additions & 2 deletions binance_d/model/tickerpricechangestatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self):
self.highPrice = 0.0
self.lowPrice = 0.0
self.volume = 0.0
self.quoteVolume = 0.0
self.baseVolume = 0.0
self.openTime = 0
self.closeTime = 0
self.firstId = None
Expand All @@ -33,7 +33,7 @@ def json_parse(json_data):
result.highPrice = json_data.get_float("highPrice")
result.lowPrice = json_data.get_float("lowPrice")
result.volume = json_data.get_float("volume")
result.quoteVolume = json_data.get_float("quoteVolume")
result.baseVolume = json_data.get_float("baseVolume")
result.openTime = json_data.get_int("openTime")
result.closeTime = json_data.get_int("closeTime")
result.firstId = json_data.get_int("firstId")
Expand Down
4 changes: 2 additions & 2 deletions binance_d/model/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def __init__(self):
self.id = None
self.price = 0.0
self.qty = 0.0
self.quoteQty = 0.0
self.baseQty = 0.0
self.time = 0
self.isBuyerMaker = False

Expand All @@ -14,7 +14,7 @@ def json_parse(json_data):
result.id = json_data.get_int("id")
result.price = json_data.get_float("price")
result.qty = json_data.get_float("qty")
result.quoteQty = json_data.get_float("quoteQty")
result.baseQty = json_data.get_float("baseQty")
result.time = json_data.get_int("time")
result.isBuyerMaker = json_data.get_boolean("isBuyerMaker")

Expand Down
11 changes: 11 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
APScheduler==3.6.3
binance-futures==1.1.0
certifi==2020.4.5.2
chardet==3.0.4
idna==2.9
pytz==2020.1
requests==2.23.0
six==1.15.0
tzlocal==2.1
urllib3==1.25.9
websocket-client==0.57.0

0 comments on commit a82a9e0

Please sign in to comment.