Skip to content

Commit 712f043

Browse files
committed
add some improvements
1 parent 7001e59 commit 712f043

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

mqpy/book.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ def release(self) -> bool:
5353
Returns:
5454
bool: True if successful, False otherwise.
5555
"""
56-
return Mt5.market_book_release(self.symbol)
56+
result = Mt5.market_book_release(self.symbol)
57+
return False if result is None else result

tests/test_book.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,45 +91,35 @@ def test_full_workflow(symbol):
9191

9292
def test_multiple_symbols():
9393
"""Test using Book with multiple symbols simultaneously."""
94-
# Get available symbols
9594
symbols = Mt5.symbols_get()
9695
if len(symbols) < 2:
9796
pytest.skip("Need at least 2 symbols for this test")
9897

99-
# Select two different symbols
10098
symbol1 = symbols[0].name
10199
symbol2 = symbols[1].name
102100

103-
# Create books for both symbols
104101
book1 = Book(symbol1)
105102
book2 = Book(symbol2)
106103

107-
# Wait for market books to populate
108104
time.sleep(1)
109105

110-
# Get market data for both symbols
111106
data1 = book1.get()
112107
data2 = book2.get()
113108

114-
# Verify both returned data
115109
assert data1 is not None
116110
assert data2 is not None
117111

118-
# Clean up
119112
book1.release()
120113
book2.release()
121114

122115
def test_unavailable_symbol(caplog):
123116
"""Test behavior with an unavailable symbol."""
124117
caplog.set_level(logging.ERROR)
125118

126-
# Use an invalid symbol name
127119
invalid_symbol = "INVALID_SYMBOL_THAT_DOESNT_EXIST"
128120

129-
# Create a book with invalid symbol
130121
book = Book(invalid_symbol)
131122

132-
# Check that an error was logged
133123
assert "Error adding INVALID_SYMBOL_THAT_DOESNT_EXIST to the market book" in caplog.text
134124

135125
release_result = book.release()

0 commit comments

Comments
 (0)