Commit Graph

440 Commits

Author SHA1 Message Date
c9s
4b49fda463 refactor sync service 2021-03-14 11:18:22 +08:00
ben
40eadfeaca add yaml tag for mapping basic risk control order executor. 2021-03-01 13:44:58 +08:00
Yo-An Lin
592a8d87ae Merge pull request #137 from c9s/feature/scale
feature: add exp scale and log scale formula
2021-02-28 16:13:38 +08:00
c9s
b71ea867c5 ignore sync if sync service is nil 2021-02-28 15:05:49 +08:00
c9s
da79920ca9 rename scale struct name to PriceVolumeScale 2021-02-28 14:51:24 +08:00
c9s
83111c9eb9 test exponential scale with reverse range 2021-02-28 12:12:03 +08:00
c9s
99f236d2e0 integrate quantity scale into support strategy and grid strategy 2021-02-28 11:57:25 +08:00
c9s
bf87fbbf55 add LinearScale 2021-02-28 02:20:47 +08:00
c9s
8572df2cb3 add link to TestQuadraticScale 2021-02-28 02:07:48 +08:00
c9s
83af52c53b add QuadraticScale 2021-02-28 02:06:33 +08:00
c9s
52395fd460 add log scale graph link 2021-02-28 01:55:35 +08:00
c9s
fbb8837c5c add exp scale and log scale formula 2021-02-28 01:53:45 +08:00
c9s
5a7cf05701 integrate reward service into the sync service 2021-02-23 16:39:48 +08:00
c9s
73cb80ee96 improve logging 2021-02-22 17:06:43 +08:00
c9s
eaad414706 adjust max api call rate limiting 2021-02-22 15:01:05 +08:00
c9s
724dad70bb remove trade sync from environ init 2021-02-22 14:14:39 +08:00
c9s
84775652fe remove defer wrapper func 2021-02-22 13:49:26 +08:00
c9s
63ebbc0e73 fix frontend sync status checking 2021-02-21 19:36:03 +08:00
c9s
3629a1f5a2 pre-save syncing var for return 2021-02-21 18:54:48 +08:00
c9s
a8516edb98 add Get method to the persistence service facade 2021-02-21 16:55:45 +08:00
c9s
21b092037e refactor notification configuration 2021-02-21 16:52:47 +08:00
c9s
fa4e813729 resolve cyclic imports 2021-02-21 01:01:39 +08:00
c9s
6845db6dd3 refactor database configure method 2021-02-21 00:58:34 +08:00
c9s
12ed5a1efe move persistence service into the service package 2021-02-21 00:45:56 +08:00
c9s
be00aae81e move trade configuration to the trader struct method 2021-02-20 12:23:31 +08:00
c9s
7684099f01 add /api/environment/syncing api 2021-02-20 11:54:48 +08:00
c9s
4ce6e85624 add sync status to the environment 2021-02-20 11:29:33 +08:00
c9s
dd13b9a8bf remove start time query condition for trade sync since starting from trade id = 1 works 2021-02-19 14:18:50 +08:00
c9s
44fa74a4c9 refactor session sync 2021-02-19 10:42:24 +08:00
c9s
390c9b1a4b move Sync method into the sync service 2021-02-19 10:26:13 +08:00
c9s
eaa8c647b5 refactor session sync 2021-02-18 22:40:46 +08:00
c9s
b2bcd3528c use sqlx for testing connection 2021-02-17 17:35:54 +08:00
c9s
a1cb3859c3 fix db driver setup 2021-02-17 14:57:29 +08:00
c9s
3867fdde91 add stringer interface to Position 2021-02-16 16:40:11 +08:00
c9s
e3d3eacb78 fix trade service injection 2021-02-16 16:30:01 +08:00
c9s
8ae4cab550 inject TradeService field if we found it 2021-02-16 16:14:49 +08:00
c9s
c75eb6b5ba pull out Persistence injection to the common injection 2021-02-16 16:13:52 +08:00
c9s
5c1630f000 refactor strategy executor 2021-02-16 16:12:00 +08:00
c9s
fc4419b49b refactor injection 2021-02-16 15:58:21 +08:00
c9s
1c2646b0af add Test_injectField 2021-02-16 15:49:57 +08:00
c9s
c219dc7be0 add test code for testing migration scripts 2021-02-15 21:04:44 +08:00
c9s
f8378957ee add more checks for bollgrid
related to #93
2021-02-13 16:03:31 +08:00
c9s
ffa001fc29 fix quantity format 2021-02-11 00:21:56 +08:00
c9s
57435419b4 add marketData label 2021-02-10 22:40:36 +08:00
ycchen
6655e16889 minor tweaks 2021-02-08 22:41:44 +01:00
ycchen
61c98432f2 feat: tickers for asset calculation 2021-02-08 22:41:44 +01:00
c9s
99b56003eb clean up legacy db connection handling with the new database service 2021-02-06 11:22:04 +08:00
c9s
276b6c1e48 drop the legacy upgradeDB 2021-02-06 11:22:04 +08:00
c9s
de51eb29e4 refactor db stuff with database service 2021-02-06 11:22:04 +08:00
c9s
d8d1249293 fix env var prefix by using os.Getenv directly 2021-02-04 15:14:54 +08:00
c9s
c35cef5b09 implement config saving api 2021-02-03 17:27:18 +08:00
c9s
f7a4f7d415 add strategies endpoint and strategy review page 2021-02-03 15:00:01 +08:00
c9s
705edc38c0 implement config yaml dummper 2021-02-03 09:58:31 +08:00
c9s
098a966813 add test case for config.Map method 2021-02-03 09:34:53 +08:00
c9s
1a2c3556a8 add ID method to the TestStrategy 2021-02-03 09:09:19 +08:00
c9s
7904c6f4d0 add ID() to Strategy interface 2021-02-03 09:08:05 +08:00
c9s
8aa96c4546 integrate strateg adding api 2021-02-03 02:26:41 +08:00
c9s
578451bb51 add setup flag to run server 2021-02-02 18:17:58 +08:00
c9s
17d5e301dc refine setup steps 2021-02-02 17:26:35 +08:00
c9s
73762d9888 support exchange session test from the setup wizard 2021-02-02 11:44:07 +08:00
c9s
a60aeb4771 pull out .Subscribe from trader.Run 2021-02-01 20:44:15 +08:00
c9s
ddcc8ae4ee move ExchangeOrderExecutor into exchange session 2021-02-01 20:44:15 +08:00
c9s
de8e717a41 refactor session initialization function 2021-02-01 20:44:15 +08:00
c9s
fbbe304dfb add trades query api 2021-01-29 18:48:00 +08:00
c9s
cc8133a90e print order query sql 2021-01-29 18:34:03 +08:00
c9s
32645f228b add order query api 2021-01-29 13:15:44 +08:00
c9s
be750b94df fix layout and margin 2021-01-29 12:55:11 +08:00
c9s
8031c6066e mount static files to routes 2021-01-29 11:19:37 +08:00
c9s
78890834b5 support symbol segment 2021-01-28 18:51:35 +08:00
c9s
9ee49ea3f1 Add TradingVolumeBar 2021-01-26 18:10:08 +08:00
c9s
95129e94d7 add lastPrcieUpdatedAt timestamp for checking last price cache 2021-01-26 17:23:40 +08:00
c9s
df17c4b1b6 add trading volume query api 2021-01-26 17:21:18 +08:00
c9s
9717fddfbd add total asset pie chart 2021-01-25 16:56:02 +08:00
c9s
e47357d1ed add assets api and price loading 2021-01-25 15:32:17 +08:00
c9s
09b3046feb lower case fields are not exported to json 2021-01-25 14:32:46 +08:00
c9s
7310700540 add account and account balances 2021-01-24 20:18:04 +08:00
c9s
eab915abc7 rename loaded-symbols to just symbols 2021-01-24 20:14:43 +08:00
c9s
3a52a4bff8 add and set AddOrderUpdate flag for session order store 2021-01-24 20:13:05 +08:00
c9s
42b66d6898 add OrderStore accessor on ExchangeSession 2021-01-24 19:08:12 +08:00
c9s
447057086c add Orders method on OrderStore 2021-01-24 19:07:32 +08:00
c9s
eccc2c6e0f implement session config api and server 2021-01-24 18:42:36 +08:00
c9s
51e5deee47 add frontend files 2021-01-24 14:14:25 +08:00
c9s
1892d03326 make session trades map thread safe 2021-01-24 14:14:25 +08:00
c9s
1c80d30ce2 add TradeSlice with sync 2021-01-24 14:14:25 +08:00
c9s
84b6982033 add order store to exchange session 2021-01-24 14:14:25 +08:00
c9s
d0fc161ae7 fix define build config checking 2021-01-23 01:06:56 +08:00
c9s
2da5fa2e92 pre-define build config 2021-01-23 01:03:56 +08:00
c9s
5eaa8f0778 add IsWrapperBinary flag and fix persistence error 2021-01-21 12:27:21 +08:00
c9s
45876968d9 let build config and legacy imports co-exists 2021-01-21 12:08:06 +08:00
c9s
5329ef8f25 refactor build config 2021-01-21 12:06:03 +08:00
c9s
ad4f339b27 fix test case name 2021-01-21 00:54:59 +08:00
c9s
38bac10050 consider fee calculation 2021-01-21 00:49:01 +08:00
c9s
bfc8e511d0 simplify average cost calculation 2021-01-20 23:46:22 +08:00
c9s
16aa070120 assign base/quote currency to the position struct 2021-01-20 23:08:57 +08:00
c9s
8a08c406c3 check symbol for the position update 2021-01-20 17:37:23 +08:00
c9s
48dd697ce3 handling short-to-long and long-to-short position 2021-01-20 17:35:58 +08:00
c9s
c2a27b031e init position with loaded symbols 2021-01-20 16:30:44 +08:00
c9s
0051dbc78a add Position accessor 2021-01-20 16:29:15 +08:00
c9s
079fcf08e3 initialize position map 2021-01-20 16:28:27 +08:00
c9s
09d712416f add json struct tags 2021-01-20 16:15:34 +08:00
c9s
617f5119fd test trade profit calculation 2021-01-20 16:14:02 +08:00
c9s
169af63846 add more position tests 2021-01-20 16:10:20 +08:00
c9s
34148948ab add position and its tests 2021-01-20 16:08:14 +08:00
c9s
d3f6841a27 improve sync command for margin trades and orders 2021-01-20 01:46:17 +08:00
c9s
f8a9610222 pass isolated margin symbol 2021-01-19 23:31:04 +08:00
c9s
d4774f5f0e add IsolatedMargin option 2021-01-19 23:31:04 +08:00
c9s
310943d010 add isolated margin symbol option 2021-01-19 23:31:04 +08:00
c9s
e8fec434b5 cast exchange instance to margin exchange interface 2021-01-19 23:31:04 +08:00
c9s
3199c63d62 add margin mode 2021-01-19 23:31:04 +08:00
c9s
4002ec80d6 add public only field to the session config struct 2021-01-19 23:31:04 +08:00
c9s
d04e1e7816 refactory sync command and upgrade db automatically 2021-01-14 15:10:11 +08:00
c9s
2699c32b38 add rockhopper 2021-01-13 23:53:36 +08:00
c9s
653eba73c5 improve session error message 2021-01-09 19:47:21 +08:00
c9s
4a1af6f362 add check for PersistenceServiceFacade 2021-01-09 19:44:45 +08:00
c9s
93d71b5300 bbgo: session log error 2021-01-09 19:40:31 +08:00
c9s
92ab7e125a improve RegisterStrategy method to register strategy between cross and single 2020-12-31 17:14:47 +08:00
c9s
25eab8e95f adjust log 2020-12-29 18:32:51 +08:00
c9s
f485c1ba7f fix grid strategy order placing 2020-12-29 18:18:32 +08:00
c9s
275aa9494a support canceling orders on max 2020-12-29 16:00:03 +08:00
c9s
9223b2ba47 move FormatOrder to ExchangeSession since it depends on Market 2020-12-21 13:47:40 +08:00
c9s
3eae58322a add trade update callbacks and order update callbacks to order executor 2020-12-21 13:40:23 +08:00
c9s
728bf5fc81 bbgo: move some logs to debug level 2020-12-15 14:14:44 +08:00
c9s
0222c33330 fix kline tail method 2020-12-08 10:26:20 +08:00
c9s
9eaf69388c add fixedpoint json marshaling 2020-12-07 23:03:06 +08:00
c9s
4addf65f64 support memory persistence 2020-12-07 12:03:56 +08:00
c9s
2d98336fb6 implement Persistent API for strategy 2020-12-07 11:44:41 +08:00
c9s
341f735bc3 configure ConfigurePersistence if it's defined 2020-12-07 11:44:41 +08:00
c9s
a01f83ab15 add persistence config and tests 2020-12-07 11:44:41 +08:00
c9s
b843388483 only query subscribed kline intervals 2020-12-07 11:44:23 +08:00
c9s
62a541fb27 rename preload to loadBuildConfig 2020-12-07 11:44:23 +08:00
c9s
c5d002a0b0 fix market data kline registration 2020-12-05 13:32:41 +08:00
c9s
900f822559 improve and fix ewma calculation 2020-12-05 13:32:41 +08:00
c9s
ef03c0cf20 separate Run and CrossRun
so that we mount one strategy as cross strategy or single exchange strategy
2020-12-03 09:31:40 +08:00
c9s
4f399ebb9f fix stop price formating 2020-12-03 09:25:47 +08:00
c9s
d38b16fb3e fix cross exchange strategy subscription 2020-12-02 22:44:41 +08:00
c9s
d226ec2e01 change field names to lower case so that we can use shorter name for the accessors 2020-12-02 22:21:13 +08:00
c9s
e57b9f235b add quota 2020-11-23 16:47:36 +08:00
c9s
914d5cdc94 try to keep all orders from order store 2020-11-17 15:53:46 +08:00
c9s
ed6d6342e7 fix account currency translation 2020-11-17 14:24:26 +08:00
c9s
cc3da5b678 pass order id for order store exists 2020-11-17 08:53:22 +08:00
c9s
f4512f031c improve cross exchange strategy mounting behavior and add fixedpoint atomic ops 2020-11-17 08:19:22 +08:00
c9s
ded970f5a4 imporve CrossExchange subscription handling 2020-11-15 13:27:33 +08:00
c9s
94aaaf21b0 improve wrapper binary invocation 2020-11-15 13:23:26 +08:00
c9s
cd283f2c28 remove unused logger field 2020-11-12 17:30:21 +08:00
c9s
8cc1c589a1 fix waitgroup counting 2020-11-12 14:59:47 +08:00
c9s
fc9409673f add graceful shutdown 2020-11-12 14:50:21 +08:00
c9s
35a5b61f60 add local active orderbook callback files 2020-11-11 23:19:16 +08:00
c9s
0264baa922 refactor and improve bollgrid 2020-11-11 23:18:53 +08:00
c9s
04f6da3cb8 add traditional grid strategy 2020-11-10 19:06:20 +08:00
c9s
4ab402a188 clean up legacy code 2020-11-10 16:56:30 +08:00
c9s
23c19c5968 use fixedpoint for balances 2020-11-10 14:19:33 +08:00
c9s
6c2aef31a3 improve backtest logging 2020-11-09 16:47:29 +08:00
c9s
e7cc79f3cf replace errors.Errorf with fmt.Errorf 2020-11-09 16:34:35 +08:00
c9s
1e129e4c86 collect error object instead of logging 2020-11-09 15:29:40 +08:00
c9s
8414f406bf drop the legacy order executor 2020-11-09 15:02:12 +08:00
c9s
4a2a542222 refactor basic risk controller 2020-11-09 14:56:54 +08:00
c9s
f69c87b3a8 fix fee calculation and add account balance checking 2020-11-08 21:52:44 +08:00
c9s
4b0bab31fb Merge branch 'feature/backtest' into main 2020-11-07 20:34:55 +08:00
c9s
641784e1b1 calculate pnl after the backtest 2020-11-07 20:34:34 +08:00
c9s
a4a9067c6a integrate matching engine with backtest exchange 2020-11-07 19:57:36 +08:00
c9s
0d8fa08171 add book Update method 2020-11-07 15:07:06 +08:00
c9s
b13a2deec5 emit klines and setup account balances 2020-11-07 03:18:05 +08:00
c9s
22a214328d implement backtest command, stream and add backtest config 2020-11-07 02:57:50 +08:00
c9s
8823a39fc2 support backtesting kline verification 2020-11-07 00:49:17 +08:00
c9s
555fe57341 implement kline sync function from command 2020-11-06 21:40:48 +08:00
c9s
7fab2e24de improve order persistence and support order data sync 2020-11-05 11:14:14 +08:00
c9s
eb67fc0f8f make mysql-url optional for run command 2020-11-05 11:14:14 +08:00
c9s
8388f443a9 move active order book to the bbgo package 2020-11-05 11:14:14 +08:00
c9s
8e0b5d11a7 add max grid config and fix max price formatting 2020-10-31 20:38:20 +08:00
c9s
14abe3fb7e pull out active order book to the types package 2020-10-31 20:38:20 +08:00
c9s
2397acd45f fix type casting and assertion by passing pointer 2020-10-31 18:35:48 +08:00
c9s
0f8e9f6df7 add doc comment to Notifiability 2020-10-31 18:35:48 +08:00
c9s
eb05620f99 use Notifiability directly from environment 2020-10-31 18:35:48 +08:00
c9s
49ff9c4dd6 drop legacy trade reporter 2020-10-31 18:35:48 +08:00
c9s
c4d7476212 add submit order routing 2020-10-31 18:35:48 +08:00
c9s
ec9b5230aa refactor trade report and move trade reporter to the environment layer 2020-10-31 18:35:48 +08:00
c9s
8867ceb951 initialize Notifiability for exchange session 2020-10-31 18:35:48 +08:00
c9s
dc547aa818 fix BOLL map allocation 2020-10-31 18:29:58 +08:00
c9s
c3961024cf implement grid strategy update orders method 2020-10-31 18:29:58 +08:00
c9s
e60127090b add GetBOLL access to standard indicator sets 2020-10-31 18:29:58 +08:00
c9s
d49b2be543 add bollinger indicator 2020-10-29 17:51:20 +08:00
c9s
4afabd92ed clean up code 2020-10-29 17:05:01 +08:00
c9s
5f45d18ae2 fix struct composition 2020-10-29 13:08:33 +08:00
c9s
19b600bb35 simplify strategy registration api 2020-10-29 07:54:59 +08:00
c9s
c71f013916 let SMA indicator and EWMA indicator use IntervalWindow type 2020-10-29 07:51:23 +08:00
c9s
2f8bffeaca add strict injection check fo pointer only objects 2020-10-29 07:49:06 +08:00
c9s
33257c591e refactor swing strategy with types IntervalWindow 2020-10-29 07:44:22 +08:00
c9s
6d8ec7894e refactor standard indicator set with store 2020-10-29 07:40:02 +08:00
c9s
67446670ac finalize swing strategy and fix trade reporter issue 2020-10-28 17:48:16 +08:00
c9s
b22e0370b3 drop legacy OrderProcessor and remove slack debug 2020-10-28 17:48:16 +08:00
c9s
468864302e fix submit order quantity formatting 2020-10-28 17:48:16 +08:00
c9s
2680ad5072 refactor environment, market data store, injection and add swing strategy 2020-10-28 17:48:16 +08:00
c9s
7d7d2c2fc7 assign standard indicator set to the session 2020-10-28 11:15:50 +08:00
c9s
e2df24f31c support standard indicatorset 2020-10-28 09:43:19 +08:00
c9s
50693ae845 implement ewma and sma 2020-10-28 09:13:57 +08:00
c9s
388346b284 move injectStrategyField to a single file 2020-10-27 20:42:48 +08:00
c9s
e1c2f7cc3d improve notifier signatures and fix slack Notify method 2020-10-27 20:13:10 +08:00
c9s
7905ba09d4 pull out fillStrategyNotifiability 2020-10-27 19:37:11 +08:00
c9s
ccc381143d support pointer type filling 2020-10-27 19:33:11 +08:00
c9s
b3eaf832af Add pricealert strategy for demonstrating notification 2020-10-27 13:54:39 +08:00