ccxt
¤
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|