Skip to content

Commit

Permalink
Fixed keys example, added more robust limit test for homogenity.
Browse files Browse the repository at this point in the history
  • Loading branch information
EmersonDove committed Jul 20, 2021
1 parent d0f1d38 commit da62e25
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Blankly/exchanges/interfaces/Binance/Binance_Interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ def get_market_limits(self, product_id):
max_quantity = float(filters[2]["maxQty"])
base_increment = float(filters[2]["stepSize"])

min_market_notational = float(filters[3]['minNotational'])
min_market_notational = float(filters[3]['minNotional'])
max_market_notational = 92233720368.547752 # For some reason equal to the first *11 digits* of 2^63 then
# it gets weird past the decimal

Expand Down
4 changes: 2 additions & 2 deletions Examples/keys_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"alpaca": {
"another cool portfolio": {
"API_KEY": "**************************************************************",
"API_SECRET": "*************************************************************"
"API_KEY": "********************",
"API_SECRET": "****************************************"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def test_get_account(alpaca_mock_interface) -> None:
assert return_val['cash'] == float(1500)
# assert "exchange_specific" in return_val[0]


def test_get_fees(alpaca_mock_interface) -> None:
fee_response = alpaca_mock_interface.get_fees()
assert fee_response['maker_fee_rate'] == 0
assert fee_response['taker_fee_rate'] == 0
assert fee_response['taker_fee_rate'] == 0
24 changes: 24 additions & 0 deletions tests/exchanges/test_interface_homogeneity.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ def check_limit_order(self, limit_order: LimitOrder, expected_side: str, size, p
self.assertEqual(limit_order.get_product_id(), product_id)

def test_limit_order(self):
"""
This function tests a few components of market orders:
- Opening market orders
- Monitoring market orders using the order status function
- Comparing with open orders
- Canceling orders
"""
binance_limits = self.Binance_Interface.get_market_limits('BTC-USDT')

binance_buy = self.Binance_Interface.limit_order('BTC-USDT', 'buy', int(binance_limits['min_price']+30), .01)
Expand All @@ -167,6 +174,23 @@ def test_limit_order(self):

cancels = []

coinbase_open = self.Coinbase_Pro_Interface.get_open_orders('BTC-USD')
for i in [coinbase_buy, coinbase_sell]:
found = False
for j in coinbase_open:
if i.get_id() == j['id']:
found = True
self.assertTrue(found)

binance_open = self.Binance_Interface.get_open_orders('BTC-USDT')
for i in [binance_buy, binance_sell]:
found = False
for j in binance_open:
if i.get_id() == j['id']:
found = True
compare_dictionaries(i.get_response(), j)
self.assertTrue(found)

for i in limits:
responses.append(i.get_response())
status.append(i.get_status(full=True))
Expand Down

0 comments on commit da62e25

Please sign in to comment.