Skip to content

Commit 4b4be9d

Browse files
authored
1.106.0
2 parents d0392a0 + 7bb570b commit 4b4be9d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2120
-750
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,11 @@ The following order types are available (when possible on an exchange);
219219
- `Market`
220220
- `Limit`
221221
- `StopMarket`
222+
- `StopLimit`
222223

223-
More will be added in due course including `StopLimit`, `MarketIfTouched`,
224-
`LimitIfTouched` and icebergs. Users are invited to open discussion issues to
225-
request specific order types or features.
224+
More will be added in due course including `MarketIfTouched`, `LimitIfTouched`
225+
and icebergs. Users are invited to open discussion issues to request specific
226+
order types or features.
226227

227228
## Integrations
228229

docs/source/api_reference/model.rst

+9
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ Stop-Market Order
112112
:members:
113113
:member-order: bysource
114114

115+
Stop-Limit Order
116+
----------------
117+
118+
.. automodule:: nautilus_trader.model.order.stop_limit
119+
:show-inheritance:
120+
:inherited-members:
121+
:members:
122+
:member-order: bysource
123+
115124
Bracket Order
116125
-------------
117126

examples/strategies/ema_cross_cython.pyx

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from decimal import Decimal
1717

18+
from nautilus_trader.data.base cimport Data
1819
from nautilus_trader.core.message cimport Event
1920
from nautilus_trader.indicators.average.ema cimport ExponentialMovingAverage
2021
from nautilus_trader.model.bar cimport Bar
@@ -219,14 +220,14 @@ cdef class EMACross(TradingStrategy):
219220

220221
self.submit_order(order)
221222

222-
cpdef void on_data(self, data) except *:
223+
cpdef void on_data(self, Data data) except *:
223224
"""
224225
Actions to be performed when the strategy is running and receives a data object.
225226
226227
Parameters
227228
----------
228-
data : object
229-
The data object received.
229+
data : Data
230+
The data received.
230231
231232
"""
232233
pass

examples/strategies/ema_cross_stop_entry_trail.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838

3939
class EMACrossStopEntryTrail(TradingStrategy):
4040
"""
41-
A simple moving average cross example strategy with a stop market entry and
41+
A simple moving average cross example strategy with a stop-market entry and
4242
trailing stop.
4343
44-
When the fast EMA crosses the slow EMA then submits a stop market order one
44+
When the fast EMA crosses the slow EMA then submits a stop-market order one
4545
tick above the current bar for BUY, or one tick below the current bar
4646
for SELL.
4747

examples/strategies/ema_cross_trail.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838

3939
class EMACrossWithTrailingStop(TradingStrategy):
4040
"""
41-
A simple moving average cross example strategy with a stop market entry and
41+
A simple moving average cross example strategy with a stop-market entry and
4242
trailing stop.
4343
44-
When the fast EMA crosses the slow EMA then submits a stop market order one
44+
When the fast EMA crosses the slow EMA then submits a stop-market order one
4545
tick above the current bar for BUY, or one tick below the current bar
4646
for SELL.
4747

nautilus_trader/adapters/ccxt/providers.pyx

+9-2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ cdef class CCXTInstrumentProvider(InstrumentProvider):
109109
for k, v in self._client.markets.items():
110110
symbol = Symbol(k, self.venue)
111111
instrument = self._parse_instrument(symbol, v)
112+
if instrument is None:
113+
continue # Something went wrong in parsing
112114

113115
self._instruments[symbol.code] = instrument
114116

@@ -124,9 +126,12 @@ cdef class CCXTInstrumentProvider(InstrumentProvider):
124126
currency_type = self._parse_currency_type(code)
125127
currency = Currency.from_str_c(code)
126128
if currency is None:
129+
precision = values.get("precision")
130+
if precision is None:
131+
continue
127132
currency = Currency(
128133
code=code,
129-
precision=self._get_precision(values["precision"], precision_mode),
134+
precision=self._get_precision(precision, precision_mode),
130135
currency_type=currency_type,
131136
)
132137

@@ -174,7 +179,9 @@ cdef class CCXTInstrumentProvider(InstrumentProvider):
174179
if base_currency is not None:
175180
base_currency = Currency.from_str_c(values["base"])
176181
if base_currency is None:
177-
base_currency = self._currencies[values["base"]]
182+
base_currency = self._currencies.get(values["base"])
183+
if base_currency is None:
184+
return None
178185

179186
quote_currency = Currency.from_str_c(values["quote"])
180187
if quote_currency is None:
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -------------------------------------------------------------------------------------------------
2+
# Copyright (C) 2015-2021 Nautech Systems Pty Ltd. All rights reserved.
3+
# https://nautechsystems.io
4+
#
5+
# Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6+
# You may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# -------------------------------------------------------------------------------------------------
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -------------------------------------------------------------------------------------------------
2+
# Copyright (C) 2015-2021 Nautech Systems Pty Ltd. All rights reserved.
3+
# https://nautechsystems.io
4+
#
5+
# Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6+
# You may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# -------------------------------------------------------------------------------------------------

nautilus_trader/adapters/ib/data.pxd

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -------------------------------------------------------------------------------------------------
2+
# Copyright (C) 2015-2021 Nautech Systems Pty Ltd. All rights reserved.
3+
# https://nautechsystems.io
4+
#
5+
# Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6+
# You may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# -------------------------------------------------------------------------------------------------

nautilus_trader/adapters/ib/data.pyx

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -------------------------------------------------------------------------------------------------
2+
# Copyright (C) 2015-2021 Nautech Systems Pty Ltd. All rights reserved.
3+
# https://nautechsystems.io
4+
#
5+
# Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6+
# You may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# -------------------------------------------------------------------------------------------------
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -------------------------------------------------------------------------------------------------
2+
# Copyright (C) 2015-2021 Nautech Systems Pty Ltd. All rights reserved.
3+
# https://nautechsystems.io
4+
#
5+
# Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6+
# You may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# -------------------------------------------------------------------------------------------------
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -------------------------------------------------------------------------------------------------
2+
# Copyright (C) 2015-2021 Nautech Systems Pty Ltd. All rights reserved.
3+
# https://nautechsystems.io
4+
#
5+
# Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6+
# You may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# -------------------------------------------------------------------------------------------------
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -------------------------------------------------------------------------------------------------
2+
# Copyright (C) 2015-2021 Nautech Systems Pty Ltd. All rights reserved.
3+
# https://nautechsystems.io
4+
#
5+
# Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6+
# You may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# -------------------------------------------------------------------------------------------------
15+
16+
from nautilus_trader.model.c_enums.asset_class cimport AssetClass
17+
from nautilus_trader.model.identifiers cimport Security
18+
from nautilus_trader.model.instrument cimport Future
19+
from nautilus_trader.model.instrument cimport Instrument
20+
21+
22+
cdef class IBInstrumentProvider:
23+
cdef dict _instruments
24+
cdef object _client
25+
cdef str _host
26+
cdef str _port
27+
cdef int _client_id
28+
29+
cdef readonly int count
30+
"""The count of instruments held by the provider.\n\n:returns: `int`"""
31+
32+
cpdef void connect(self)
33+
cpdef Future load_future(self, Security security, AssetClass asset_class=*)
34+
cpdef Instrument get(self, Security security)
35+
cdef inline int _tick_size_to_precision(self, double tick_size) except *
36+
cdef Future _parse_futures_contract(self, Security security, AssetClass asset_class, list details_list)

0 commit comments

Comments
 (0)