all
¤
Import everything in one. Import some unnecessary but convenient for everyone
BackTestAccount
¤
BackTestAccount(
risk: float = 0.02,
balance: float = 10000,
commission: float = 0.2,
margin: float = 1,
leverage: float = 1,
**kwargs
)
Bases: Account
Parameters:
-
risk
(float
, default:0.02
) –description. Defaults to 0.02.
-
balance
(float
, default:10000
) –description. Defaults to 10_000.
-
commission
(float
, default:0.2
) –Commission fee is percent of size. Defaults to 0.2.
-
margin
(float
, default:1
) –description. Defaults to 1.
-
leverage
(float
, default:1
) –description. Defaults to 1.
-
**kwargs
(dict
, default:{}
) –Mirror of lettrade.account.Account().
Source code in lettrade/exchange/backtest/account.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
next
¤
next()
Next account
Source code in lettrade/account/account.py
73 74 |
|
next_next
¤
next_next()
Call after strategy.next()
Source code in lettrade/account/account.py
76 77 78 |
|
risk
¤
Risk calculation
Source code in lettrade/account/account.py
87 88 89 90 91 |
|
start
¤
start()
Start account
Source code in lettrade/account/account.py
70 71 |
|
stop
¤
stop()
Stop account
Source code in lettrade/account/account.py
80 81 82 83 84 85 |
|
BackTestCommander
¤
Bases: Commander
BackTest Commander to debug commander notify
init
¤
init(
bot: LetTradeBot,
brain: Brain,
exchange: Exchange,
strategy: Strategy,
)
Init commander dependencies
Parameters:
-
bot
(LetTradeBot
) –LetTradeBot object
-
brain
(Brain
) –Brain of bot
-
exchange
(Exchange
) –Manage bot trading
-
strategy
(Strategy
) –Strategy of bot
Source code in lettrade/commander/commander.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
BackTestDataFeed
¤
BackTestDataFeed(
data: DataFrame,
name: str,
timeframe: str | int | Timedelta | None = None,
meta: dict | None = None,
since: int | str | Timestamp | None = None,
to: int | str | Timestamp | None = None,
**kwargs
)
Bases: DataFeed
BackTest DataFeed
Parameters:
-
data
(DataFrame
) –description
-
name
(str
) –description
-
timeframe
(str | int | Timedelta | None
, default:None
) –description. Defaults to None.
-
meta
(dict | None
, default:None
) –description. Defaults to None.
-
since
(int | str | Timestamp | None
, default:None
) –Drop data before since. Defaults to None.
-
to
(int | str | Timestamp | None
, default:None
) –Drop data after to. Defaults to None.
Source code in lettrade/exchange/backtest/data.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
i
property
¤
i: indicator
Alias to lettrade.indicator
and using in DataFeed by call: DataFeed.i.indicator_name()
l
instance-attribute
¤
LetTrade DataFeed wrapper using to manage index pointer of DataFeed
bar
¤
bar(i: int = 0) -> Timestamp
Get current pd.Timestamp value of DataFeed
Parameters:
-
i
(int
, default:0
) –Index. Defaults to 0.
Returns:
-
Timestamp
–pd.Timestamp: description
Source code in lettrade/data/data.py
108 109 110 111 112 113 114 115 116 117 |
|
copy
¤
summary
Parameters:
-
deep
(bool
, default:False
) –description. Defaults to False.
Returns:
-
DataFeed
(DataFeed
) –description
Source code in lettrade/data/data.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
drop
¤
drop(
*args,
since: int | str | Timestamp | None = None,
to: int | str | Timestamp | None = None,
**kwargs
) -> None | DataFeed
summary
Parameters:
-
since
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
-
to
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/data/data.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
push
¤
Push new rows to DataFeed
Parameters:
-
rows
(list[list[int | float]]
) –list of rows
[["timestamp", "open price", "high price"...]]
-
unit
(str | None
, default:None
) –pandas.Timestamp parsing unit. Defaults to None.
-
utc
(bool
, default:True
) –description. Defaults to True.
Source code in lettrade/data/data.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
BackTestDataFeeder
¤
BackTestDataFeeder(start_size: int = 500)
Bases: DataFeeder
BackTest DataFeeder
Source code in lettrade/exchange/backtest/feeder.py
18 19 20 |
|
BackTestExchange
¤
BackTestExchange(**kwargs)
Bases: Exchange
Source code in lettrade/exchange/backtest/exchange.py
15 16 17 18 19 |
|
history_orders
instance-attribute
¤
History Order dict by Order.id
key
history_positions
instance-attribute
¤
History Position dict by Position.id
key
positions
instance-attribute
¤
Available Position dict by Position.id
key
init
¤
init(
brain: Brain,
feeder: DataFeeder,
account: Account,
commander: Commander,
) -> None
Init Exchange dependencies.
Set data/datas from feeder.
Set state to ExchangeState.Start
.
Parameters:
-
brain
(Brain
) –description
-
feeder
(DataFeeder
) –description
-
account
(Account
) –description
-
commander
(Commander
) –description
Source code in lettrade/exchange/exchange.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
new_order
¤
new_order(
size: float,
type: OrderType = OrderType.Market,
limit: float | None = None,
stop: float | None = None,
sl: float | None = None,
tp: float | None = None,
tag: object | None = None,
data: DataFeed | None = None,
expiration: datetime | None = None,
**kwargs
) -> OrderResult
Place new order.
Then send order events to Brain
Parameters:
-
size
(float
) –description
-
type
(OrderType | None
, default:Market
) –description. Defaults to OrderType.Market.
-
limit
(float | None
, default:None
) –description. Defaults to None.
-
stop
(float | None
, default:None
) –description. Defaults to None.
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
tag
(object | None
, default:None
) –description. Defaults to None.
-
data
(DataFeed | None
, default:None
) –description. Defaults to None.
-
**kwargs
(dict | None
, default:{}
) –Extra-parameters
Returns:
-
OrderResult
(OrderResult
) –Result when place new
Order
Source code in lettrade/exchange/backtest/exchange.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
next
¤
next()
Execution when new data feeded
Source code in lettrade/exchange/backtest/exchange.py
25 26 27 28 |
|
next_next
¤
next_next()
Call after strategy.next()
Source code in lettrade/exchange/exchange.py
109 110 111 |
|
on_executions
¤
Receive Execution event from exchange then store and notify Brain
Source code in lettrade/exchange/exchange.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
on_order
¤
Receive order event from exchange then store and notify Brain
Parameters:
-
order
(Order
) –description
-
broadcast
(bool | None
, default:True
) –description. Defaults to True.
Source code in lettrade/exchange/exchange.py
160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
on_orders
¤
Receive orders event from exchange then store and notify Brain
Parameters:
-
orders
(list[Order]
) –description
-
broadcast
(bool | None
, default:True
) –description. Defaults to True.
Raises:
-
RuntimeError
–description
Source code in lettrade/exchange/exchange.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
on_position
¤
Receive Position event from exchange then store and notify Brain
Parameters:
-
position
(Position
) –new comming
Position
-
broadcast
(bool | None
, default:True
) –Flag notify to Brain. Defaults to True.
Raises:
-
RuntimeError
–validate
Position
instance
Source code in lettrade/exchange/exchange.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
on_positions
¤
Receive Positions event from exchange then store and notify Brain
Parameters:
-
positions
(list[Position]
) –list of new comming
Position
-
broadcast
(bool | None
, default:True
) –Flag notify to Brain. Defaults to True.
Raises:
-
RuntimeError
–validate
Position
instance
Source code in lettrade/exchange/exchange.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
start
¤
start() -> None
Start of Exchange by:
- Start account.
- Set state to ExchangeState.Run
ready for next().
Source code in lettrade/exchange/exchange.py
97 98 99 100 101 102 103 |
|
stop
¤
stop() -> None
Stop Exchange
Source code in lettrade/exchange/exchange.py
113 114 115 116 |
|
BackTestExecution
¤
BackTestExecution(
exchange: BackTestExchange, *args, **kwargs
)
Bases: Execution
Execution for backtesting
Source code in lettrade/exchange/backtest/trade.py
28 29 30 31 32 33 34 35 |
|
from_order
classmethod
¤
from_order(
order: BackTestOrder,
price: float,
at: object,
size: float | None = None,
) -> BackTestExecution
Method help to build Execution object from Order object
Parameters:
-
price
(float
) –Executed price
-
at
(object
) –Executed bar
-
size
(float | None
, default:None
) –Executed size. Defaults to None.
Returns:
-
BackTestExecution
(BackTestExecution
) –Execution object
Source code in lettrade/exchange/backtest/trade.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
merge
¤
merge(other: Execution)
Merge to keep object handler but not overwrite for Strategy using when Strategy want to store object and object will be automatic update directly
Source code in lettrade/exchange/execution.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
BackTestOrder
¤
BackTestOrder(
id: str,
exchange: Exchange,
data: DataFeed,
size: float,
state: OrderState = OrderState.Pending,
type: OrderType = OrderType.Market,
limit_price: float | None = None,
stop_price: float | None = None,
sl_price: float | None = None,
tp_price: float | None = None,
parent: Position | None = None,
expiration: datetime | None = None,
tag: str | None = None,
placed_at: datetime | None = None,
**kwargs
)
Bases: Order
Order for backtesting
Parameters:
-
id
(str
) –description
-
exchange
(Exchange
) –description
-
data
(DataFeed
) –description
-
size
(float
) –description
-
state
(OrderState
, default:Pending
) –description. Defaults to OrderState.Pending.
-
type
(OrderType
, default:Market
) –description. Defaults to OrderType.Market.
-
limit_price
(float | None
, default:None
) –description. Defaults to None.
-
stop_price
(float | None
, default:None
) –description. Defaults to None.
-
sl_price
(float | None
, default:None
) –description. Defaults to None.
-
tp_price
(float | None
, default:None
) –description. Defaults to None.
-
parent
(Position | None
, default:None
) –description. Defaults to None.
-
expiration
(datetime | None
, default:None
) –description. Defaults to None.
-
tag
(str | None
, default:None
) –description. Defaults to None.
-
placed_at
(datetime | None
, default:None
) –description. Defaults to None.
Source code in lettrade/exchange/order.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
is_closed
property
¤
is_closed: bool
Flag to check Order
closed
Returns:
-
bool
(bool
) –True if
state
in [OrderState.Filled, OrderState.Canceled]
is_opening
property
¤
is_opening: bool
Flag to check Order
still alive
Returns:
-
bool
(bool
) –True if
state
in [OrderState.Placed, OrderState.Partial]
cancel
¤
cancel(
caller: Order | Position | None = None, **kwargs
) -> OrderResult
Cancel the Order and notify Exchange
Source code in lettrade/exchange/backtest/trade.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
fill
¤
fill(
price: float, at: object, **kwargs
) -> BackTestExecution
Execution order and notify for Exchange
Parameters:
Raises:
-
RuntimeError
–description
Returns:
-
BackTestExecution
(BackTestExecution
) –Execution object
Source code in lettrade/exchange/backtest/trade.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
merge
¤
merge(other: Order)
Update current Order
variables by other Order
Parameters:
-
other
(Order
) –Merge source
Order
Raises:
-
RuntimeError
–Validate same id
Source code in lettrade/exchange/order.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
place
¤
place(
at: Timestamp, raw: object | None = None
) -> OrderResult
Place Order
Set status
to OrderState.Placed
.
Send event to Exchange
Raises:
-
RuntimeError
–description
Returns:
-
OrderResult
(OrderResult
) –result of
Order
Source code in lettrade/exchange/order.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
update
¤
update(
limit_price: float | None = None,
stop_price: float | None = None,
sl: float | None = None,
tp: float | None = None,
raw: object | None = None,
) -> OrderResult
Update Order
Parameters:
-
limit_price
(float
, default:None
) –description. Defaults to None.
-
stop_price
(float
, default:None
) –description. Defaults to None.
-
sl
(float
, default:None
) –description. Defaults to None.
-
tp
(float
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/exchange/order.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
BackTestPosition
¤
BackTestPosition(
id: str,
exchange: Exchange,
data: DataFeed,
size: float,
parent: Order,
state: PositionState = PositionState.Open,
entry_price: float | None = None,
entry_fee: float = 0.0,
entry_at: Timestamp | None = None,
sl_order: Order | None = None,
tp_order: Order | None = None,
tag: str | None = None,
**kwargs
)
Bases: Position
Position for backtesting
Source code in lettrade/exchange/position.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
exit
¤
exit(
price: float | None = None,
at: Timestamp | None = None,
caller: Order | Position | None = None,
**kwargs
) -> PositionResult
Exit Position
Parameters:
-
price
(float
, default:None
) –Exit price
-
at
(object
, default:None
) –Exit bar
-
caller
(Order | Position
, default:None
) –Skip caller to prevent infinite recursion loop. Defaults to None.
Source code in lettrade/exchange/backtest/trade.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
from_order
classmethod
¤
from_order(
order: BackTestOrder,
size: float | None = None,
state: PositionState = PositionState.Open,
**kwargs
) -> BackTestPosition
Build Position object from Order object
Parameters:
-
size
(float
, default:None
) –Size of Position object. Defaults to None.
-
state
(PositionState
, default:Open
) –State of Position object. Defaults to PositionState.Open.
Returns:
-
BackTestPosition
(BackTestPosition
) –Position object
Source code in lettrade/exchange/backtest/trade.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
merge
¤
Merge position from another position has same id
Parameters:
-
other
(Position
) –description
Raises:
-
RuntimeError
–description
Source code in lettrade/exchange/position.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
BotPlotter
¤
BotPlotter(bot: LetTradeBot)
Bases: Plotter
Class help to plot bot result
Source code in lettrade/plot/bot.py
34 35 36 37 38 39 40 41 42 |
|
jump
¤
jump(
since: int | str | Timestamp | None = None,
order_id: str | None = None,
position_id: str | None = None,
range: int = 300,
name: str | None = None,
)
Jump to place on datefeed
Parameters:
-
since
(int | str | Timestamp | None
, default:None
) –Jump to index/datetime. Defaults to None.
-
order_id
(str | None
, default:None
) –Jump to order id. Defaults to None.
-
position_id
(str | None
, default:None
) –Jump to position id. Defaults to None.
-
range
(int
, default:300
) –number of candle plot. Defaults to 300.
-
name
(str | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/plot/bot.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
jump_reset
¤
jump_reset() -> bool
Reset jump datafeeds back to bot datafeeds
Source code in lettrade/plot/bot.py
115 116 117 118 119 |
|
load
abstractmethod
¤
load()
Load plot config from Strategy.plot()
and setup candlestick/equity
Source code in lettrade/plot/plot.py
9 10 11 |
|
plot
abstractmethod
¤
plot(**kwargs)
Plot equity
, orders
, and positions
then show
Source code in lettrade/plot/plot.py
13 14 15 |
|
stop
abstractmethod
¤
stop()
stop plotter
Source code in lettrade/plot/plot.py
17 18 19 |
|
BotStatistic
¤
BotStatistic(
feeder: DataFeeder,
exchange: Exchange,
strategy: Strategy,
)
Compute strategy result
Source code in lettrade/stats/stats.py
21 22 23 24 25 26 27 28 29 30 |
|
compute
¤
compute()
Calculate strategy report
Source code in lettrade/stats/stats.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
show
¤
show()
Show statistic report
Source code in lettrade/stats/stats.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
CCXTAPI
¤
CCXTAPI(
exchange: int,
key: str,
secret: str,
currency: str = "USDT",
ccxt: CCXTAPIExchange | None = None,
**kwargs
)
Bases: LiveAPI
CCXT API
Parameters:
-
exchange
(int
) –description
-
key
(str
) –description
-
secret
(str
) –description
-
ccxt
(CCXTAPIExchange | None
, default:None
) –description. Defaults to None.
Source code in lettrade/exchange/ccxt/api.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
account
¤
account() -> dict
Source code in lettrade/exchange/ccxt/api.py
264 265 266 267 268 269 270 271 272 273 274 |
|
execution_get
¤
Source code in lettrade/exchange/ccxt/api.py
323 324 |
|
executions_get
¤
Source code in lettrade/exchange/ccxt/api.py
315 316 317 318 319 320 321 |
|
executions_total
¤
Source code in lettrade/exchange/ccxt/api.py
307 308 309 310 311 312 313 |
|
init
¤
init(**kwargs)
Source code in lettrade/exchange/live/api.py
21 22 |
|
order_close
¤
order_close(order: CCXTOrder)
Source code in lettrade/exchange/ccxt/api.py
297 298 |
|
order_open
¤
order_open(order: CCXTOrder, **kwargs)
Source code in lettrade/exchange/ccxt/api.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
orders_get
¤
orders_get(**kwargs)
Source code in lettrade/exchange/ccxt/api.py
303 304 |
|
orders_history_get
¤
orders_history_get(
id: str | None = None,
since: datetime | None = None,
to: datetime | None = None,
**kwargs
) -> list[dict]
Source code in lettrade/exchange/live/api.py
100 101 102 103 104 105 106 107 |
|
orders_total
¤
orders_total()
Source code in lettrade/exchange/ccxt/api.py
300 301 |
|
position_close
¤
position_close(position: CCXTPosition, **kwargs) -> dict
Source code in lettrade/exchange/ccxt/api.py
347 348 |
|
position_update
¤
position_update(
position: CCXTPosition,
sl: float | None = None,
tp: float | None = None,
**kwargs
) -> dict
Source code in lettrade/exchange/ccxt/api.py
338 339 340 341 342 343 344 345 |
|
positions_get
¤
Source code in lettrade/exchange/ccxt/api.py
335 336 |
|
positions_total
¤
Source code in lettrade/exchange/ccxt/api.py
327 328 329 330 331 332 333 |
|
CCXTAccount
¤
Bases: LiveAccount
Account for CCXT
Source code in lettrade/exchange/ccxt/ccxt.py
40 41 42 |
|
account_refresh
¤
account_refresh()
Refresh account balance
Source code in lettrade/exchange/live/account.py
53 54 55 56 57 58 59 60 61 |
|
next
¤
next()
Next account
Source code in lettrade/account/account.py
73 74 |
|
next_next
¤
next_next()
Call after strategy.next()
Source code in lettrade/account/account.py
76 77 78 |
|
risk
¤
Risk calculation
Source code in lettrade/account/account.py
87 88 89 90 91 |
|
start
¤
start()
Start live account by load account info from API
Source code in lettrade/exchange/live/account.py
34 35 36 37 38 |
|
stop
¤
stop()
Stop account
Source code in lettrade/account/account.py
80 81 82 83 84 85 |
|
CCXTDataFeed
¤
CCXTDataFeed(
symbol: str,
timeframe: str | int | Timedelta,
name: str | None = None,
columns: list[str] | None = None,
api: LiveAPI | None = None,
api_kwargs: dict | None = None,
**kwargs
)
Bases: LiveDataFeed
DataFeed for CCXT
Parameters:
-
symbol
(str
) –Symbol of DataFeed
-
timeframe
(str | int | Timedelta
) –TimeFrame of DataFeed
-
name
(str | None
, default:None
) –Name of DataFeed, auto generate
{symbol}_{timeframe}
if none. Defaults to None. -
columns
(list[str] | None
, default:None
) –List of DataFeed columns. Defaults to None.
-
api
(LiveAPI | None
, default:None
) –Live trading API. Defaults to None.
Source code in lettrade/exchange/live/data.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
i
property
¤
i: indicator
Alias to lettrade.indicator
and using in DataFeed by call: DataFeed.i.indicator_name()
l
instance-attribute
¤
LetTrade DataFeed wrapper using to manage index pointer of DataFeed
bar
¤
bar(i: int = 0) -> Timestamp
Get current pd.Timestamp value of DataFeed
Parameters:
-
i
(int
, default:0
) –Index. Defaults to 0.
Returns:
-
Timestamp
–pd.Timestamp: description
Source code in lettrade/data/data.py
108 109 110 111 112 113 114 115 116 117 |
|
bars
¤
Get bars from LiveAPI
Parameters:
Returns:
-
list
(list
) –list of bar
Source code in lettrade/exchange/live/data.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
bars_load
¤
Get bar from API and push to DataFeed
Parameters:
Returns:
-
bool
(bool
) –True if has data, False if no data
Source code in lettrade/exchange/live/data.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
drop
¤
drop(
*args,
since: int | str | Timestamp | None = None,
to: int | str | Timestamp | None = None,
**kwargs
) -> None | DataFeed
summary
Parameters:
-
since
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
-
to
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/data/data.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
dump_csv
¤
dump_csv(
path: str | None = None,
since: int | str | datetime | None = 0,
to: int | str | datetime | None = 1000,
**kwargs
)
summary
Parameters:
-
path
(str | None
, default:None
) –description. Defaults to None.
-
since
(int | str | datetime | None
, default:0
) –description. Defaults to 0.
-
to
(int | str | datetime | None
, default:1000
) –description. Defaults to 1_000.
Source code in lettrade/exchange/live/data.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
next
¤
next(size=1, tick=0) -> bool
Drop extra columns and load next DataFeed
Parameters:
-
size
(int
, default:1
) –description. Defaults to 1.
-
tick
(int
, default:0
) –description. Defaults to 0.
Returns:
-
bool
(bool
) –description
Source code in lettrade/exchange/live/data.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
push
¤
Push new rows to DataFeed
Parameters:
-
rows
(list[list[int | float]]
) –list of rows
[["timestamp", "open price", "high price"...]]
-
unit
(str | None
, default:None
) –pandas.Timestamp parsing unit. Defaults to None.
-
utc
(bool
, default:True
) –description. Defaults to True.
Source code in lettrade/data/data.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
symbol_info
¤
symbol_info()
Get symbol information from API
Source code in lettrade/exchange/live/data.py
74 75 76 |
|
CCXTDataFeeder
¤
CCXTDataFeeder(
api: LiveAPI | None = None,
tick: bool = 5,
start_size: int = 500,
api_kwargs: dict | None = None,
**kwargs
)
Bases: LiveDataFeeder
DataFeeder for CCXT
tick == 0: wait until new bar change value
tick > 0: sleep tick time (in seconds) then update
Source code in lettrade/exchange/live/feeder.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
CCXTExchange
¤
CCXTExchange(api: LiveAPI, *args, **kwargs)
Bases: LiveExchange
MetaTrade 5 exchange module for lettrade
Parameters:
-
api
(LiveAPI
) –API connect to rpyc MeTrader 5 Terminal server through module
mt5linux
-
*args
(list
, default:()
) –Exchange
list parameters -
**kwargs
(dict
, default:{}
) –Exchange
dict parameters
Source code in lettrade/exchange/live/exchange.py
21 22 23 24 25 26 27 28 29 30 |
|
executions
instance-attribute
¤
Execution dict by Execution.id
key
history_orders
instance-attribute
¤
History Order dict by Order.id
key
history_positions
instance-attribute
¤
History Position dict by Position.id
key
positions
instance-attribute
¤
Available Position dict by Position.id
key
init
¤
init(
brain: Brain,
feeder: DataFeeder,
account: Account,
commander: Commander,
) -> None
Init Exchange dependencies.
Set data/datas from feeder.
Set state to ExchangeState.Start
.
Parameters:
-
brain
(Brain
) –description
-
feeder
(DataFeeder
) –description
-
account
(Account
) –description
-
commander
(Commander
) –description
Source code in lettrade/exchange/exchange.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
new_order
¤
new_order(
size: float,
type: OrderType | None = OrderType.Market,
limit: float | None = None,
stop: float | None = None,
sl: float | None = None,
tp: float | None = None,
tag: str | None = None,
data: DataFeed | None = None,
**kwargs
) -> OrderResult
Place new order to server
Parameters:
-
size
(float
) –description
-
type
(OrderType | None
, default:Market
) –description. Defaults to OrderType.Market.
-
limit
(float | None
, default:None
) –description. Defaults to None.
-
stop
(float | None
, default:None
) –description. Defaults to None.
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
tag
(str | None
, default:None
) –description. Defaults to None.
-
data
(DataFeed | None
, default:None
) –description. Defaults to None.
Returns:
-
OrderResult
(OrderResult
) –description
Source code in lettrade/exchange/live/exchange.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
next_next
¤
next_next()
Call after strategy.next()
Source code in lettrade/exchange/exchange.py
109 110 111 |
|
on_execution
¤
Receive Execution event from exchange then store and notify Brain
Parameters:
-
execution
(Execution
) –description
-
broadcast
(bool | None
, default:True
) –description. Defaults to True.
Source code in lettrade/exchange/exchange.py
118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
on_executions
¤
Receive Execution event from exchange then store and notify Brain
Source code in lettrade/exchange/exchange.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
on_order
¤
Receive order event from exchange then store and notify Brain
Parameters:
-
order
(Order
) –description
-
broadcast
(bool | None
, default:True
) –description. Defaults to True.
Source code in lettrade/exchange/exchange.py
160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
on_orders
¤
Receive orders event from exchange then store and notify Brain
Parameters:
-
orders
(list[Order]
) –description
-
broadcast
(bool | None
, default:True
) –description. Defaults to True.
Raises:
-
RuntimeError
–description
Source code in lettrade/exchange/exchange.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
on_position
¤
Receive Position event from exchange then store and notify Brain
Parameters:
-
position
(Position
) –new comming
Position
-
broadcast
(bool | None
, default:True
) –Flag notify to Brain. Defaults to True.
Raises:
-
RuntimeError
–validate
Position
instance
Source code in lettrade/exchange/exchange.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
on_positions
¤
Receive Positions event from exchange then store and notify Brain
Parameters:
-
positions
(list[Position]
) –list of new comming
Position
-
broadcast
(bool | None
, default:True
) –Flag notify to Brain. Defaults to True.
Raises:
-
RuntimeError
–validate
Position
instance
Source code in lettrade/exchange/exchange.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
start
¤
start() -> None
Start Live exchange by: Sync positions from server
Source code in lettrade/exchange/live/exchange.py
32 33 34 35 |
|
stop
¤
stop() -> None
Stop Exchange
Source code in lettrade/exchange/exchange.py
113 114 115 116 |
|
CCXTExecution
¤
CCXTExecution(
id: str,
exchange: LiveExchange,
data: LiveDataFeed,
size: float,
price: float,
at: float,
order_id: str | None = None,
order: Order | None = None,
position_id: str | None = None,
position: Position | None = None,
api: LiveAPI | None = None,
raw: object | None = None,
**kwargs
)
Bases: LiveExecution
Execution for CCXT
Source code in lettrade/exchange/live/trade.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
from_raw
classmethod
¤
from_raw(
raw, exchange: LiveExchange, api: CCXTAPI = None
) -> CCXTExecution
Building new CCXTExecution from live api raw object
Parameters:
-
raw
(_type_
) –description
-
exchange
(LiveExchange
) –description
Returns:
-
CCXTExecution
(CCXTExecution
) –description
Source code in lettrade/exchange/ccxt/trade.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
merge
¤
merge(other: Execution)
Merge to keep object handler but not overwrite for Strategy using when Strategy want to store object and object will be automatic update directly
Source code in lettrade/exchange/execution.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
CCXTOrder
¤
CCXTOrder(is_real: bool = True, **kwargs)
Bases: LiveOrder
Order for CCXT
Source code in lettrade/exchange/ccxt/trade.py
73 74 75 76 77 |
|
is_closed
property
¤
is_closed: bool
Flag to check Order
closed
Returns:
-
bool
(bool
) –True if
state
in [OrderState.Filled, OrderState.Canceled]
is_opening
property
¤
is_opening: bool
Flag to check Order
still alive
Returns:
-
bool
(bool
) –True if
state
in [OrderState.Placed, OrderState.Partial]
is_real
instance-attribute
¤
Flag to check Order
is real, cannot duplicate id, cannot recall from history
cancel
¤
cancel(**kwargs) -> OrderResult
Cancel order
Returns:
-
OrderResult
(OrderResult
) –description
Source code in lettrade/exchange/ccxt/trade.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
fill
¤
fill(
price: float, at: Timestamp, raw: object | None = None
) -> OrderResult
Fill Order
.
Set status
to OrderState.Executed
.
Send event to Exchange
Parameters:
-
price
(float
) –Executed price
-
at
(Timestamp
) –Executed bar
Raises:
-
RuntimeError
–description
Returns:
-
OrderResult
(OrderResult
) –result of
Order
Source code in lettrade/exchange/order.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
from_position
classmethod
¤
from_position(
position: CCXTPosition,
sl: float | None = None,
tp: float | None = None,
) -> CCXTOrder
summary
Parameters:
-
position
(CCXTPosition
) –description
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Returns:
-
CCXTOrder
(CCXTOrder
) –description
Source code in lettrade/exchange/ccxt/trade.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
from_raw
classmethod
¤
from_raw(
raw: Any,
exchange: LiveExchange,
api: CCXTAPI | None = None,
) -> CCXTOrder | None
summary
Parameters:
-
raw
(Any
) –description.
-
exchange
(LiveExchange
) –description.
-
api
(CCXTAPI | None
, default:None
) –description. Defaults to None.
Raises:
-
NotImplementedError
–description
Returns:
-
CCXTOrder
(CCXTOrder | None
) –description
Source code in lettrade/exchange/ccxt/trade.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
|
merge
¤
merge(other: Order)
Update current Order
variables by other Order
Parameters:
-
other
(Order
) –Merge source
Order
Raises:
-
RuntimeError
–Validate same id
Source code in lettrade/exchange/order.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
place
¤
place() -> OrderResult
summary
Raises:
-
RuntimeError
–description
Returns:
-
OrderResult
(OrderResult
) –description
Source code in lettrade/exchange/ccxt/trade.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
update
¤
update(
limit_price: float | None = None,
stop_price: float | None = None,
sl: float | None = None,
tp: float | None = None,
caller: float | None = None,
**kwargs
) -> OrderResult
summary
Parameters:
-
limit_price
(float | None
, default:None
) –description. Defaults to None.
-
stop_price
(float | None
, default:None
) –description. Defaults to None.
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
caller
(float | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Returns:
-
OrderResult
(OrderResult
) –description
Source code in lettrade/exchange/ccxt/trade.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
CCXTPosition
¤
CCXTPosition(
id: str,
exchange: LiveExchange,
data: LiveDataFeed,
size: float,
parent: Order,
tag: str | None = None,
state: PositionState = PositionState.Open,
entry_price: float | None = None,
entry_fee: float = 0.0,
entry_at: int | None = None,
sl_order: Order | None = None,
tp_order: Order | None = None,
api: LiveAPI | None = None,
raw: object | None = None,
**kwargs
)
Bases: LivePosition
Position for CCXT
Source code in lettrade/exchange/live/trade.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
|
exit
¤
exit() -> PositionResult
summary
Returns:
-
PositionResult
(PositionResult
) –description
Source code in lettrade/exchange/ccxt/trade.py
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
from_raw
classmethod
¤
from_raw(
raw,
exchange: LiveExchange,
state: PositionState = PositionState.Open,
data: LiveDataFeed = None,
api: CCXTAPI = None,
) -> CCXTPosition
summary
Parameters:
-
raw
(_type_
) –description
-
exchange
(LiveExchange
) –description
-
data
(LiveDataFeed
, default:None
) –description. Defaults to None.
-
api
(CCXTAPI
, default:None
) –description. Defaults to None.
Raises:
-
NotImplementedError
–description
Returns:
-
CCXTPosition
(CCXTPosition
) –description
Source code in lettrade/exchange/ccxt/trade.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
|
merge
¤
merge(other: LivePosition) -> bool
Merge LivePosition from another
Parameters:
-
other
(LivePosition
) –description
Returns:
-
bool
(bool
) –description
Source code in lettrade/exchange/live/trade.py
288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
update
¤
update(
sl: float | None = None,
tp: float | None = None,
caller: float | None = None,
**kwargs
) -> PositionResult
summary
Parameters:
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
caller
(float | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Returns:
-
PositionResult
(PositionResult
) –description
Source code in lettrade/exchange/ccxt/trade.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
CSVBackTestDataFeed
¤
CSVBackTestDataFeed(
path: str | None = None,
csv: dict | None = None,
name: str | None = None,
timeframe: str | int | Timedelta | None = None,
meta: dict | None = None,
data: DataFeed | None = None,
**kwargs: dict
)
Bases: BackTestDataFeed
Implement help to load DataFeed from csv file
Parameters:
-
path
(str | None
, default:None
) –Path to csv file. Defaults to None.
-
csv
(dict | None
, default:None
) –Reflect of
pandas.read_csv()
parameters. Defaults to None. -
name
(str | None
, default:None
) –description. Defaults to None.
-
timeframe
(str | int | Timedelta | None
, default:None
) –description. Defaults to None.
-
meta
(dict | None
, default:None
) –description. Defaults to None.
-
data
(DataFeed | None
, default:None
) –description. Defaults to None.
-
**kwargs
(dict
, default:{}
) –DataFeed dict parameters
Source code in lettrade/exchange/backtest/data.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
i
property
¤
i: indicator
Alias to lettrade.indicator
and using in DataFeed by call: DataFeed.i.indicator_name()
l
instance-attribute
¤
LetTrade DataFeed wrapper using to manage index pointer of DataFeed
bar
¤
bar(i: int = 0) -> Timestamp
Get current pd.Timestamp value of DataFeed
Parameters:
-
i
(int
, default:0
) –Index. Defaults to 0.
Returns:
-
Timestamp
–pd.Timestamp: description
Source code in lettrade/data/data.py
108 109 110 111 112 113 114 115 116 117 |
|
copy
¤
summary
Parameters:
-
deep
(bool
, default:False
) –description. Defaults to False.
Returns:
-
DataFeed
(DataFeed
) –description
Source code in lettrade/data/data.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
drop
¤
drop(
*args,
since: int | str | Timestamp | None = None,
to: int | str | Timestamp | None = None,
**kwargs
) -> None | DataFeed
summary
Parameters:
-
since
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
-
to
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/data/data.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
push
¤
Push new rows to DataFeed
Parameters:
-
rows
(list[list[int | float]]
) –list of rows
[["timestamp", "open price", "high price"...]]
-
unit
(str | None
, default:None
) –pandas.Timestamp parsing unit. Defaults to None.
-
utc
(bool
, default:True
) –description. Defaults to True.
Source code in lettrade/data/data.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
Commander
¤
Bases: ABC
Abstract class for strategy commander. Help to manage and report strategy real-time
init
¤
init(
bot: LetTradeBot,
brain: Brain,
exchange: Exchange,
strategy: Strategy,
)
Init commander dependencies
Parameters:
-
bot
(LetTradeBot
) –LetTradeBot object
-
brain
(Brain
) –Brain of bot
-
exchange
(Exchange
) –Manage bot trading
-
strategy
(Strategy
) –Strategy of bot
Source code in lettrade/commander/commander.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
DataFeed
¤
Bases: DataFrame
Data for Strategy. A implement of pandas.DataFrame
Parameters:
-
name
(str
) –description
-
timeframe
(TimeFrame
) –description
-
meta
(dict | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/data/data.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
i
property
¤
i: indicator
Alias to lettrade.indicator
and using in DataFeed by call: DataFeed.i.indicator_name()
l
instance-attribute
¤
LetTrade DataFeed wrapper using to manage index pointer of DataFeed
bar
¤
bar(i: int = 0) -> Timestamp
Get current pd.Timestamp value of DataFeed
Parameters:
-
i
(int
, default:0
) –Index. Defaults to 0.
Returns:
-
Timestamp
–pd.Timestamp: description
Source code in lettrade/data/data.py
108 109 110 111 112 113 114 115 116 117 |
|
copy
¤
summary
Parameters:
-
deep
(bool
, default:False
) –description. Defaults to False.
Returns:
-
DataFeed
(DataFeed
) –description
Source code in lettrade/data/data.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
drop
¤
drop(
*args,
since: int | str | Timestamp | None = None,
to: int | str | Timestamp | None = None,
**kwargs
) -> None | DataFeed
summary
Parameters:
-
since
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
-
to
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/data/data.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
next
¤
next(size=1)
Load next data
Parameters:
-
size
(int
, default:1
) –description. Defaults to 1.
Source code in lettrade/data/data.py
100 101 102 103 104 105 106 |
|
push
¤
Push new rows to DataFeed
Parameters:
-
rows
(list[list[int | float]]
) –list of rows
[["timestamp", "open price", "high price"...]]
-
unit
(str | None
, default:None
) –pandas.Timestamp parsing unit. Defaults to None.
-
utc
(bool
, default:True
) –description. Defaults to True.
Source code in lettrade/data/data.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
ForexBackTestAccount
¤
ForexBackTestAccount(
risk: float = 0.02,
balance: float = 10000,
commission: float = 0.2,
margin: float = 1,
leverage: float = 1,
**kwargs
)
Bases: BackTestAccount
Forex backtest account helps to handle lot size
Parameters:
-
risk
(float
, default:0.02
) –description. Defaults to 0.02.
-
balance
(float
, default:10000
) –description. Defaults to 10_000.
-
commission
(float
, default:0.2
) –Commission fee is percent of size. Defaults to 0.2.
-
margin
(float
, default:1
) –description. Defaults to 1.
-
leverage
(float
, default:1
) –description. Defaults to 1.
-
**kwargs
(dict
, default:{}
) –Mirror of lettrade.account.Account().
Source code in lettrade/exchange/backtest/account.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
next
¤
next()
Next account
Source code in lettrade/account/account.py
73 74 |
|
next_next
¤
next_next()
Call after strategy.next()
Source code in lettrade/account/account.py
76 77 78 |
|
risk
¤
Risk calculation
Source code in lettrade/account/account.py
87 88 89 90 91 |
|
start
¤
start()
Start account
Source code in lettrade/account/account.py
70 71 |
|
stop
¤
stop()
Stop account
Source code in lettrade/account/account.py
80 81 82 83 84 85 |
|
IndicatorPlotter
¤
IndicatorPlotter(
dataframe: DataFrame,
plotter: Callable,
filter: Callable | Series | None = None,
push: bool = True,
**kwargs
)
Add indicator plotter to DataFrame
Source code in lettrade/indicator/plot.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
LetTrade
¤
LetTrade(
datas: DataFeed | list[DataFeed] | str | list[str],
strategy: type[Strategy],
feeder: type[DataFeeder],
exchange: type[Exchange],
account: type[Account],
commander: type[Commander] | Commander | None = None,
stats: type[BotStatistic] = BotStatistic,
plotter: type[Plotter] | None = None,
name: str | None = None,
bot: type[LetTradeBot] = LetTradeBot,
**kwargs
)
Building new bot object and handle multiprocessing
Parameters:
-
datas
(DataFeed | list[DataFeed] | str | list[str]
) –description
-
strategy
(type[Strategy]
) –description
-
feeder
(type[DataFeeder]
) –description
-
exchange
(type[Exchange]
) –description
-
account
(type[Account]
) –description
-
commander
(type[Commander] | Commander | None
, default:None
) –description. Defaults to None.
-
stats
(type[BotStatistic]
, default:BotStatistic
) –description. Defaults to BotStatistic.
-
plotter
(type[Plotter] | None
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
bot
(type[LetTradeBot]
, default:LetTradeBot
) –description. Defaults to LetTradeBot.
Source code in lettrade/lettrade.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
plot
¤
plot(*args, jump: dict | None = None, **kwargs)
Plot strategy/optimize result
BotPlotter
Miror of BotPlotter.plot(). Plotly implement PlotlyBotPlotter.plot().
Args:
jump
(dict | None, optional): Miror of BotPlotter.jump()
Example: Jump to position_id
lt.plot(
jump=dict(position_id=1, range=300),
layout=dict(height=2000),
)
OptimizePlotter
Miror of OptimizePlotter.plot(). Plotly implement PlotlyOptimizePlotter.plot().
Example:
lt.plot(layout=dict(height=2000))
Source code in lettrade/lettrade.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
run
¤
run(worker: int | None = None, **kwargs)
Run LetTrade in single or multiple processing
Parameters:
-
worker
(int | None
, default:None
) –Number of processing. Defaults to None.
Source code in lettrade/lettrade.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
start
¤
start(force: bool = False)
Start LetTrade by init bot object and loading datafeeds
Parameters:
-
force
(bool
, default:False
) –description. Defaults to False.
Source code in lettrade/lettrade.py
108 109 110 111 112 113 114 115 116 117 |
|
stop
¤
stop()
Stop LetTrade
Source code in lettrade/lettrade.py
185 186 187 188 189 190 |
|
LetTradeBackTest
¤
LetTradeBackTest(
datas: DataFeed | list[DataFeed] | str | list[str],
strategy: type[Strategy],
feeder: type[DataFeeder],
exchange: type[Exchange],
account: type[Account],
commander: type[Commander] | Commander | None = None,
stats: type[BotStatistic] = BotStatistic,
plotter: type[Plotter] | None = None,
name: str | None = None,
bot: type[LetTradeBot] = LetTradeBot,
**kwargs
)
Bases: LetTrade
Parameters:
-
datas
(DataFeed | list[DataFeed] | str | list[str]
) –description
-
strategy
(type[Strategy]
) –description
-
feeder
(type[DataFeeder]
) –description
-
exchange
(type[Exchange]
) –description
-
account
(type[Account]
) –description
-
commander
(type[Commander] | Commander | None
, default:None
) –description. Defaults to None.
-
stats
(type[BotStatistic]
, default:BotStatistic
) –description. Defaults to BotStatistic.
-
plotter
(type[Plotter] | None
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
bot
(type[LetTradeBot]
, default:LetTradeBot
) –description. Defaults to LetTradeBot.
Source code in lettrade/lettrade.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
optimize
¤
optimize(
multiprocessing: Literal["auto", "fork"] = "auto",
workers: int | None = None,
process_bar: bool = True,
cache: str = "data/optimize",
**kwargs
)
Backtest optimization
Parameters:
-
multiprocessing
(str | None
, default:'auto'
) –description. Defaults to "auto".
Source code in lettrade/exchange/backtest/backtest.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
optimize_cache
¤
optimize_cache(cache: str = 'data/optimize')
Load optimize results from cache
Parameters:
-
cache
(str
, default:'data/optimize'
) –Cache directory. Defaults to "data/optimize".
Source code in lettrade/exchange/backtest/backtest.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
optimize_done
¤
optimize_done()
Clean and close optimize handlers
Source code in lettrade/exchange/backtest/backtest.py
433 434 435 |
|
optimize_model
¤
optimize_model(
params_parser: Callable[
[Any], list[set[str, Any]]
] = None,
result_parser: Callable[[Series], float] = None,
total: int = 0,
cache: str = "data/optimize",
process_bar: bool = False,
dumper: (
Callable[[dict, LetTradeBackTest], None] | None
) = None,
) -> Callable[[Any], Any]
Optimize function help to integrated with external optimize trainer
Parameters:
-
params_parser
(Callable[[Any], list[set[str, Any]]]
, default:None
) –Parse external parameters to bot parameters dict. Defaults to None.
-
result_parser
(Callable[[Series], float]
, default:None
) –Parse bot result to external score. Defaults to None.
-
total
(int
, default:0
) –Total number of optimize if possible. Defaults to 0.
-
cache
(str
, default:'data/optimize'
) –Cache directory to store optimize result. Defaults to "data/optimize".
-
process_bar
(bool
, default:False
) –Enable/Disable process bar. Defaults to False.
Raises:
-
RuntimeError
–description
Returns:
Source code in lettrade/exchange/backtest/backtest.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|
plot
¤
plot(*args, jump: dict | None = None, **kwargs)
Plot strategy/optimize result
BotPlotter
Miror of BotPlotter.plot(). Plotly implement PlotlyBotPlotter.plot().
Args:
jump
(dict | None, optional): Miror of BotPlotter.jump()
Example: Jump to position_id
lt.plot(
jump=dict(position_id=1, range=300),
layout=dict(height=2000),
)
OptimizePlotter
Miror of OptimizePlotter.plot(). Plotly implement PlotlyOptimizePlotter.plot().
Example:
lt.plot(layout=dict(height=2000))
Source code in lettrade/lettrade.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
stop
¤
stop()
Stop LetTrade
Source code in lettrade/lettrade.py
185 186 187 188 189 190 |
|
LetTradeBackTestBot
¤
LetTradeBackTestBot(
datas: DataFeed | list[DataFeed] | list[str] | str,
strategy: type[Strategy],
feeder: type[DataFeeder],
exchange: type[Exchange],
account: type[Account],
commander: type[Commander] | None = None,
plotter: type[Plotter] | None = None,
stats: type[BotStatistic] | None = None,
name: str | None = None,
**kwargs
)
Bases: LetTradeBot
LetTradeBot for backtest
Parameters:
-
datas
(DataFeed | list[DataFeed] | list[str] | str
) –description
-
strategy
(type[Strategy]
) –description
-
feeder
(type[DataFeeder]
) –description
-
exchange
(type[Exchange]
) –description
-
account
(type[Account]
) –description
-
commander
(type[Commander] | None
, default:None
) –description. Defaults to None.
-
plotter
(type[Plotter] | None
, default:None
) –description. Defaults to None.
-
stats
(type[BotStatistic] | None
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
Source code in lettrade/bot.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
new_bot
classmethod
¤
new_bot(
datas: list[DataFeed],
strategy_cls: type[Strategy],
feeder_cls: type[DataFeeder],
exchange_cls: type[Exchange],
account_cls: type[Account],
commander_cls: type[Commander],
plotter_cls: type[Plotter],
stats_cls: type[BotStatistic],
name: str | None = None,
**kwargs
) -> LetTradeBot
Create new bot object
Parameters:
-
datas
(list[DataFeed]
) –description
-
strategy_cls
(type[Strategy]
) –description
-
feeder_cls
(type[DataFeeder]
) –description
-
exchange_cls
(type[Exchange]
) –description
-
account_cls
(type[Account]
) –description
-
commander_cls
(type[Commander]
) –description
-
plotter_cls
(type[Plotter]
) –description
-
stats_cls
(type[BotStatistic]
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
Returns:
-
LetTradeBot
(LetTradeBot
) –description
Source code in lettrade/bot.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
plot
¤
plot(*args, **kwargs)
Plot bot result
Source code in lettrade/bot.py
189 190 191 192 193 194 195 196 197 |
|
run
¤
run()
Run bot
Source code in lettrade/bot.py
176 177 178 179 180 181 182 183 184 185 186 187 |
|
run_bot
classmethod
¤
run_bot(
bot: LetTradeBot | None = None,
datas: list[DataFeed] | None = None,
id: int | None = None,
name: str | None = None,
result: Literal["str", "stats", "bot", None] = "str",
**kwargs
) -> LetTradeBot | BotStatistic | str | None
Run bot object
Parameters:
-
bot
(LetTradeBot | None
, default:None
) –description. Defaults to None.
-
datas
(list[DataFeed] | None
, default:None
) –description. Defaults to None.
-
id
(int | None
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
result
(Literal['str', 'stats', 'bot', None]
, default:'str'
) –description. Defaults to "str".
Returns:
-
LetTradeBot | BotStatistic | str | None
–LetTradeBot | BotStatistic | str | None: Return value will be pickle across multiprocessing. The cost higher from
str
,stats
object,bot
object
Source code in lettrade/bot.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
start
¤
start(**kwargs)
Start bot
Source code in lettrade/bot.py
166 167 168 169 170 171 172 173 174 |
|
start_bot
classmethod
¤
start_bot(
bot: LetTradeBot | None = None, **kwargs
) -> LetTradeBot
Init and start bot object
Parameters:
-
bot
(LetTradeBot | None
, default:None
) –description. Defaults to None.
Returns:
-
LetTradeBot
(LetTradeBot
) –description
Source code in lettrade/bot.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
stop
¤
stop()
Stop bot
Source code in lettrade/bot.py
199 200 201 202 203 |
|
LetTradeBot
¤
LetTradeBot(
datas: DataFeed | list[DataFeed] | list[str] | str,
strategy: type[Strategy],
feeder: type[DataFeeder],
exchange: type[Exchange],
account: type[Account],
commander: type[Commander] | None = None,
plotter: type[Plotter] | None = None,
stats: type[BotStatistic] | None = None,
name: str | None = None,
**kwargs
)
Bot object helps to manage actions of bot
Parameters:
-
datas
(DataFeed | list[DataFeed] | list[str] | str
) –description
-
strategy
(type[Strategy]
) –description
-
feeder
(type[DataFeeder]
) –description
-
exchange
(type[Exchange]
) –description
-
account
(type[Account]
) –description
-
commander
(type[Commander] | None
, default:None
) –description. Defaults to None.
-
plotter
(type[Plotter] | None
, default:None
) –description. Defaults to None.
-
stats
(type[BotStatistic] | None
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
Source code in lettrade/bot.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
init
¤
init()
Init objects from classes
Source code in lettrade/bot.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
new_bot
classmethod
¤
new_bot(
datas: list[DataFeed],
strategy_cls: type[Strategy],
feeder_cls: type[DataFeeder],
exchange_cls: type[Exchange],
account_cls: type[Account],
commander_cls: type[Commander],
plotter_cls: type[Plotter],
stats_cls: type[BotStatistic],
name: str | None = None,
**kwargs
) -> LetTradeBot
Create new bot object
Parameters:
-
datas
(list[DataFeed]
) –description
-
strategy_cls
(type[Strategy]
) –description
-
feeder_cls
(type[DataFeeder]
) –description
-
exchange_cls
(type[Exchange]
) –description
-
account_cls
(type[Account]
) –description
-
commander_cls
(type[Commander]
) –description
-
plotter_cls
(type[Plotter]
) –description
-
stats_cls
(type[BotStatistic]
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
Returns:
-
LetTradeBot
(LetTradeBot
) –description
Source code in lettrade/bot.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
plot
¤
plot(*args, **kwargs)
Plot bot result
Source code in lettrade/bot.py
189 190 191 192 193 194 195 196 197 |
|
run
¤
run()
Run bot
Source code in lettrade/bot.py
176 177 178 179 180 181 182 183 184 185 186 187 |
|
run_bot
classmethod
¤
run_bot(
bot: LetTradeBot | None = None,
datas: list[DataFeed] | None = None,
id: int | None = None,
name: str | None = None,
result: Literal["str", "stats", "bot", None] = "str",
**kwargs
) -> LetTradeBot | BotStatistic | str | None
Run bot object
Parameters:
-
bot
(LetTradeBot | None
, default:None
) –description. Defaults to None.
-
datas
(list[DataFeed] | None
, default:None
) –description. Defaults to None.
-
id
(int | None
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
result
(Literal['str', 'stats', 'bot', None]
, default:'str'
) –description. Defaults to "str".
Returns:
-
LetTradeBot | BotStatistic | str | None
–LetTradeBot | BotStatistic | str | None: Return value will be pickle across multiprocessing. The cost higher from
str
,stats
object,bot
object
Source code in lettrade/bot.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
start
¤
start(**kwargs)
Start bot
Source code in lettrade/bot.py
166 167 168 169 170 171 172 173 174 |
|
start_bot
classmethod
¤
start_bot(
bot: LetTradeBot | None = None, **kwargs
) -> LetTradeBot
Init and start bot object
Parameters:
-
bot
(LetTradeBot | None
, default:None
) –description. Defaults to None.
Returns:
-
LetTradeBot
(LetTradeBot
) –description
Source code in lettrade/bot.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
stop
¤
stop()
Stop bot
Source code in lettrade/bot.py
199 200 201 202 203 |
|
LetTradeCCXT
¤
LetTradeCCXT(
feeder: type[CCXTDataFeeder] = CCXTDataFeeder,
exchange: type[CCXTExchange] = CCXTExchange,
account: type[CCXTAccount] = CCXTAccount,
**kwargs
)
Bases: LetTradeLive
Help to maintain CCXT bots
Parameters:
-
feeder
(Type[CCXTDataFeeder]
, default:CCXTDataFeeder
) –description. Defaults to CCXTDataFeeder.
-
exchange
(Type[CCXTExchange]
, default:CCXTExchange
) –description. Defaults to CCXTExchange.
-
account
(Type[CCXTAccount]
, default:CCXTAccount
) –description. Defaults to CCXTAccount.
Source code in lettrade/exchange/ccxt/ccxt.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
plot
¤
plot(*args, jump: dict | None = None, **kwargs)
Plot strategy/optimize result
BotPlotter
Miror of BotPlotter.plot(). Plotly implement PlotlyBotPlotter.plot().
Args:
jump
(dict | None, optional): Miror of BotPlotter.jump()
Example: Jump to position_id
lt.plot(
jump=dict(position_id=1, range=300),
layout=dict(height=2000),
)
OptimizePlotter
Miror of OptimizePlotter.plot(). Plotly implement PlotlyOptimizePlotter.plot().
Example:
lt.plot(layout=dict(height=2000))
Source code in lettrade/lettrade.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
run
¤
run(worker: int | None = None, **kwargs)
Run LetTrade in single or multiple processing
Parameters:
-
worker
(int | None
, default:None
) –Number of processing. Defaults to None.
Source code in lettrade/lettrade.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
start
¤
start(force: bool = False)
Start LetTrade by init bot object and loading datafeeds
Parameters:
-
force
(bool
, default:False
) –description. Defaults to False.
Source code in lettrade/lettrade.py
108 109 110 111 112 113 114 115 116 117 |
|
stop
¤
stop()
Stop LetTrade
Source code in lettrade/lettrade.py
185 186 187 188 189 190 |
|
LetTradeCCXTBot
¤
LetTradeCCXTBot(api: LiveAPI | None = LiveAPI, **kwargs)
Bases: LetTradeLiveBot
LetTradeBot for CCXT
Parameters:
Source code in lettrade/exchange/live/live.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
new_bot
classmethod
¤
new_bot(
datas: list[DataFeed],
strategy_cls: type[Strategy],
feeder_cls: type[DataFeeder],
exchange_cls: type[Exchange],
account_cls: type[Account],
commander_cls: type[Commander],
plotter_cls: type[Plotter],
stats_cls: type[BotStatistic],
name: str | None = None,
**kwargs
) -> LetTradeBot
Create new bot object
Parameters:
-
datas
(list[DataFeed]
) –description
-
strategy_cls
(type[Strategy]
) –description
-
feeder_cls
(type[DataFeeder]
) –description
-
exchange_cls
(type[Exchange]
) –description
-
account_cls
(type[Account]
) –description
-
commander_cls
(type[Commander]
) –description
-
plotter_cls
(type[Plotter]
) –description
-
stats_cls
(type[BotStatistic]
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
Returns:
-
LetTradeBot
(LetTradeBot
) –description
Source code in lettrade/bot.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
plot
¤
plot(*args, **kwargs)
Plot bot result
Source code in lettrade/bot.py
189 190 191 192 193 194 195 196 197 |
|
run
¤
run()
Run bot
Source code in lettrade/bot.py
176 177 178 179 180 181 182 183 184 185 186 187 |
|
run_bot
classmethod
¤
run_bot(
bot: LetTradeBot | None = None,
datas: list[DataFeed] | None = None,
id: int | None = None,
name: str | None = None,
result: Literal["str", "stats", "bot", None] = "str",
**kwargs
) -> LetTradeBot | BotStatistic | str | None
Run bot object
Parameters:
-
bot
(LetTradeBot | None
, default:None
) –description. Defaults to None.
-
datas
(list[DataFeed] | None
, default:None
) –description. Defaults to None.
-
id
(int | None
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
result
(Literal['str', 'stats', 'bot', None]
, default:'str'
) –description. Defaults to "str".
Returns:
-
LetTradeBot | BotStatistic | str | None
–LetTradeBot | BotStatistic | str | None: Return value will be pickle across multiprocessing. The cost higher from
str
,stats
object,bot
object
Source code in lettrade/bot.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
start
¤
start(**kwargs)
Start bot
Source code in lettrade/bot.py
166 167 168 169 170 171 172 173 174 |
|
start_bot
classmethod
¤
start_bot(
bot: LetTradeBot | None = None, **kwargs
) -> LetTradeBot
Init and start bot object
Parameters:
-
bot
(LetTradeBot | None
, default:None
) –description. Defaults to None.
Returns:
-
LetTradeBot
(LetTradeBot
) –description
Source code in lettrade/bot.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
stop
¤
stop()
Stop bot
Source code in lettrade/bot.py
199 200 201 202 203 |
|
LetTradeLive
¤
LetTradeLive(
datas: DataFeed | list[DataFeed] | str | list[str],
strategy: type[Strategy],
feeder: type[DataFeeder],
exchange: type[Exchange],
account: type[Account],
commander: type[Commander] | Commander | None = None,
stats: type[BotStatistic] = BotStatistic,
plotter: type[Plotter] | None = None,
name: str | None = None,
bot: type[LetTradeBot] = LetTradeBot,
**kwargs
)
Bases: LetTrade
Help to maintain live bots
Parameters:
-
datas
(DataFeed | list[DataFeed] | str | list[str]
) –description
-
strategy
(type[Strategy]
) –description
-
feeder
(type[DataFeeder]
) –description
-
exchange
(type[Exchange]
) –description
-
account
(type[Account]
) –description
-
commander
(type[Commander] | Commander | None
, default:None
) –description. Defaults to None.
-
stats
(type[BotStatistic]
, default:BotStatistic
) –description. Defaults to BotStatistic.
-
plotter
(type[Plotter] | None
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
bot
(type[LetTradeBot]
, default:LetTradeBot
) –description. Defaults to LetTradeBot.
Source code in lettrade/lettrade.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
plot
¤
plot(*args, jump: dict | None = None, **kwargs)
Plot strategy/optimize result
BotPlotter
Miror of BotPlotter.plot(). Plotly implement PlotlyBotPlotter.plot().
Args:
jump
(dict | None, optional): Miror of BotPlotter.jump()
Example: Jump to position_id
lt.plot(
jump=dict(position_id=1, range=300),
layout=dict(height=2000),
)
OptimizePlotter
Miror of OptimizePlotter.plot(). Plotly implement PlotlyOptimizePlotter.plot().
Example:
lt.plot(layout=dict(height=2000))
Source code in lettrade/lettrade.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
run
¤
run(worker: int | None = None, **kwargs)
Run LetTrade in single or multiple processing
Parameters:
-
worker
(int | None
, default:None
) –Number of processing. Defaults to None.
Source code in lettrade/lettrade.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
start
¤
start(force: bool = False)
Start LetTrade by init bot object and loading datafeeds
Parameters:
-
force
(bool
, default:False
) –description. Defaults to False.
Source code in lettrade/lettrade.py
108 109 110 111 112 113 114 115 116 117 |
|
stop
¤
stop()
Stop LetTrade
Source code in lettrade/lettrade.py
185 186 187 188 189 190 |
|
LetTradeLiveBot
¤
LetTradeLiveBot(api: LiveAPI | None = LiveAPI, **kwargs)
Bases: LetTradeBot
Live bot object
Parameters:
Source code in lettrade/exchange/live/live.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
new_bot
classmethod
¤
new_bot(
datas: list[DataFeed],
strategy_cls: type[Strategy],
feeder_cls: type[DataFeeder],
exchange_cls: type[Exchange],
account_cls: type[Account],
commander_cls: type[Commander],
plotter_cls: type[Plotter],
stats_cls: type[BotStatistic],
name: str | None = None,
**kwargs
) -> LetTradeBot
Create new bot object
Parameters:
-
datas
(list[DataFeed]
) –description
-
strategy_cls
(type[Strategy]
) –description
-
feeder_cls
(type[DataFeeder]
) –description
-
exchange_cls
(type[Exchange]
) –description
-
account_cls
(type[Account]
) –description
-
commander_cls
(type[Commander]
) –description
-
plotter_cls
(type[Plotter]
) –description
-
stats_cls
(type[BotStatistic]
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
Returns:
-
LetTradeBot
(LetTradeBot
) –description
Source code in lettrade/bot.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
plot
¤
plot(*args, **kwargs)
Plot bot result
Source code in lettrade/bot.py
189 190 191 192 193 194 195 196 197 |
|
run
¤
run()
Run bot
Source code in lettrade/bot.py
176 177 178 179 180 181 182 183 184 185 186 187 |
|
run_bot
classmethod
¤
run_bot(
bot: LetTradeBot | None = None,
datas: list[DataFeed] | None = None,
id: int | None = None,
name: str | None = None,
result: Literal["str", "stats", "bot", None] = "str",
**kwargs
) -> LetTradeBot | BotStatistic | str | None
Run bot object
Parameters:
-
bot
(LetTradeBot | None
, default:None
) –description. Defaults to None.
-
datas
(list[DataFeed] | None
, default:None
) –description. Defaults to None.
-
id
(int | None
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
result
(Literal['str', 'stats', 'bot', None]
, default:'str'
) –description. Defaults to "str".
Returns:
-
LetTradeBot | BotStatistic | str | None
–LetTradeBot | BotStatistic | str | None: Return value will be pickle across multiprocessing. The cost higher from
str
,stats
object,bot
object
Source code in lettrade/bot.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
start
¤
start(**kwargs)
Start bot
Source code in lettrade/bot.py
166 167 168 169 170 171 172 173 174 |
|
start_bot
classmethod
¤
start_bot(
bot: LetTradeBot | None = None, **kwargs
) -> LetTradeBot
Init and start bot object
Parameters:
-
bot
(LetTradeBot | None
, default:None
) –description. Defaults to None.
Returns:
-
LetTradeBot
(LetTradeBot
) –description
Source code in lettrade/bot.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
stop
¤
stop()
Stop bot
Source code in lettrade/bot.py
199 200 201 202 203 |
|
LetTradeMetaTrader
¤
LetTradeMetaTrader(
feeder: type[
MetaTraderDataFeeder
] = MetaTraderDataFeeder,
exchange: type[MetaTraderExchange] = MetaTraderExchange,
account: type[MetaTraderAccount] = MetaTraderAccount,
**kwargs
)
Bases: LetTradeLive
Help to maintain MetaTrader bots
Parameters:
-
feeder
(Type[MetaTraderDataFeeder]
, default:MetaTraderDataFeeder
) –description. Defaults to MetaTraderDataFeeder.
-
exchange
(Type[MetaTraderExchange]
, default:MetaTraderExchange
) –description. Defaults to MetaTraderExchange.
-
account
(Type[MetaTraderAccount]
, default:MetaTraderAccount
) –description. Defaults to MetaTraderAccount.
Source code in lettrade/exchange/metatrader/metatrader.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
plot
¤
plot(*args, jump: dict | None = None, **kwargs)
Plot strategy/optimize result
BotPlotter
Miror of BotPlotter.plot(). Plotly implement PlotlyBotPlotter.plot().
Args:
jump
(dict | None, optional): Miror of BotPlotter.jump()
Example: Jump to position_id
lt.plot(
jump=dict(position_id=1, range=300),
layout=dict(height=2000),
)
OptimizePlotter
Miror of OptimizePlotter.plot(). Plotly implement PlotlyOptimizePlotter.plot().
Example:
lt.plot(layout=dict(height=2000))
Source code in lettrade/lettrade.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
run
¤
run(worker: int | None = None, **kwargs)
Run LetTrade in single or multiple processing
Parameters:
-
worker
(int | None
, default:None
) –Number of processing. Defaults to None.
Source code in lettrade/lettrade.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
start
¤
start(force: bool = False)
Start LetTrade by init bot object and loading datafeeds
Parameters:
-
force
(bool
, default:False
) –description. Defaults to False.
Source code in lettrade/lettrade.py
108 109 110 111 112 113 114 115 116 117 |
|
stop
¤
stop()
Stop LetTrade
Source code in lettrade/lettrade.py
185 186 187 188 189 190 |
|
LetTradeMetaTraderBot
¤
LetTradeMetaTraderBot(
api: LiveAPI | None = LiveAPI, **kwargs
)
Bases: LetTradeLiveBot
LetTradeBot for MetaTrader
Parameters:
Source code in lettrade/exchange/live/live.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
new_bot
classmethod
¤
new_bot(
datas: list[DataFeed],
strategy_cls: type[Strategy],
feeder_cls: type[DataFeeder],
exchange_cls: type[Exchange],
account_cls: type[Account],
commander_cls: type[Commander],
plotter_cls: type[Plotter],
stats_cls: type[BotStatistic],
name: str | None = None,
**kwargs
) -> LetTradeBot
Create new bot object
Parameters:
-
datas
(list[DataFeed]
) –description
-
strategy_cls
(type[Strategy]
) –description
-
feeder_cls
(type[DataFeeder]
) –description
-
exchange_cls
(type[Exchange]
) –description
-
account_cls
(type[Account]
) –description
-
commander_cls
(type[Commander]
) –description
-
plotter_cls
(type[Plotter]
) –description
-
stats_cls
(type[BotStatistic]
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
Returns:
-
LetTradeBot
(LetTradeBot
) –description
Source code in lettrade/bot.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
plot
¤
plot(*args, **kwargs)
Plot bot result
Source code in lettrade/bot.py
189 190 191 192 193 194 195 196 197 |
|
run
¤
run()
Run bot
Source code in lettrade/bot.py
176 177 178 179 180 181 182 183 184 185 186 187 |
|
run_bot
classmethod
¤
run_bot(
bot: LetTradeBot | None = None,
datas: list[DataFeed] | None = None,
id: int | None = None,
name: str | None = None,
result: Literal["str", "stats", "bot", None] = "str",
**kwargs
) -> LetTradeBot | BotStatistic | str | None
Run bot object
Parameters:
-
bot
(LetTradeBot | None
, default:None
) –description. Defaults to None.
-
datas
(list[DataFeed] | None
, default:None
) –description. Defaults to None.
-
id
(int | None
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
result
(Literal['str', 'stats', 'bot', None]
, default:'str'
) –description. Defaults to "str".
Returns:
-
LetTradeBot | BotStatistic | str | None
–LetTradeBot | BotStatistic | str | None: Return value will be pickle across multiprocessing. The cost higher from
str
,stats
object,bot
object
Source code in lettrade/bot.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
start
¤
start(**kwargs)
Start bot
Source code in lettrade/bot.py
166 167 168 169 170 171 172 173 174 |
|
start_bot
classmethod
¤
start_bot(
bot: LetTradeBot | None = None, **kwargs
) -> LetTradeBot
Init and start bot object
Parameters:
-
bot
(LetTradeBot | None
, default:None
) –description. Defaults to None.
Returns:
-
LetTradeBot
(LetTradeBot
) –description
Source code in lettrade/bot.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
stop
¤
stop()
Stop bot
Source code in lettrade/bot.py
199 200 201 202 203 |
|
LiveAPI
¤
LiveAPI(**kwargs)
Bases: ABC
Source code in lettrade/exchange/live/api.py
18 19 |
|
account
abstractmethod
¤
account() -> dict
Source code in lettrade/exchange/live/api.py
65 66 67 |
|
bars
abstractmethod
¤
bars(
symbol,
timeframe,
since: int | datetime | None = 0,
to: int | datetime | None = 1000,
) -> list[list]
Source code in lettrade/exchange/live/api.py
48 49 50 51 52 53 54 55 56 |
|
execution_get
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
128 129 130 |
|
executions_get
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
119 120 121 122 123 124 125 126 |
|
executions_total
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
110 111 112 113 114 115 116 117 |
|
heartbeat
¤
heartbeat() -> bool
Source code in lettrade/exchange/live/api.py
34 35 36 |
|
init
¤
init(**kwargs)
Source code in lettrade/exchange/live/api.py
21 22 |
|
market
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
39 40 41 |
|
markets
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
43 44 45 |
|
multiprocess
classmethod
¤
multiprocess(kwargs: dict, **other_kwargs)
Source code in lettrade/exchange/live/api.py
14 15 16 |
|
order_close
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
96 97 98 |
|
order_open
abstractmethod
¤
order_open(**kwargs) -> dict
Source code in lettrade/exchange/live/api.py
88 89 90 |
|
order_update
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
92 93 94 |
|
orders_get
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
79 80 81 82 83 84 85 86 |
|
orders_history_get
¤
orders_history_get(
id: str | None = None,
since: datetime | None = None,
to: datetime | None = None,
**kwargs
) -> list[dict]
Source code in lettrade/exchange/live/api.py
100 101 102 103 104 105 106 107 |
|
orders_total
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
70 71 72 73 74 75 76 77 |
|
position_close
abstractmethod
¤
position_close(position: LivePosition, **kwargs) -> dict
Source code in lettrade/exchange/live/api.py
156 157 158 |
|
position_update
abstractmethod
¤
position_update(
position: LivePosition,
sl: float | None = None,
tp: float | None = None,
**kwargs
) -> dict
Source code in lettrade/exchange/live/api.py
146 147 148 149 150 151 152 153 154 |
|
positions_get
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
142 143 144 |
|
positions_total
abstractmethod
¤
Source code in lettrade/exchange/live/api.py
133 134 135 136 137 138 139 140 |
|
start
¤
start(exchange: LiveExchange)
Source code in lettrade/exchange/live/api.py
24 25 |
|
LiveAccount
¤
LiveAccount(api: LiveAPI, **kwargs)
Bases: Account
Parameters:
-
api
(LiveAPI
) –description
-
**kwargs
(dict
, default:{}
) –Mirror of lettrade.account.Account().
Source code in lettrade/exchange/live/account.py
18 19 20 21 22 23 24 25 26 27 28 29 |
|
account_refresh
¤
account_refresh()
Refresh account balance
Source code in lettrade/exchange/live/account.py
53 54 55 56 57 58 59 60 61 |
|
next
¤
next()
Next account
Source code in lettrade/account/account.py
73 74 |
|
next_next
¤
next_next()
Call after strategy.next()
Source code in lettrade/account/account.py
76 77 78 |
|
risk
¤
Risk calculation
Source code in lettrade/account/account.py
87 88 89 90 91 |
|
start
¤
start()
Start live account by load account info from API
Source code in lettrade/exchange/live/account.py
34 35 36 37 38 |
|
stop
¤
stop()
Stop account
Source code in lettrade/account/account.py
80 81 82 83 84 85 |
|
LiveDataFeed
¤
LiveDataFeed(
symbol: str,
timeframe: str | int | Timedelta,
name: str | None = None,
columns: list[str] | None = None,
api: LiveAPI | None = None,
api_kwargs: dict | None = None,
**kwargs
)
Bases: DataFeed
Live trading DataFeed
Parameters:
-
symbol
(str
) –Symbol of DataFeed
-
timeframe
(str | int | Timedelta
) –TimeFrame of DataFeed
-
name
(str | None
, default:None
) –Name of DataFeed, auto generate
{symbol}_{timeframe}
if none. Defaults to None. -
columns
(list[str] | None
, default:None
) –List of DataFeed columns. Defaults to None.
-
api
(LiveAPI | None
, default:None
) –Live trading API. Defaults to None.
Source code in lettrade/exchange/live/data.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
i
property
¤
i: indicator
Alias to lettrade.indicator
and using in DataFeed by call: DataFeed.i.indicator_name()
l
instance-attribute
¤
LetTrade DataFeed wrapper using to manage index pointer of DataFeed
bar
¤
bar(i: int = 0) -> Timestamp
Get current pd.Timestamp value of DataFeed
Parameters:
-
i
(int
, default:0
) –Index. Defaults to 0.
Returns:
-
Timestamp
–pd.Timestamp: description
Source code in lettrade/data/data.py
108 109 110 111 112 113 114 115 116 117 |
|
bars
¤
Get bars from LiveAPI
Parameters:
Returns:
-
list
(list
) –list of bar
Source code in lettrade/exchange/live/data.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
bars_load
¤
Get bar from API and push to DataFeed
Parameters:
Returns:
-
bool
(bool
) –True if has data, False if no data
Source code in lettrade/exchange/live/data.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
drop
¤
drop(
*args,
since: int | str | Timestamp | None = None,
to: int | str | Timestamp | None = None,
**kwargs
) -> None | DataFeed
summary
Parameters:
-
since
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
-
to
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/data/data.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
dump_csv
¤
dump_csv(
path: str | None = None,
since: int | str | datetime | None = 0,
to: int | str | datetime | None = 1000,
**kwargs
)
summary
Parameters:
-
path
(str | None
, default:None
) –description. Defaults to None.
-
since
(int | str | datetime | None
, default:0
) –description. Defaults to 0.
-
to
(int | str | datetime | None
, default:1000
) –description. Defaults to 1_000.
Source code in lettrade/exchange/live/data.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
next
¤
next(size=1, tick=0) -> bool
Drop extra columns and load next DataFeed
Parameters:
-
size
(int
, default:1
) –description. Defaults to 1.
-
tick
(int
, default:0
) –description. Defaults to 0.
Returns:
-
bool
(bool
) –description
Source code in lettrade/exchange/live/data.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
push
¤
Push new rows to DataFeed
Parameters:
-
rows
(list[list[int | float]]
) –list of rows
[["timestamp", "open price", "high price"...]]
-
unit
(str | None
, default:None
) –pandas.Timestamp parsing unit. Defaults to None.
-
utc
(bool
, default:True
) –description. Defaults to True.
Source code in lettrade/data/data.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
symbol_info
¤
symbol_info()
Get symbol information from API
Source code in lettrade/exchange/live/data.py
74 75 76 |
|
LiveDataFeeder
¤
LiveDataFeeder(
api: LiveAPI | None = None,
tick: bool = 5,
start_size: int = 500,
api_kwargs: dict | None = None,
**kwargs
)
Bases: DataFeeder
tick == 0: wait until new bar change value
tick > 0: sleep tick time (in seconds) then update
Source code in lettrade/exchange/live/feeder.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
LiveExchange
¤
LiveExchange(api: LiveAPI, *args, **kwargs)
Bases: Exchange
MetaTrade 5 exchange module for lettrade
Parameters:
-
api
(LiveAPI
) –API connect to rpyc MeTrader 5 Terminal server through module
mt5linux
-
*args
(list
, default:()
) –Exchange
list parameters -
**kwargs
(dict
, default:{}
) –Exchange
dict parameters
Source code in lettrade/exchange/live/exchange.py
21 22 23 24 25 26 27 28 29 30 |
|
executions
instance-attribute
¤
Execution dict by Execution.id
key
history_orders
instance-attribute
¤
History Order dict by Order.id
key
history_positions
instance-attribute
¤
History Position dict by Position.id
key
positions
instance-attribute
¤
Available Position dict by Position.id
key
init
¤
init(
brain: Brain,
feeder: DataFeeder,
account: Account,
commander: Commander,
) -> None
Init Exchange dependencies.
Set data/datas from feeder.
Set state to ExchangeState.Start
.
Parameters:
-
brain
(Brain
) –description
-
feeder
(DataFeeder
) –description
-
account
(Account
) –description
-
commander
(Commander
) –description
Source code in lettrade/exchange/exchange.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
new_order
¤
new_order(
size: float,
type: OrderType | None = OrderType.Market,
limit: float | None = None,
stop: float | None = None,
sl: float | None = None,
tp: float | None = None,
tag: str | None = None,
data: DataFeed | None = None,
**kwargs
) -> OrderResult
Place new order to server
Parameters:
-
size
(float
) –description
-
type
(OrderType | None
, default:Market
) –description. Defaults to OrderType.Market.
-
limit
(float | None
, default:None
) –description. Defaults to None.
-
stop
(float | None
, default:None
) –description. Defaults to None.
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
tag
(str | None
, default:None
) –description. Defaults to None.
-
data
(DataFeed | None
, default:None
) –description. Defaults to None.
Returns:
-
OrderResult
(OrderResult
) –description
Source code in lettrade/exchange/live/exchange.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
next_next
¤
next_next()
Call after strategy.next()
Source code in lettrade/exchange/exchange.py
109 110 111 |
|
on_execution
¤
Receive Execution event from exchange then store and notify Brain
Parameters:
-
execution
(Execution
) –description
-
broadcast
(bool | None
, default:True
) –description. Defaults to True.
Source code in lettrade/exchange/exchange.py
118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
on_executions
¤
Receive Execution event from exchange then store and notify Brain
Source code in lettrade/exchange/exchange.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
on_order
¤
Receive order event from exchange then store and notify Brain
Parameters:
-
order
(Order
) –description
-
broadcast
(bool | None
, default:True
) –description. Defaults to True.
Source code in lettrade/exchange/exchange.py
160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
on_orders
¤
Receive orders event from exchange then store and notify Brain
Parameters:
-
orders
(list[Order]
) –description
-
broadcast
(bool | None
, default:True
) –description. Defaults to True.
Raises:
-
RuntimeError
–description
Source code in lettrade/exchange/exchange.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
on_position
¤
Receive Position event from exchange then store and notify Brain
Parameters:
-
position
(Position
) –new comming
Position
-
broadcast
(bool | None
, default:True
) –Flag notify to Brain. Defaults to True.
Raises:
-
RuntimeError
–validate
Position
instance
Source code in lettrade/exchange/exchange.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
on_positions
¤
Receive Positions event from exchange then store and notify Brain
Parameters:
-
positions
(list[Position]
) –list of new comming
Position
-
broadcast
(bool | None
, default:True
) –Flag notify to Brain. Defaults to True.
Raises:
-
RuntimeError
–validate
Position
instance
Source code in lettrade/exchange/exchange.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
start
¤
start() -> None
Start Live exchange by: Sync positions from server
Source code in lettrade/exchange/live/exchange.py
32 33 34 35 |
|
stop
¤
stop() -> None
Stop Exchange
Source code in lettrade/exchange/exchange.py
113 114 115 116 |
|
MetaTraderAPI
¤
MetaTraderAPI(
login: int,
password: str,
server: str,
timeout: int = 60,
retry: int = 20,
host: str = "localhost",
port: int = 18812,
wine: str | None = None,
path: str | None = None,
magic: int = 88888888,
**kwargs
)
Bases: LiveAPI
API to connect MetaTrader 5 Terminal
Parameters:
-
login
(int
) –description
-
password
(str
) –description
-
server
(str
) –description
-
timeout
(int
, default:60
) –description. Defaults to 60.
-
retry
(int
, default:20
) –description. Defaults to 20.
-
host
(str
, default:'localhost'
) –description. Defaults to "localhost".
-
port
(int
, default:18812
) –description. Defaults to 18812.
-
wine
(str | None
, default:None
) –description. Defaults to None.
-
magic
(int
, default:88888888
) –description. Defaults to 88888888.
Raises:
-
ConnectionRefusedError
–description
-
RuntimeError
–description
Source code in lettrade/exchange/metatrader/api.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
account
¤
account(**kwargs) -> dict
Metatrader 5 account information
Returns:
-
dict
(dict
) –description
Source code in lettrade/exchange/metatrader/api.py
365 366 367 368 369 370 371 372 373 374 375 |
|
bars
¤
bars(
symbol,
timeframe,
since: int | datetime | None = 0,
to: int | datetime | None = 1000,
**kwargs
) -> list[list]
summary
Parameters:
-
symbol
(_type_
) –description
-
timeframe
(_type_
) –description
-
since
(int | datetime | None
, default:0
) –description. Defaults to 0.
-
to
(int | datetime | None
, default:1000
) –description. Defaults to 1_000.
Returns:
Source code in lettrade/exchange/metatrader/api.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
do_position_update
¤
summary
Parameters:
-
id
(int
) –description
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
Returns:
-
dict
(dict
) –description
Source code in lettrade/exchange/metatrader/api.py
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 |
|
execution_get
¤
summary
Parameters:
-
id
(str
) –description
Returns:
-
dict
(dict
) –description
Source code in lettrade/exchange/metatrader/api.py
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
|
executions_get
¤
summary
Parameters:
-
position_id
(str | None
, default:None
) –description. Defaults to None.
-
search
(str | None
, default:None
) –description. Defaults to None.
Returns:
Source code in lettrade/exchange/metatrader/api.py
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 |
|
executions_total
¤
summary
Parameters:
-
since
(datetime | None
, default:None
) –description. Defaults to None.
-
to
(datetime | None
, default:None
) –description. Defaults to None.
Returns:
-
int
(int
) –description
Source code in lettrade/exchange/metatrader/api.py
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
|
heartbeat
¤
heartbeat() -> bool
Heartbeat
Returns:
-
bool
(bool
) –description
Source code in lettrade/exchange/metatrader/api.py
256 257 258 259 260 261 262 |
|
init
¤
init(**kwargs)
Source code in lettrade/exchange/live/api.py
21 22 |
|
market
¤
summary
Parameters:
-
symbol
(str
) –description
Returns:
-
dict
(dict
) –description
Source code in lettrade/exchange/metatrader/api.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
markets
¤
The filter for arranging a group of necessary symbols. If the group is specified, the function returns only symbols meeting a specified criteria.
Search example
Get symbols whose names do not contain USD, EUR, JPY and GBP
search="*,!*USD*,!*EUR*,!*JPY*,!*GBP*"
Parameters:
-
search
(str | None
, default:'*'
) –description. Defaults to None.
Returns:
Source code in lettrade/exchange/metatrader/api.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
next
¤
next()
Next tick action
Source code in lettrade/exchange/metatrader/api.py
252 253 254 |
|
order_open
¤
order_open(order: MetaTraderOrder) -> dict
summary
Parameters:
-
order
(MetaTraderOrder
) –description
Raises:
-
NotImplementedError
–description
Returns:
-
dict
(dict
) –description
Source code in lettrade/exchange/metatrader/api.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
|
orders_get
¤
summary
Parameters:
-
id
(str | None
, default:None
) –description. Defaults to None.
-
symbol
(str | None
, default:None
) –description. Defaults to None.
Returns:
Source code in lettrade/exchange/metatrader/api.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
orders_history_get
¤
orders_history_get(
id: str | None = None,
position_id: str | None = None,
since: datetime | None = None,
to: datetime | None = None,
**kwargs
) -> list[dict]
summary
Parameters:
-
id
(str | None
, default:None
) –description. Defaults to None.
-
position_id
(str | None
, default:None
) –description. Defaults to None.
-
since
(datetime | None
, default:None
) –description. Defaults to None.
-
to
(datetime | None
, default:None
) –description. Defaults to None.
Returns:
Source code in lettrade/exchange/metatrader/api.py
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
|
orders_history_total
¤
summary
Parameters:
-
since
(datetime | None
, default:None
) –description. Defaults to None.
-
to
(datetime | None
, default:None
) –description. Defaults to None.
Returns:
-
int
(int
) –description
Source code in lettrade/exchange/metatrader/api.py
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
|
orders_total
¤
summary
Parameters:
-
since
(datetime | None
, default:None
) –description. Defaults to None.
-
to
(datetime | None
, default:None
) –description. Defaults to None.
Returns:
-
int
(int
) –description
Source code in lettrade/exchange/metatrader/api.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
|
position_close
¤
position_close(
position: MetaTraderPosition, **kwargs
) -> dict
Close a position
Parameters:
-
position
(MetaTraderPosition
) –description
Returns:
-
dict
(dict
) –description
Source code in lettrade/exchange/metatrader/api.py
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 |
|
position_update
¤
position_update(
position: MetaTraderPosition,
sl: float | None = None,
tp: float | None = None,
**kwargs
) -> dict
summary
Parameters:
-
position
(MetaTraderPosition
) –description
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
Returns:
-
dict
(dict
) –description
Source code in lettrade/exchange/metatrader/api.py
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
|
positions_get
¤
summary
Parameters:
-
id
(str
, default:None
) –description. Defaults to None.
-
symbol
(str
, default:None
) –description. Defaults to None.
Returns:
Source code in lettrade/exchange/metatrader/api.py
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
|
positions_total
¤
summary
Parameters:
-
since
(datetime | None
, default:None
) –description. Defaults to None.
-
to
(datetime | None
, default:None
) –description. Defaults to None.
Returns:
-
int
(int
) –description
Source code in lettrade/exchange/metatrader/api.py
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 |
|
start
¤
start(exchange: MetaTraderExchange)
summary
Parameters:
-
exchange
(MetaTraderExchange
) –description
Source code in lettrade/exchange/metatrader/api.py
237 238 239 240 241 242 243 244 245 246 |
|
stop
¤
stop()
Stop MetaTrader 5 Terminal
Source code in lettrade/exchange/metatrader/api.py
248 249 250 |
|
tick_get
¤
summary
Parameters:
-
symbol
(str
) –description
Returns:
-
dict
(dict
) –description
Source code in lettrade/exchange/metatrader/api.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
|
MetaTraderAccount
¤
MetaTraderAccount(api: LiveAPI, **kwargs)
Bases: LiveAccount
Account for MetaTrader
Parameters:
-
api
(LiveAPI
) –description
-
**kwargs
(dict
, default:{}
) –Mirror of lettrade.account.Account().
Source code in lettrade/exchange/live/account.py
18 19 20 21 22 23 24 25 26 27 28 29 |
|
account_refresh
¤
account_refresh()
Refresh account balance
Source code in lettrade/exchange/live/account.py
53 54 55 56 57 58 59 60 61 |
|
next
¤
next()
Next account
Source code in lettrade/account/account.py
73 74 |
|
next_next
¤
next_next()
Call after strategy.next()
Source code in lettrade/account/account.py
76 77 78 |
|
risk
¤
Risk calculation
Source code in lettrade/account/account.py
87 88 89 90 91 |
|
start
¤
start()
Start live account by load account info from API
Source code in lettrade/exchange/live/account.py
34 35 36 37 38 |
|
stop
¤
stop()
Stop account
Source code in lettrade/account/account.py
80 81 82 83 84 85 |
|
MetaTraderDataFeed
¤
MetaTraderDataFeed(
symbol: str,
timeframe: str | int | Timedelta,
name: str | None = None,
columns: list[str] | None = None,
api: LiveAPI | None = None,
api_kwargs: dict | None = None,
**kwargs
)
Bases: LiveDataFeed
DataFeed for MetaTrader
Parameters:
-
symbol
(str
) –Symbol of DataFeed
-
timeframe
(str | int | Timedelta
) –TimeFrame of DataFeed
-
name
(str | None
, default:None
) –Name of DataFeed, auto generate
{symbol}_{timeframe}
if none. Defaults to None. -
columns
(list[str] | None
, default:None
) –List of DataFeed columns. Defaults to None.
-
api
(LiveAPI | None
, default:None
) –Live trading API. Defaults to None.
Source code in lettrade/exchange/live/data.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
i
property
¤
i: indicator
Alias to lettrade.indicator
and using in DataFeed by call: DataFeed.i.indicator_name()
l
instance-attribute
¤
LetTrade DataFeed wrapper using to manage index pointer of DataFeed
bar
¤
bar(i: int = 0) -> Timestamp
Get current pd.Timestamp value of DataFeed
Parameters:
-
i
(int
, default:0
) –Index. Defaults to 0.
Returns:
-
Timestamp
–pd.Timestamp: description
Source code in lettrade/data/data.py
108 109 110 111 112 113 114 115 116 117 |
|
bars
¤
Get bars from LiveAPI
Parameters:
Returns:
-
list
(list
) –list of bar
Source code in lettrade/exchange/live/data.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
bars_load
¤
Get bar from API and push to DataFeed
Parameters:
Returns:
-
bool
(bool
) –True if has data, False if no data
Source code in lettrade/exchange/live/data.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
drop
¤
drop(
*args,
since: int | str | Timestamp | None = None,
to: int | str | Timestamp | None = None,
**kwargs
) -> None | DataFeed
summary
Parameters:
-
since
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
-
to
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/data/data.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
dump_csv
¤
dump_csv(
path: str | None = None,
since: int | str | datetime | None = 0,
to: int | str | datetime | None = 1000,
**kwargs
)
summary
Parameters:
-
path
(str | None
, default:None
) –description. Defaults to None.
-
since
(int | str | datetime | None
, default:0
) –description. Defaults to 0.
-
to
(int | str | datetime | None
, default:1000
) –description. Defaults to 1_000.
Source code in lettrade/exchange/live/data.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
next
¤
next(size=1, tick=0) -> bool
Drop extra columns and load next DataFeed
Parameters:
-
size
(int
, default:1
) –description. Defaults to 1.
-
tick
(int
, default:0
) –description. Defaults to 0.
Returns:
-
bool
(bool
) –description
Source code in lettrade/exchange/live/data.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
push
¤
Push new rows to DataFeed
Parameters:
-
rows
(list[list[int | float]]
) –list of rows
[["timestamp", "open price", "high price"...]]
-
unit
(str | None
, default:None
) –pandas.Timestamp parsing unit. Defaults to None.
-
utc
(bool
, default:True
) –description. Defaults to True.
Source code in lettrade/data/data.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
symbol_info
¤
symbol_info()
Get symbol information from API
Source code in lettrade/exchange/live/data.py
74 75 76 |
|
MetaTraderDataFeeder
¤
MetaTraderDataFeeder(
api: LiveAPI | None = None,
tick: bool = 5,
start_size: int = 500,
api_kwargs: dict | None = None,
**kwargs
)
Bases: LiveDataFeeder
DataFeeder for MetaTrader
tick == 0: wait until new bar change value
tick > 0: sleep tick time (in seconds) then update
Source code in lettrade/exchange/live/feeder.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
MetaTraderExchange
¤
MetaTraderExchange(api: LiveAPI, *args, **kwargs)
Bases: LiveExchange
MetaTrade 5 exchange module for lettrade
Parameters:
-
api
(LiveAPI
) –API connect to rpyc MeTrader 5 Terminal server through module
mt5linux
-
*args
(list
, default:()
) –Exchange
list parameters -
**kwargs
(dict
, default:{}
) –Exchange
dict parameters
Source code in lettrade/exchange/live/exchange.py
21 22 23 24 25 26 27 28 29 30 |
|
executions
instance-attribute
¤
Execution dict by Execution.id
key
history_orders
instance-attribute
¤
History Order dict by Order.id
key
history_positions
instance-attribute
¤
History Position dict by Position.id
key
positions
instance-attribute
¤
Available Position dict by Position.id
key
init
¤
init(
brain: Brain,
feeder: DataFeeder,
account: Account,
commander: Commander,
) -> None
Init Exchange dependencies.
Set data/datas from feeder.
Set state to ExchangeState.Start
.
Parameters:
-
brain
(Brain
) –description
-
feeder
(DataFeeder
) –description
-
account
(Account
) –description
-
commander
(Commander
) –description
Source code in lettrade/exchange/exchange.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
new_order
¤
new_order(
size: float,
type: OrderType | None = OrderType.Market,
limit: float | None = None,
stop: float | None = None,
sl: float | None = None,
tp: float | None = None,
tag: str | None = None,
data: DataFeed | None = None,
**kwargs
) -> OrderResult
Place new order to server
Parameters:
-
size
(float
) –description
-
type
(OrderType | None
, default:Market
) –description. Defaults to OrderType.Market.
-
limit
(float | None
, default:None
) –description. Defaults to None.
-
stop
(float | None
, default:None
) –description. Defaults to None.
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
tag
(str | None
, default:None
) –description. Defaults to None.
-
data
(DataFeed | None
, default:None
) –description. Defaults to None.
Returns:
-
OrderResult
(OrderResult
) –description
Source code in lettrade/exchange/live/exchange.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
next_next
¤
next_next()
Call after strategy.next()
Source code in lettrade/exchange/exchange.py
109 110 111 |
|
on_execution
¤
Receive Execution event from exchange then store and notify Brain
Parameters:
-
execution
(Execution
) –description
-
broadcast
(bool | None
, default:True
) –description. Defaults to True.
Source code in lettrade/exchange/exchange.py
118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
on_executions
¤
Receive Execution event from exchange then store and notify Brain
Source code in lettrade/exchange/exchange.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
on_orders
¤
Receive orders event from exchange then store and notify Brain
Parameters:
-
orders
(list[Order]
) –description
-
broadcast
(bool | None
, default:True
) –description. Defaults to True.
Raises:
-
RuntimeError
–description
Source code in lettrade/exchange/exchange.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
on_position
¤
Receive Position event from exchange then store and notify Brain
Parameters:
-
position
(Position
) –new comming
Position
-
broadcast
(bool | None
, default:True
) –Flag notify to Brain. Defaults to True.
Raises:
-
RuntimeError
–validate
Position
instance
Source code in lettrade/exchange/exchange.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
on_positions
¤
Receive Positions event from exchange then store and notify Brain
Parameters:
-
positions
(list[Position]
) –list of new comming
Position
-
broadcast
(bool | None
, default:True
) –Flag notify to Brain. Defaults to True.
Raises:
-
RuntimeError
–validate
Position
instance
Source code in lettrade/exchange/exchange.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
start
¤
start() -> None
Start Live exchange by: Sync positions from server
Source code in lettrade/exchange/live/exchange.py
32 33 34 35 |
|
stop
¤
stop() -> None
Stop Exchange
Source code in lettrade/exchange/exchange.py
113 114 115 116 |
|
MetaTraderExecution
¤
MetaTraderExecution(
pl: float | None = None,
fee: float | None = None,
tag: str | None = None,
**kwargs
)
Bases: LiveExecution
Execution for MetaTrader
Source code in lettrade/exchange/metatrader/trade.py
36 37 38 39 40 41 42 43 44 45 46 |
|
from_raw
classmethod
¤
from_raw(
raw,
exchange: MetaTraderExchange,
data: MetaTraderDataFeed | None = None,
api: MetaTraderAPI | None = None,
) -> MetaTraderExecution | None
Building new MetaTraderExecution from live api raw object
Parameters:
-
raw
(_type_
) –description
-
exchange
(MetaTraderExchange
) –description
Returns:
-
MetaTraderExecution
(MetaTraderExecution | None
) –description
Source code in lettrade/exchange/metatrader/trade.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
merge
¤
merge(other: Execution)
Merge to keep object handler but not overwrite for Strategy using when Strategy want to store object and object will be automatic update directly
Source code in lettrade/exchange/execution.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
MetaTraderOrder
¤
MetaTraderOrder(is_real: bool = True, **kwargs)
Bases: LiveOrder
Order for MetaTrader
Source code in lettrade/exchange/metatrader/trade.py
111 112 113 114 115 |
|
is_closed
property
¤
is_closed: bool
Flag to check Order
closed
Returns:
-
bool
(bool
) –True if
state
in [OrderState.Filled, OrderState.Canceled]
is_opening
property
¤
is_opening: bool
Flag to check Order
still alive
Returns:
-
bool
(bool
) –True if
state
in [OrderState.Placed, OrderState.Partial]
is_real
instance-attribute
¤
Flag to check Order
is real, cannot duplicate id, cannot recall from history
cancel
¤
cancel(**kwargs) -> OrderResult
Cancel order
Returns:
-
OrderResult
(OrderResult
) –description
Source code in lettrade/exchange/metatrader/trade.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
fill
¤
fill(
price: float, at: Timestamp, raw: object | None = None
) -> OrderResult
Fill Order
.
Set status
to OrderState.Executed
.
Send event to Exchange
Parameters:
-
price
(float
) –Executed price
-
at
(Timestamp
) –Executed bar
Raises:
-
RuntimeError
–description
Returns:
-
OrderResult
(OrderResult
) –result of
Order
Source code in lettrade/exchange/order.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
from_position
classmethod
¤
from_position(
position: MetaTraderPosition,
sl: float | None = None,
tp: float | None = None,
) -> MetaTraderOrder
summary
Parameters:
-
position
(MetaTraderPosition
) –description
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Returns:
-
MetaTraderOrder
(MetaTraderOrder
) –description
Source code in lettrade/exchange/metatrader/trade.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
|
from_raw
classmethod
¤
from_raw(
raw: Any,
exchange: MetaTraderExchange,
data: MetaTraderDataFeed | None = None,
api: MetaTraderAPI | None = None,
) -> MetaTraderOrder | None
summary
Parameters:
-
raw
(Any
) –description
-
exchange
(MetaTraderExchange
) –description
-
data
(MetaTraderDataFeed | None
, default:None
) –description. Defaults to None.
-
api
(MetaTraderAPI | None
, default:None
) –description. Defaults to None.
Raises:
-
NotImplementedError
–description
Returns:
-
MetaTraderOrder | None
–MetaTraderOrder | None: description
Source code in lettrade/exchange/metatrader/trade.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
merge
¤
merge(other: Order)
Update current Order
variables by other Order
Parameters:
-
other
(Order
) –Merge source
Order
Raises:
-
RuntimeError
–Validate same id
Source code in lettrade/exchange/order.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
place
¤
place() -> OrderResult
summary
Raises:
-
RuntimeError
–description
Returns:
-
OrderResult
(OrderResult
) –description
Source code in lettrade/exchange/metatrader/trade.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
update
¤
update(
limit_price: float | None = None,
stop_price: float | None = None,
sl: float | None = None,
tp: float | None = None,
caller: float | None = None,
**kwargs
) -> OrderResult
summary
Parameters:
-
limit_price
(float | None
, default:None
) –description. Defaults to None.
-
stop_price
(float | None
, default:None
) –description. Defaults to None.
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
caller
(float | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Returns:
-
OrderResult
(OrderResult
) –description
Source code in lettrade/exchange/metatrader/trade.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
MetaTraderPosition
¤
MetaTraderPosition(
id: str,
exchange: LiveExchange,
data: LiveDataFeed,
size: float,
parent: Order,
tag: str | None = None,
state: PositionState = PositionState.Open,
entry_price: float | None = None,
entry_fee: float = 0.0,
entry_at: int | None = None,
sl_order: Order | None = None,
tp_order: Order | None = None,
api: LiveAPI | None = None,
raw: object | None = None,
**kwargs
)
Bases: LivePosition
Position for MetaTrader
Source code in lettrade/exchange/live/trade.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
|
exit
¤
exit() -> PositionResult
summary
Returns:
-
PositionResult
(PositionResult
) –description
Source code in lettrade/exchange/metatrader/trade.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
|
from_raw
classmethod
¤
from_raw(
raw,
exchange: MetaTraderExchange,
state: PositionState = PositionState.Open,
data: MetaTraderDataFeed | None = None,
api: MetaTraderAPI = None,
) -> MetaTraderPosition
summary
Parameters:
-
raw
(_type_
) –description
-
exchange
(MetaTraderExchange
) –description
-
data
(MetaTraderDataFeed
, default:None
) –description. Defaults to None.
-
api
(MetaTraderAPI
, default:None
) –description. Defaults to None.
Raises:
-
NotImplementedError
–description
Returns:
-
MetaTraderPosition
(MetaTraderPosition
) –description
Source code in lettrade/exchange/metatrader/trade.py
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
|
merge
¤
merge(other: LivePosition) -> bool
Merge LivePosition from another
Parameters:
-
other
(LivePosition
) –description
Returns:
-
bool
(bool
) –description
Source code in lettrade/exchange/live/trade.py
288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
update
¤
update(
sl: float | None = None,
tp: float | None = None,
caller: float | None = None,
**kwargs
) -> PositionResult
summary
Parameters:
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
caller
(float | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
-
RuntimeError
–description
Returns:
-
PositionResult
(PositionResult
) –description
Source code in lettrade/exchange/metatrader/trade.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
|
OptimizePlotter
¤
OptimizePlotter()
Bases: Plotter
Class help to plot lettrade
Source code in lettrade/exchange/backtest/plot.py
11 12 |
|
contour
¤
Source code in lettrade/exchange/backtest/plot.py
26 27 |
|
heatmap
¤
Source code in lettrade/exchange/backtest/plot.py
23 24 |
|
load
abstractmethod
¤
load()
Load plot config from Strategy.plot()
and setup candlestick/equity
Source code in lettrade/plot/plot.py
9 10 11 |
|
on_done
¤
on_done()
Source code in lettrade/exchange/backtest/plot.py
20 21 |
|
on_result
¤
on_result(result)
Source code in lettrade/exchange/backtest/plot.py
17 18 |
|
plot
abstractmethod
¤
plot(**kwargs)
Plot equity
, orders
, and positions
then show
Source code in lettrade/plot/plot.py
13 14 15 |
|
stop
abstractmethod
¤
stop()
stop plotter
Source code in lettrade/plot/plot.py
17 18 19 |
|
PlotColor
¤
Enum plot color
PlotlyBotPlotter
¤
PlotlyBotPlotter(bot: LetTradeBot)
Bases: BotPlotter
Class help to plot lettrade
Source code in lettrade/plot/bot.py
34 35 36 37 38 39 40 41 42 |
|
jump
¤
jump(
since: int | str | Timestamp | None = None,
order_id: str | None = None,
position_id: str | None = None,
range: int = 300,
name: str | None = None,
)
Jump to place on datefeed
Parameters:
-
since
(int | str | Timestamp | None
, default:None
) –Jump to index/datetime. Defaults to None.
-
order_id
(str | None
, default:None
) –Jump to order id. Defaults to None.
-
position_id
(str | None
, default:None
) –Jump to position id. Defaults to None.
-
range
(int
, default:300
) –number of candle plot. Defaults to 300.
-
name
(str | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/plot/bot.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
jump_reset
¤
jump_reset() -> bool
Reset jump datafeeds back to bot datafeeds
Source code in lettrade/plot/bot.py
115 116 117 118 119 |
|
load
¤
load()
Load plot config from Strategy.plot()
and setup candlestick/equity
Source code in lettrade/plot/plotly/plotly.py
607 608 609 610 611 612 613 614 615 616 617 618 619 |
|
plot
¤
plot(jump: dict | None = None, **kwargs)
Plotly show figure
Parameters:
-
jump
(dict | None
, default:None
) –description. Defaults to None.
Source code in lettrade/plot/plotly/plotly.py
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
|
stop
¤
stop()
stop plotter
Source code in lettrade/plot/plotly/plotly.py
16 17 |
|
PlotlyOptimizePlotter
¤
PlotlyOptimizePlotter(total=None, process_bar: bool = True)
Bases: OptimizePlotter
Source code in lettrade/exchange/backtest/plotly/optimize.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
contour
¤
Plot optimize contour
Parameters:
-
x
(str
, default:None
) –description. Defaults to None.
-
y
(str
, default:None
) –description. Defaults to None.
-
z
(str
, default:'equity'
) –description. Defaults to "equity".
-
histfunc
(str
, default:'max'
) –description. Defaults to "max".
Source code in lettrade/exchange/backtest/plotly/optimize.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
heatmap
¤
Plot optimize heatmap
Parameters:
-
x
(str
, default:None
) –description. Defaults to None.
-
y
(str
, default:None
) –description. Defaults to None.
-
z
(str
, default:'equity'
) –description. Defaults to "equity".
-
histfunc
(str
, default:'max'
) –description. Defaults to "max".
Source code in lettrade/exchange/backtest/plotly/optimize.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
plot
¤
plot(**kwargs)
Plot optimize result
Source code in lettrade/exchange/backtest/plotly/optimize.py
69 70 71 72 73 74 75 76 77 78 79 80 |
|
Plotter
¤
Bases: ABC
Base class help to plot strategy
load
abstractmethod
¤
load()
Load plot config from Strategy.plot()
and setup candlestick/equity
Source code in lettrade/plot/plot.py
9 10 11 |
|
plot
abstractmethod
¤
plot(**kwargs)
Plot equity
, orders
, and positions
then show
Source code in lettrade/plot/plot.py
13 14 15 |
|
stop
abstractmethod
¤
stop()
stop plotter
Source code in lettrade/plot/plot.py
17 18 19 |
|
StorageBackTestCommander
¤
Bases: Commander
BackTest Commander to debug commander notify
init
¤
init(
bot: LetTradeBot,
brain: Brain,
exchange: Exchange,
strategy: Strategy,
)
Init commander dependencies
Parameters:
-
bot
(LetTradeBot
) –LetTradeBot object
-
brain
(Brain
) –Brain of bot
-
exchange
(Exchange
) –Manage bot trading
-
strategy
(Strategy
) –Strategy of bot
Source code in lettrade/commander/commander.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
Strategy
¤
Strategy(
feeder: DataFeeder,
exchange: Exchange,
account: Account,
commander: Commander,
is_optimize: bool = False,
**kwargs
)
Base class to implement a strategy
Parameters:
-
feeder
(DataFeeder
) –DataFeeder for strategy
-
exchange
(Exchange
) –Trading exchange
-
account
(Account
) –Account manager
-
commander
(Commander
) –Event/Command manager
-
is_optimize
(bool
, default:False
) –flag validate optimize condiction. Defaults to False.
Raises:
-
RuntimeError
–Validate valid is_optimize flag
Example
Set custom variable to strategy:
lt = let_backtest(strategy_kwargs=dict(custom_key=custom_value)
Source code in lettrade/strategy/strategy.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
datas
property
¤
feeder
property
¤
feeder: DataFeeder
history_orders
property
¤
history_orders: dict[str, Order | BackTestOrder]
Getter of history Order
dict
Returns:
-
dict[str, Order | BackTestOrder]
–dict[str, Order]: description
history_positions
property
¤
history_positions: dict[str, Position | BackTestPosition]
Getter of history Position
dict
Returns:
-
dict[str, Position | BackTestPosition]
–dict[str, Position]: description
orders
property
¤
orders: dict[str, Order | BackTestOrder]
positions
property
¤
positions: dict[str, Position | BackTestPosition]
Getter of Position
dict
Returns:
-
dict[str, Position | BackTestPosition]
–dict[str, Position]: description
indicators
¤
indicators(df: DataFeed) -> None
All indicator and signal should implement here to cacheable.
Because of lettrade
will cache/pre-load all DataFeed
.
To add indicators for a special DataFeed, define a new function name
indicators_<DataFeed name>
.
Usage
df_eurusd = DataFeed(name="eurusd")
df_gbpusd = DataFeed(name="gbpusd")
# This function will load indicators for df_eurusd
def indicators(self, df: DataFeed):
df['ema'] = df.i.ema(window=21)
# This function will load indicators for df_gbpusd
def indicators_gbpusd(self, df: DataFeed):
df['ema'] = df.i.ema(window=25)
Parameters:
-
df
(DataFeed
) –DataFeed need to load indicators value
Source code in lettrade/strategy/strategy.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
init
¤
init() -> None
Init strategy variables
Source code in lettrade/strategy/strategy.py
76 77 |
|
next
¤
Next bar event
Source code in lettrade/strategy/strategy.py
147 148 |
|
on_executions
¤
Listen for Execution
event since next()
begin
Parameters:
Source code in lettrade/strategy/strategy.py
524 525 526 527 528 529 530 531 532 |
|
on_notify
¤
on_notify(*args, **kwargs) -> None
Listen for notify
event since next()
begin
Returns:
-
_type_
(None
) –None
Source code in lettrade/strategy/strategy.py
554 555 556 557 558 559 |
|
on_orders
¤
Listen for Order
event
Parameters:
Source code in lettrade/strategy/strategy.py
534 535 536 537 538 539 540 541 542 |
|
on_positions
¤
Listen for Position
event since next()
begin
Parameters:
Source code in lettrade/strategy/strategy.py
544 545 546 547 548 549 550 551 552 |
|
on_transactions
¤
Listen for transaction events since next()
begin
Parameters:
Source code in lettrade/strategy/strategy.py
514 515 516 517 518 519 520 521 522 |
|
place_buy_order
¤
place_buy_order(
size: float | None = None,
type: OrderType = OrderType.Market,
limit: float | None = None,
stop: float | None = None,
sl: float | None = None,
tp: float | None = None,
expiration: (
int
| datetime
| timedelta
| Timestamp
| Timedelta
| None
) = None,
tag: str | None = None,
**kwargs
) -> OrderResult
Place a new long order.
Parameters:
-
size
(float | None
, default:None
) –description. Defaults to None.
-
type
(OrderType
, default:Market
) –description. Defaults to OrderType.Market.
-
limit
(float | None
, default:None
) –description. Defaults to None.
-
stop
(float | None
, default:None
) –description. Defaults to None.
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
tag
(str | None
, default:None
) –description. Defaults to None.
-
**kwargs
(dict | None
, default:{}
) –Extra-parameters send to
Exchange.new_order
Returns:
-
OrderResult
(OrderResult
) –Order result information
Source code in lettrade/strategy/strategy.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
place_order
¤
place_order(
side: TradeSide,
size: float | None = None,
type: OrderType = OrderType.Market,
limit: float | None = None,
stop: float | None = None,
sl: float | None = None,
tp: float | None = None,
expiration: (
int
| datetime
| timedelta
| Timestamp
| Timedelta
| None
) = None,
tag: str | None = None,
data: DataFeed | None = None,
**kwargs
) -> OrderResult
summary
Parameters:
-
side
(TradeSide
) –description
-
size
(float | None
, default:None
) –description. Defaults to None.
-
type
(OrderType
, default:Market
) –description. Defaults to OrderType.Market.
-
limit
(float | None
, default:None
) –description. Defaults to None.
-
stop
(float | None
, default:None
) –description. Defaults to None.
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
expiration
(int | datetime | timedelta | Timestamp | Timedelta | None
, default:None
) –description. Defaults to None.
-
tag
(str | None
, default:None
) –description. Defaults to None.
-
data
(DataFeed | None
, default:None
) –description. Defaults to None.
Returns:
-
OrderResult
(OrderResult
) –description
Source code in lettrade/strategy/strategy.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
place_sell_order
¤
place_sell_order(
size: float | None = None,
type: OrderType = OrderType.Market,
limit: float | None = None,
stop: float | None = None,
sl: float | None = None,
tp: float | None = None,
expiration: (
int
| datetime
| timedelta
| Timestamp
| Timedelta
| None
) = None,
tag: str | None = None,
**kwargs
) -> OrderResult
Place a new short order.
Parameters:
-
size
(float | None
, default:None
) –description. Defaults to None.
-
type
(OrderType
, default:Market
) –description. Defaults to OrderType.Market.
-
limit
(float | None
, default:None
) –description. Defaults to None.
-
stop
(float | None
, default:None
) –description. Defaults to None.
-
sl
(float | None
, default:None
) –description. Defaults to None.
-
tp
(float | None
, default:None
) –description. Defaults to None.
-
tag
(str | None
, default:None
) –description. Defaults to None.
-
**kwargs
(dict | None
, default:{}
) –Extra-parameters send to
Exchange.new_order
Returns:
-
OrderResult
(OrderResult
) –Order result information
Source code in lettrade/strategy/strategy.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
|
plot
¤
Custom config of plot
Example
{
# Global items is main datafeed item
"items": [],
# DataFeed plot config
"datafeed_name_eurusd": {
"items": [
{
"type": "scatter",
"x": dataframe.index,
"y": dataframe["close"],
"name": "EMA",
"mode": "lines",
"line": { "color": '#00bad6', "width": 1 },
}
]
},
# Layout config
{
"hovermode": "x unified"
}
}
Parameters:
-
df
(DataFeed
) –plot DataFeed
Returns:
-
dict
(dict
) –config
Source code in lettrade/strategy/strategy.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
send_notify
¤
Send message to commander
Parameters:
-
msg
(str
) –message string
Returns:
-
Any
(Any
) –description
Source code in lettrade/strategy/strategy.py
562 563 564 565 566 567 568 569 570 571 572 |
|
start
¤
call after init()
and before first next()
is called
Parameters:
-
df
(DataFeed
) –description
Returns:
-
_type_
(None
) –None
Source code in lettrade/strategy/strategy.py
130 131 132 133 134 135 136 137 138 |
|
stop
¤
Call when strategy run completed
Parameters:
-
df
(DataFeed
) –main data of strategy
Source code in lettrade/strategy/strategy.py
154 155 156 157 158 159 |
|
TelegramAPI
¤
Singleton object communicate across multipprocessing
Source code in lettrade/commander/telegram.py
98 99 100 101 102 |
|
cleanup
¤
cleanup() -> None
Stops all running telegram threads.
Source code in lettrade/commander/telegram.py
147 148 149 150 151 |
|
send_message
¤
Send message to Telegram Bot
Parameters:
-
msg
(str
) –Message
Returns:
-
_type_
(None
) –None
Source code in lettrade/commander/telegram.py
129 130 131 132 133 134 135 136 137 138 139 |
|
start
¤
Start
Source code in lettrade/commander/telegram.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
TelegramCommander
¤
TelegramCommander(
token: str,
chat_id: int,
api: TelegramAPI | None = None,
*args,
**kwargs
)
Bases: Commander
Send notify and receive command from Telegram Bot
Parameters:
Source code in lettrade/commander/telegram.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
|
init
¤
init(
bot: LetTradeBot,
brain: Brain,
exchange: Exchange,
strategy: Strategy,
)
Init commander dependencies
Parameters:
-
bot
(LetTradeBot
) –LetTradeBot object
-
brain
(Brain
) –Brain of bot
-
exchange
(Exchange
) –Manage bot trading
-
strategy
(Strategy
) –Strategy of bot
Source code in lettrade/commander/commander.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
start
¤
start()
Start
Source code in lettrade/commander/telegram.py
556 557 558 559 560 |
|
stop
¤
stop()
Stop
Source code in lettrade/commander/telegram.py
562 563 564 565 566 |
|
YFBackTestDataFeed
¤
YFBackTestDataFeed(
name: str,
ticker: str,
since: str,
to: str | None = None,
period: str | None = None,
interval: str = "1d",
**kwargs
)
Bases: BackTestDataFeed
YahooFinance DataFeed
Parameters:
-
name
(str
) –description
-
ticker
(str
) –description
-
since
(str
) –description
-
to
(str | None
, default:None
) –description. Defaults to None.
-
period
(str | None
, default:None
) –description. Defaults to None.
-
interval
(str
, default:'1d'
) –description. Defaults to "1d".
Source code in lettrade/exchange/backtest/data.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
i
property
¤
i: indicator
Alias to lettrade.indicator
and using in DataFeed by call: DataFeed.i.indicator_name()
l
instance-attribute
¤
LetTrade DataFeed wrapper using to manage index pointer of DataFeed
bar
¤
bar(i: int = 0) -> Timestamp
Get current pd.Timestamp value of DataFeed
Parameters:
-
i
(int
, default:0
) –Index. Defaults to 0.
Returns:
-
Timestamp
–pd.Timestamp: description
Source code in lettrade/data/data.py
108 109 110 111 112 113 114 115 116 117 |
|
copy
¤
summary
Parameters:
-
deep
(bool
, default:False
) –description. Defaults to False.
Returns:
-
DataFeed
(DataFeed
) –description
Source code in lettrade/data/data.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
drop
¤
drop(
*args,
since: int | str | Timestamp | None = None,
to: int | str | Timestamp | None = None,
**kwargs
) -> None | DataFeed
summary
Parameters:
-
since
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
-
to
(int | str | Timestamp | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Source code in lettrade/data/data.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
push
¤
Push new rows to DataFeed
Parameters:
-
rows
(list[list[int | float]]
) –list of rows
[["timestamp", "open price", "high price"...]]
-
unit
(str | None
, default:None
) –pandas.Timestamp parsing unit. Defaults to None.
-
utc
(bool
, default:True
) –description. Defaults to True.
Source code in lettrade/data/data.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
above
¤
above(
series1: Series | str,
series2: Series | str,
dataframe: DataFrame = None,
name: str | None = None,
prefix: str = "",
inplace: bool = False,
plot: bool | list[str] = False,
plot_kwargs: dict | None = None,
) -> Series
Check a Series is above another Series
Parameters:
-
series1
(Series
) –first Series
-
series2
(Series
) –second Series
Returns:
-
Series
–pd.Series: True series1 is above series2 else False
Source code in lettrade/indicator/series.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
authorized_only
¤
Decorator to check if the message comes from the correct chat_id
Parameters:
Source code in lettrade/commander/telegram.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
below
¤
below(
series1: Series | str,
series2: Series | str,
dataframe: DataFrame = None,
name: str | None = None,
prefix: str = "",
inplace: bool = False,
plot: bool | list[str] = False,
plot_kwargs: dict | None = None,
) -> Series
Check a Series is below another Series
Parameters:
-
series1
(Series
) –first Series
-
series2
(Series
) –second Series
Returns:
-
Series
–pd.Series: -100 series1 is below series2 else 0
Source code in lettrade/indicator/series.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
cdl_3blackcrows
¤
cdl_3blackcrows(
dataframe: DataFrame,
name: str | None = None,
prefix: str = "cdl_",
inplace: bool = False,
plot: bool | list[str] = False,
plot_type: Literal[
"candlestick", "mark"
] = "candlestick",
plot_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:'cdl_'
) –description. Defaults to "cdl_".
-
inplace
(bool
, default:False
) –description. Defaults to False.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/candlestick/talib.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
cdl_3inside
¤
cdl_3inside(
dataframe: DataFrame,
name: str | None = None,
prefix: str = "cdl_",
inplace: bool = False,
plot: bool | list[str] = False,
plot_type: Literal[
"candlestick", "mark"
] = "candlestick",
plot_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:'cdl_'
) –description. Defaults to "cdl_".
-
inplace
(bool
, default:False
) –description. Defaults to False.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/candlestick/talib.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
|
cdl_3whitesoldiers
¤
cdl_3whitesoldiers(
dataframe: DataFrame,
name: str | None = None,
prefix: str = "cdl_",
inplace: bool = False,
plot: bool | list[str] = False,
plot_type: Literal[
"candlestick", "mark"
] = "candlestick",
plot_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:'cdl_'
) –description. Defaults to "cdl_".
-
inplace
(bool
, default:False
) –description. Defaults to False.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/candlestick/talib.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
cdl_direction
¤
cdl_direction(
dataframe: DataFrame,
name: str | None = None,
prefix: str = "cdl_",
inplace: bool = False,
) -> Series | DataFrame
Direction of candle
Parameters:
-
dataframe
(DataFrame
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:'cdl_'
) –description. Defaults to "cdl_".
-
inplace
(bool
, default:False
) –description. Defaults to False.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame:
pd.Series
return [100, 0 , -100] -100
for bull bar --100
for bear bar -0
for None
Source code in lettrade/indicator/candlestick/candlestick.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
cdl_doji
¤
cdl_doji(
dataframe: DataFrame,
name: str | None = None,
prefix: str = "cdl_",
inplace: bool = False,
plot: bool | list[str] = False,
plot_type: Literal[
"candlestick", "mark"
] = "candlestick",
plot_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:'cdl_'
) –description. Defaults to "cdl_".
-
inplace
(bool
, default:False
) –description. Defaults to False.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/candlestick/talib.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
cdl_engulfing
¤
cdl_engulfing(
dataframe: DataFrame,
name: str | None = None,
prefix: str = "cdl_",
inplace: bool = False,
plot: bool | list[str] = False,
plot_type: Literal[
"candlestick", "mark"
] = "candlestick",
plot_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:'cdl_'
) –description. Defaults to "cdl_".
-
inplace
(bool
, default:False
) –description. Defaults to False.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/candlestick/talib.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|
cdl_eveningstar
¤
cdl_eveningstar(
dataframe: DataFrame,
name: str | None = None,
prefix: str = "cdl_",
inplace: bool = False,
plot: bool | list[str] = False,
plot_type: Literal[
"candlestick", "mark"
] = "candlestick",
plot_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:'cdl_'
) –description. Defaults to "cdl_".
-
inplace
(bool
, default:False
) –description. Defaults to False.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/candlestick/talib.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
cdl_morningstar
¤
cdl_morningstar(
dataframe: DataFrame,
name: str | None = None,
prefix: str = "cdl_",
inplace: bool = False,
plot: bool | list[str] = False,
plot_type: Literal[
"candlestick", "mark"
] = "candlestick",
plot_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:'cdl_'
) –description. Defaults to "cdl_".
-
inplace
(bool
, default:False
) –description. Defaults to False.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/candlestick/talib.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
cdl_pattern
¤
cdl_pattern(
dataframe: DataFrame,
pattern: str,
name: str | None = None,
prefix: str = "cdl_",
inplace: bool = False,
plot: bool | list[str] = False,
plot_type: Literal[
"candlestick", "mark"
] = "candlestick",
plot_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
summary
Parameters:
-
dataframe
(DataFrame
) –pandas.DataFrame with ohlcv
-
pattern
(str
) –TA-Lib candle pattern name. Ex:
3whitesoldiers
,3blackcrows
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:'cdl_'
) –description. Defaults to "cdl_".
-
inplace
(bool
, default:False
) –description. Defaults to False.
Raises:
-
RuntimeError
–description
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/candlestick/talib.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
crossover
¤
crossover(
series1: Series | str,
series2: Series | str,
dataframe: DataFrame = None,
name: str | None = None,
prefix: str = "",
inplace: bool = False,
plot: bool | list[str] = False,
plot_kwargs: dict | None = None,
) -> Series
Check if a Series cross over another Series
Parameters:
-
series1
(Series
) –first Series
-
series2
(Series
) –second Series
Returns:
-
Series
–pd.Series: 100 if series1 cross over series2 else 0
Source code in lettrade/indicator/series.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
|
crossunder
¤
crossunder(
series1: Series | str,
series2: Series | str,
dataframe: DataFrame = None,
name: str | None = None,
prefix: str = "",
inplace: bool = False,
plot: bool | list[str] = False,
plot_kwargs: dict | None = None,
) -> Series
Check if a Series cross under another Series
Parameters:
-
series1
(Series
) –first Series
-
series2
(Series
) –second Series
Returns:
-
Series
–pd.Series: -100 if series1 cross under series2 else 0
Source code in lettrade/indicator/series.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
|
diff
¤
diff(
series1: Series | str,
series2: Series | str,
dataframe: DataFrame = None,
name: str | None = None,
prefix: str = "",
inplace: bool = False,
plot: bool | list[str] = False,
plot_kwargs: dict | None = None,
) -> Series
Difference between 2 series
Parameters:
-
series1
(Series
) –description
-
series2
(Series
) –description
-
dataframe
(DataFrame
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:''
) –description. Defaults to "".
-
inplace
(bool
, default:False
) –description. Defaults to False.
-
plot
(bool | list
, default:False
) –description. Defaults to False.
-
plot_kwargs
(dict | None
, default:None
) –description. Defaults to None.
Raises:
-
RuntimeError
–description
Returns:
-
Series
–pd.Series: Difference of 2 series (series1 - series2)
Source code in lettrade/indicator/series.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
direction
¤
direction(
series1: Series | str,
series2: Series | str,
dataframe: DataFrame = None,
name: str | None = None,
prefix: str = "",
inplace: bool = False,
plot: bool | list[str] = False,
plot_kwargs: dict | None = None,
) -> Series
Check a Series is direction another Series
Parameters:
-
series1
(Series
) –first Series
-
series2
(Series
) –second Series
Returns:
-
Series
–pd.Series: -100 if series1 < series2, 100 if series1 > series2, else 0
Source code in lettrade/indicator/series.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
ema
¤
ema(
series: Series | str = "close",
window: int = None,
dataframe: DataFrame = None,
name: str | None = None,
prefix: str = "",
inplace: bool = False,
plot: bool | list[str] = False,
plot_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
Exponential Moving Average
Parameters:
-
series
(Series | str
, default:'close'
) –description. Defaults to "close".
-
window
(int
, default:None
) –description. Defaults to None.
-
dataframe
(DataFrame
, default:None
) –description. Defaults to None.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
prefix
(str
, default:''
) –description. Defaults to "".
-
inplace
(bool
, default:False
) –description. Defaults to False.
-
plot
(bool | list
, default:False
) –description. Defaults to False.
-
plot_kwargs
(dict | None
, default:None
) –description. Defaults to None.
Example
df.i.ema(window=21, name="ema", inplace=True, plot=True)
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/trend/ma.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
indicators_inject_pandas
¤
indicators_inject_pandas(obj: object | None = None)
Inject indicators to Pandas
Source code in lettrade/indicator/__init__.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
let_backtest
¤
let_backtest(
datas: DataFeed | list[DataFeed] | str | list[str],
strategy: type[Strategy],
*,
feeder: type[DataFeeder] = BackTestDataFeeder,
exchange: type[Exchange] = BackTestExchange,
account: type[Account] = BackTestAccount,
commander: (
type[Commander] | Commander | None
) = BackTestCommander,
stats: type[BotStatistic] | None = BotStatistic,
optimize_stats: (
type[OptimizeStatistic] | None
) = OptimizeStatistic,
plotter: type[BotPlotter] | None = "PlotlyBotPlotter",
optimize_plotter: (
type[OptimizePlotter] | None
) = "PlotlyOptimizePlotter",
bot: (
type[LetTradeBackTestBot] | None
) = LetTradeBackTestBot,
name: str | None = None,
balance: float | None = 10000,
commission: float | None = 0.2,
leverage: float | None = 20,
**kwargs
) -> LetTradeBackTest
Complete lettrade
backtest depenencies
Parameters:
-
datas
(DataFeed | list[DataFeed] | str | list[str]
) –description
-
strategy
(type[Strategy]
) –The Strategy implement class
-
feeder
(type[DataFeeder]
, default:BackTestDataFeeder
) –description. Defaults to BackTestDataFeeder.
-
exchange
(type[Exchange]
, default:BackTestExchange
) –description. Defaults to BackTestExchange.
-
account
(type[Account]
, default:BackTestAccount
) –description. Defaults to BackTestAccount.
-
commander
(type[Commander] | Commander | None
, default:BackTestCommander
) –description. Defaults to BackTestCommander.
-
stats
(type[BotStatistic] | None
, default:BotStatistic
) –description. Defaults to BotStatistic.
-
optimize_stats
(type[OptimizeStatistic] | None
, default:OptimizeStatistic
) –description. Defaults to OptimizeStatistic.
-
plotter
(type[BotPlotter] | None
, default:'PlotlyBotPlotter'
) –description. Defaults to "PlotlyBotPlotter".
-
optimize_plotter
(type[OptimizePlotter] | None
, default:'PlotlyOptimizePlotter'
) –description. Defaults to "PlotlyOptimizePlotter".
-
bot
(type[LetTradeBackTestBot] | None
, default:LetTradeBackTestBot
) –description. Defaults to LetTradeBackTestBot.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
balance
(float | None
, default:10000
) –description. Defaults to 10_000.
-
commission
(float | None
, default:0.2
) –description. Defaults to 0.2.
-
leverage
(float | None
, default:20
) –description. Defaults to 20.
Returns:
-
LetTradeBackTest
(LetTradeBackTest
) –The LetTrade backtesting object
Source code in lettrade/exchange/backtest/backtest.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 |
|
let_ccxt
¤
let_ccxt(
datas: set[set[str]],
strategy: type[Strategy],
*,
ccxt_exchange: str,
ccxt_key: str,
ccxt_secret: str,
ccxt_type: Literal["spot", "margin", "future"] = "spot",
ccxt_verbose: bool = False,
feeder: type[CCXTDataFeeder] = CCXTDataFeeder,
exchange: type[CCXTExchange] = CCXTExchange,
account: type[CCXTAccount] = CCXTAccount,
commander: type[Commander] | None = None,
stats: type[BotStatistic] | None = BotStatistic,
plotter: type[Plotter] | None = None,
bot: type[LetTradeCCXTBot] | None = LetTradeCCXTBot,
lettrade: type[LetTradeCCXT] | None = LetTradeCCXT,
api: type[CCXTAPI] | None = CCXTAPI,
**kwargs
) -> LetTradeCCXT
Help to build LetTradeCCXT
Parameters:
-
datas
(set[set[str]]
) –description
-
strategy
(Type[Strategy]
) –description
-
ccxt_exchange
(str
) –description
-
ccxt_key
(str
) –description
-
ccxt_secret
(str
) –description
-
ccxt_type
(Literal['spot', 'margin', 'future']
, default:'spot'
) –description. Defaults to "spot".
-
ccxt_verbose
(bool
, default:False
) –description. Defaults to False.
-
feeder
(Type[CCXTDataFeeder]
, default:CCXTDataFeeder
) –description. Defaults to CCXTDataFeeder.
-
exchange
(Type[CCXTExchange]
, default:CCXTExchange
) –description. Defaults to CCXTExchange.
-
account
(Type[CCXTAccount]
, default:CCXTAccount
) –description. Defaults to CCXTAccount.
-
commander
(Type[Commander] | None
, default:None
) –description. Defaults to None.
-
stats
(Type[BotStatistic] | None
, default:BotStatistic
) –description. Defaults to BotStatistic.
-
plotter
(Type[Plotter] | None
, default:None
) –description. Defaults to None.
-
bot
(Type[LetTradeCCXTBot] | None
, default:LetTradeCCXTBot
) –description. Defaults to LetTradeCCXTBot.
-
lettrade
(Type[LetTradeCCXT] | None
, default:LetTradeCCXT
) –description. Defaults to LetTradeCCXT.
-
api
(Type[CCXTAPI] | None
, default:CCXTAPI
) –description. Defaults to CCXTAPI.
-
**kwargs
(dict
, default:{}
) –All remaining properties are passed to the constructor of
LetTradeLive
Returns:
-
LetTradeCCXT
(LetTradeCCXT
) –description
Source code in lettrade/exchange/ccxt/ccxt.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
let_live
¤
let_live(
datas: set[set[str]],
strategy: type[Strategy],
*,
commander: Commander | None = None,
stats: type[BotStatistic] = BotStatistic,
plotter: type[Plotter] | None = None,
bot: type[LetTradeLiveBot] = LetTradeLiveBot,
lettrade: type[LetTradeLive] = LetTradeLive,
api: type[LiveAPI] = LiveAPI,
**kwargs
) -> LetTradeLive
Help to build LetTradeLive
Parameters:
-
datas
(set[set[str]]
) –description
-
strategy
(type[Strategy]
) –description
-
commander
(Commander | None
, default:None
) –description. Defaults to None.
-
stats
(type[BotStatistic]
, default:BotStatistic
) –description. Defaults to BotStatistic.
-
plotter
(type[Plotter] | None
, default:None
) –description. Defaults to None.
-
bot
(type[LetTradeLiveBot]
, default:LetTradeLiveBot
) –description. Defaults to LetTradeLiveBot.
-
lettrade
(type[LetTradeLive]
, default:LetTradeLive
) –description. Defaults to LetTradeLive.
-
api
(type[LiveAPI]
, default:LiveAPI
) –description. Defaults to LiveAPI.
Returns:
-
LetTradeLive
(LetTradeLive
) –description
Source code in lettrade/exchange/live/live.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
let_metatrader
¤
let_metatrader(
datas: set[set[str]],
strategy: type[Strategy],
*,
mt5_login: int,
mt5_password: str,
mt5_server: str,
mt5_wine: str | None = None,
mt5_path: str | None = None,
feeder: type[
MetaTraderDataFeeder
] = MetaTraderDataFeeder,
exchange: type[MetaTraderExchange] = MetaTraderExchange,
account: type[MetaTraderAccount] = MetaTraderAccount,
commander: type[Commander] | None = None,
stats: type[BotStatistic] = BotStatistic,
plotter: type[Plotter] | None = None,
bot: type[
LetTradeMetaTraderBot
] = LetTradeMetaTraderBot,
lettrade: type[LetTradeMetaTrader] = LetTradeMetaTrader,
api: type[MetaTraderAPI] = MetaTraderAPI,
**kwargs
) -> LetTradeMetaTrader
Help to build LetTradeMetaTrader
Parameters:
-
datas
(set[set[str]]
) –description
-
strategy
(type[Strategy]
) –description
-
mt5_login
(int
) –description
-
mt5_password
(str
) –description
-
mt5_server
(str
) –description
-
mt5_wine
(str | None
, default:None
) –WineHQ execute path. Defaults to None.
-
feeder
(type[MetaTraderDataFeeder]
, default:MetaTraderDataFeeder
) –description. Defaults to MetaTraderDataFeeder.
-
exchange
(type[MetaTraderExchange]
, default:MetaTraderExchange
) –description. Defaults to MetaTraderExchange.
-
account
(type[MetaTraderAccount]
, default:MetaTraderAccount
) –description. Defaults to MetaTraderAccount.
-
commander
(type[Commander] | None
, default:None
) –description. Defaults to None.
-
stats
(type[BotStatistic]
, default:BotStatistic
) –description. Defaults to BotStatistic.
-
plotter
(type[Plotter] | None
, default:None
) –description. Defaults to None.
-
bot
(type[LetTradeMetaTraderBot]
, default:LetTradeMetaTraderBot
) –description. Defaults to LetTradeMetaTraderBot.
-
lettrade
(type[LetTradeMetaTrader]
, default:LetTradeMetaTrader
) –description. Defaults to LetTradeMetaTrader.
-
api
(type[MetaTraderAPI]
, default:MetaTraderAPI
) –description. Defaults to MetaTraderAPI.
Returns:
-
LetTradeMetaTrader
(LetTradeMetaTrader
) –description
Source code in lettrade/exchange/metatrader/metatrader.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
plot_bollinger_bands
¤
plot_bollinger_bands(
dataframe: DataFrame,
upper: str | None = "upper",
basis: str | None = "basis",
lower: str | None = "lower",
width: int = 1,
upper_color: str = "#33BDFF",
basis_color: str = "#D105F5",
lower_color: str = "#33BDFF",
filter: Series | None = None,
) -> dict
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
upper
(str
, default:'upper'
) –Column name.
None
mean skip plot. Defaults to "upper". -
basis
(str
, default:'basis'
) –Column name.
None
mean skip plot. Defaults to "basis". -
lower
(str
, default:'lower'
) –Column name.
None
mean skip plot. Defaults to "lower". -
width
(int
, default:1
) –description. Defaults to 1.
-
upper_color
(str
, default:'#33BDFF'
) –Color code. Defaults to "#33BDFF".
-
lower_color
(str
, default:'#33BDFF'
) –Color code. Defaults to "#33BDFF".
-
basis_color
(str
, default:'#D105F5'
) –Color code. Defaults to "#D105F5".
-
filter
(Series | None
, default:None
) –description. Defaults to None.
Returns:
-
dict
(dict
) –description
Source code in lettrade/plot/plotly/indicator.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
plot_candlestick
¤
plot_candlestick(
dataframe: DataFrame,
name: str = "Candlestick",
width: int = 1,
increasing_line_color=PlotColor.LIGHT_GREEN,
decreasing_line_color=PlotColor.LIGHT_RED,
row: int = 1,
col: int = 1,
filter: Series | None = None,
**kwargs
) -> dict
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
name
(str
, default:'Candlestick'
) –description. Defaults to "Candlestick".
-
width
(int
, default:1
) –description. Defaults to 1.
-
increasing_line_color
(str
, default:LIGHT_GREEN
) –description. Defaults to PlotColor.LIGHT_GREEN.
-
decreasing_line_color
(str
, default:LIGHT_RED
) –description. Defaults to PlotColor.LIGHT_RED.
-
row
(int
, default:1
) –description. Defaults to 1.
-
col
(int
, default:1
) –description. Defaults to 1.
-
filter
(Series | None
, default:None
) –description. Defaults to None.
Returns:
-
dict
(dict
) –description
Source code in lettrade/plot/plotly/indicator.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
|
plot_ichimoku
¤
plot_ichimoku(
dataframe: DataFrame,
tenkan_sen="tenkan_sen",
kijun_sen="kijun_sen",
senkou_span_a="senkou_span_a",
senkou_span_b="senkou_span_b",
chikou_span="chikou_span",
width=1,
tenkan_sen_color="#33BDFF",
kijun_sen_color="#D105F5",
senkou_span_a_color="#228B22",
senkou_span_b_color="#FF3342",
chikou_span_color="#F1F316",
filter: Series | None = None,
) -> dict
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
tenkan_sen
(str
, default:'tenkan_sen'
) –description. Defaults to "tenkan_sen".
-
kijun_sen
(str
, default:'kijun_sen'
) –description. Defaults to "kijun_sen".
-
senkou_span_a
(str
, default:'senkou_span_a'
) –description. Defaults to "senkou_span_a".
-
senkou_span_b
(str
, default:'senkou_span_b'
) –description. Defaults to "senkou_span_b".
-
chikou_span
(str
, default:'chikou_span'
) –description. Defaults to "chikou_span".
-
width
(int
, default:1
) –description. Defaults to 1.
-
tenkan_sen_color
(str
, default:'#33BDFF'
) –description. Defaults to "#33BDFF".
-
kijun_sen_color
(str
, default:'#D105F5'
) –description. Defaults to "#D105F5".
-
senkou_span_a_color
(str
, default:'#228B22'
) –description. Defaults to "#228B22".
-
senkou_span_b_color
(str
, default:'#FF3342'
) –description. Defaults to "#FF3342".
-
chikou_span_color
(str
, default:'#F1F316'
) –description. Defaults to "#F1F316".
-
filter
(Series | None
, default:None
) –description. Defaults to None.
Returns:
-
dict
(dict
) –description
Source code in lettrade/plot/plotly/indicator.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
plot_line
¤
plot_line(
series: Series | str,
color: str = PlotColor.PURPLE,
width: int = 1,
name: str | None = None,
mode: str = "lines",
fullfill: bool = False,
dataframe: DataFrame | None = None,
filter: Series | None = None,
**kwargs
) -> dict
summary
Parameters:
-
series
(Series | str
) –description
-
color
(str
, default:PURPLE
) –description. Defaults to PlotColor.PURPLE.
-
width
(int
, default:1
) –description. Defaults to 1.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
mode
(str
, default:'lines'
) –description. Defaults to "lines".
-
fullfill
(bool
, default:False
) –description. Defaults to False.
-
dataframe
(DataFrame | None
, default:None
) –description. Defaults to None.
-
filter
(Series | None
, default:None
) –description. Defaults to None.
Returns:
-
dict
(dict
) –description
Source code in lettrade/plot/plotly/indicator.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
|
plot_lines
¤
plot_lines(
serieses: list[Series | str],
color: str = PlotColor.PURPLE,
width: int = 1,
name: str | None = None,
mode: str = "lines",
fullfill: bool = False,
dataframe: DataFrame | None = None,
plots_kwargs: list[dict] | None = None,
**kwargs
) -> dict
summary
Parameters:
-
serieses
(list[Series | str]
) –description
-
color
(str
, default:PURPLE
) –description. Defaults to PlotColor.PURPLE.
-
width
(int
, default:1
) –description. Defaults to 1.
-
name
(str | None
, default:None
) –description. Defaults to None.
-
mode
(str
, default:'lines'
) –description. Defaults to "lines".
-
fullfill
(bool
, default:False
) –description. Defaults to False.
-
dataframe
(DataFrame | None
, default:None
) –description. Defaults to None.
Returns:
-
dict
(dict
) –description
Source code in lettrade/plot/plotly/indicator.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
plot_mark
¤
plot_mark(
series: Series | str,
color: str = PlotColor.YELLOW,
width: int = 1,
mode: str = "markers",
name: str | None = None,
fullfill: bool = False,
dataframe: DataFrame | None = None,
filter: Series | None = None,
**kwargs
) -> dict
summary
Parameters:
-
series
(Series | str
) –description
-
color
(str
, default:YELLOW
) –description. Defaults to PlotColor.YELLOW.
-
width
(int
, default:1
) –description. Defaults to 1.
-
mode
(str
, default:'markers'
) –description. Defaults to "markers".
-
name
(str | None
, default:None
) –description. Defaults to None.
-
fullfill
(bool
, default:False
) –description. Defaults to False.
-
dataframe
(DataFrame | None
, default:None
) –description. Defaults to None.
-
filter
(Series | None
, default:None
) –description. Defaults to None.
Returns:
-
dict
(dict
) –description
Source code in lettrade/plot/plotly/indicator.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
|
plot_merge
¤
plot_merge(
source: dict,
*updates: list[dict],
recursive: int = 0,
recursive_max: int = 1
) -> dict
Merge multiple update plot config to source config
Parameters:
Returns:
-
dict
(dict
) –Merged config
Source code in lettrade/plot/helper.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
plot_parabolic_sar
¤
plot_parabolic_sar(
dataframe: DataFrame,
long: str | None = "long",
short: str | None = "short",
width: int = 1,
long_color: str = "#33BDFF",
short_color: str = "#D105F5",
filter: Series | None = None,
) -> dict
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
long
(str | None
, default:'long'
) –description. Defaults to "long".
-
short
(str | None
, default:'short'
) –description. Defaults to "short".
-
width
(int
, default:1
) –description. Defaults to 1.
-
long_color
(str
, default:'#33BDFF'
) –description. Defaults to "#33BDFF".
-
short_color
(str
, default:'#D105F5'
) –description. Defaults to "#D105F5".
-
filter
(Series | None
, default:None
) –description. Defaults to None.
Returns:
-
dict
(dict
) –description
Source code in lettrade/plot/plotly/indicator.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
rolling_above
¤
rolling_above(
series1: Series,
series2: Series,
window: int = 20,
min_periods: int | None = None,
dataframe: DataFrame = None,
name: str | None = None,
prefix: str = "",
inplace: bool = False,
plot: bool | list[str] = False,
plot_kwargs: dict | None = None,
) -> Series
Check a Series is rolling above another Series
Parameters:
-
series1
(Series
) –first Series
-
series2
(Series
) –second Series
Returns:
-
Series
–pd.Series: 100 mean series1 is rolling above series2 else 0
Source code in lettrade/indicator/series.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
rolling_below
¤
rolling_below(
series1: Series,
series2: Series,
window: int = 20,
min_periods: int | None = None,
dataframe: DataFrame = None,
name: str | None = None,
prefix: str = "",
inplace: bool = False,
plot: bool | list[str] = False,
plot_kwargs: dict | None = None,
) -> Series
Check a Series is rolling below another Series
Parameters:
-
series1
(Series
) –first Series
-
series2
(Series
) –second Series
Returns:
-
Series
–pd.Series: -100 mean series1 is rolling below series2 else 0
Source code in lettrade/indicator/series.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
|
rolling_direction
¤
rolling_direction(
series1: Series,
series2: Series,
window: int = 20,
min_periods: int | None = None,
dataframe: DataFrame = None,
name: str | None = None,
prefix: str = "",
inplace: bool = False,
plot: bool | list[str] = False,
plot_kwargs: dict | None = None,
) -> Series
Check a Series is rolling on one side with another Series
Parameters:
-
series1
(Series
) –first Series
-
series2
(Series
) –second Series
Returns:
-
Series
–pd.Series: 100 mean series1 keep consistences above series2 at least
window
bars -100 mean series1 keep consistences below series2 at leastwindow
bars 0 else cases
Source code in lettrade/indicator/series.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
|
signal_condiction
¤
signal_condiction(
dataframe: DataFrame,
condictions: list[dict],
name: str,
value: int | float = np.nan,
inplace: bool = False,
plot: bool | list[str] = False,
plot_type: Literal["line", "mark"] = "mark",
**kwargs
) -> Series | DataFrame
Define a signal with multiple condiction
Parameters:
-
dataframe
(DataFrame
) –description
-
condictions
(list[list[Series | Any]]
) –Pairs of condiction [
<pandas.Series condiction>
,<value>
] -
name
(str
) –Name of signal, column name when add to DataFrame with inplace=True.
-
value
(int
, default:nan
) –Default value when condiction is not matched. Defaults to 0.
-
inplace
(bool
, default:False
) –description. Defaults to False.
-
plot
(bool | list
, default:False
) –description. Defaults to False.
-
plot_type
(Literal['line', 'mark']
, default:'mark'
) –description. Defaults to "line".
Usage
df.i.signal_condiction(
[df["close"] > df["open"], 100],
[df["close"] < df["open"], -100],
name="cdl_direction",
inplace=True,
plot=True,
)
Raises:
-
RuntimeError
–description
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/dataframe.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
signal_direction
¤
signal_direction(
dataframe: DataFrame,
up: Series,
down: Series,
name: str = "direction",
value: int = 0,
value_up: int = 100,
value_down: int = -100,
inplace: bool = False,
plot: bool | list[str] = False,
plot_type: Literal["line", "mark"] = "mark",
plot_up_kwargs: dict | None = None,
plot_down_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
Define a signal with 2 direction Up and Down with fixed value
Parameters:
-
dataframe
(DataFrame
) –description
-
up
(Series
) –description
-
down
(Series
) –description
-
name
(str
, default:'direction'
) –Name of signal, column name when add to DataFrame with inplace=True.
-
value
(int
, default:0
) –Default value when condiction is not matched. Defaults to 0.
-
value_up
(int
, default:100
) –description. Defaults to 100.
-
value_down
(int
, default:-100
) –description. Defaults to -100.
-
inplace
(bool
, default:False
) –Whether to add to the DataFrame and return DataFrame rather than return result. Defaults to False.
-
plot
(bool | list[str]
, default:False
) –description. Defaults to False.
-
plot_type
(Literal['line', 'mark']
, default:'mark'
) –description. Defaults to "mark".
-
plot_up_kwargs
(dict | None
, default:None
) –description. Defaults to None.
-
plot_down_kwargs
(dict | None
, default:None
) –description. Defaults to None.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/dataframe.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
signal_exist
¤
signal_exist(
dataframe: DataFrame,
series: Series,
window: int,
value_exist_up: int = 100,
value_exist_down: int = -100,
name: str = "exist",
value_up: int = 100,
value_down: int = -100,
inplace: bool = False,
plot: bool | list[str] = False,
plot_up_kwargs: dict | None = None,
plot_down_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
series
(Series
) –description
-
window
(int
) –description
-
value_exist_up
(int
, default:100
) –description. Defaults to 100.
-
value_exist_down
(int
, default:-100
) –description. Defaults to -100.
-
name
(str
, default:'exist'
) –description. Defaults to "exist".
-
value_up
(int
, default:100
) –description. Defaults to 100.
-
value_down
(int
, default:-100
) –description. Defaults to -100.
-
inplace
(bool
, default:False
) –description. Defaults to False.
-
plot
(bool | list[str]
, default:False
) –description. Defaults to False.
-
plot_up_kwargs
(dict | None
, default:None
) –description. Defaults to None.
-
plot_down_kwargs
(dict | None
, default:None
) –description. Defaults to None.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/dataframe.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
signal_repeat
¤
signal_repeat(
dataframe: DataFrame,
series: Series,
window: int,
value_repeat_up: int = 100,
value_repeat_down: int = -100,
name: str = "repeat",
value_up: int = 100,
value_down: int = -100,
inplace: bool = False,
plot: bool | list[str] = False,
plot_up_kwargs: dict | None = None,
plot_down_kwargs: dict | None = None,
**kwargs
) -> Series | DataFrame
summary
Parameters:
-
dataframe
(DataFrame
) –description
-
series
(Series
) –description
-
window
(int
) –description
-
value_repeat_up
(int
, default:100
) –description. Defaults to 100.
-
value_repeat_down
(int
, default:-100
) –description. Defaults to -100.
-
name
(str
, default:'repeat'
) –description. Defaults to "repeat".
-
value_up
(int
, default:100
) –description. Defaults to 100.
-
value_down
(int
, default:-100
) –description. Defaults to -100.
-
inplace
(bool
, default:False
) –description. Defaults to False.
-
plot
(bool | list[str]
, default:False
) –description. Defaults to False.
-
plot_up_kwargs
(dict | None
, default:None
) –description. Defaults to None.
-
plot_down_kwargs
(dict | None
, default:None
) –description. Defaults to None.
Returns:
-
Series | DataFrame
–pd.Series | pd.DataFrame: description
Source code in lettrade/indicator/dataframe.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|