Skip to content

Commit 9e2e36f

Browse files
committed
feat: tina
1 parent 1ddb70a commit 9e2e36f

File tree

34 files changed

+10859
-2318
lines changed

34 files changed

+10859
-2318
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818
npm-debug.log*
1919
yarn-debug.log*
2020
yarn-error.log*
21+
22+
node_modules
23+
.env

blog/2023-07-19-bca.mdx

+30-21
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,44 @@
11
---
22
slug: bca
3-
title: ACE X CA X Lead Capital 量化課程
43
author: BCA Daniel
54
author_title: Quant Lead & BD & MM
6-
author_url: https://www.instagram.com/bca_daniel_/
5+
author_url: "https://www.instagram.com/bca_daniel_/"
76
author_image_url: /img/blog/bca.jpeg
87
hide_table_of_contents: false
9-
tags: [quant, tradingview, python, ema]
8+
title: ACE X CA X Lead Capital 量化課程
9+
tags:
10+
- quant
11+
- tradingview
12+
- python
13+
- ema
1014
---
1115

12-
1316
<details>
1417
<summary>此頁的QR連結</summary>
15-
<img src="/img/blog/aceqr.png" width="60%"/>
18+
19+
<img src="/img/blog/aceqr.png" width="60%" />
1620
</details>
1721

1822
<details>
1923
<summary>課綱</summary>
20-
<img src="/img/blog/ace791.JPG" width="50%"/>
21-
<img src="/img/blog/ace726.JPG" width="50%"/>
24+
25+
{" "}
26+
<img src="/img/blog/ace791.JPG" width="50%" />
27+
28+
<img src="/img/blog/ace726.JPG" width="50%" />
2229
</details>
2330

31+
<Details summary="this is it">asdf</Details>
2432

25-
### `Crypto-Arsenal`
33+
<CodeBlock language="python" title="asd">
34+
print("hello")
35+
</CodeBlock>
2636

37+
### `Crypto-Arsenal`
2738

28-
- [註冊連結](https://crypto-arsenal.io/?ref=BCA_qbb) (可以 Google 註冊)
29-
- 如何用CA串接和自動化任何 `TradingView` 策略: 到 [Strategy](https://crypto-arsenal.io/strategies) > `New Strategy` > `TradingView` ([詳細教學](https://docs.crypto-arsenal.io/docs/tradingview/strategy/sync-by-position))
30-
- 如何用CA回測和實單策略: 到 [Strategy](https://crypto-arsenal.io/strategies) > `New Strategy` > `Technical Indicator` > `EMA`
39+
- [註冊連結](https://crypto-arsenal.io) (可以 Google 註冊)
40+
- 如何用 CA 串接和自動化任何 `TradingView` 策略: 到 [Strategy](https://crypto-arsenal.io/strategies) > `New Strategy` > `TradingView` ([詳細教學](https://docs.crypto-arsenal.io/docs/tradingview/strategy/sync-by-position))
41+
- 如何用 CA 回測和實單策略: 到 [Strategy](https://crypto-arsenal.io/strategies) > `New Strategy` > `Technical Indicator` > `EMA`
3142

3243
### `TradingView`
3344

@@ -65,7 +76,6 @@ plot(ema10, color=#f37f20)
6576
plot(ema20 , color = color.red)
6677
```
6778

68-
6979
#### 7/19 簡易`EMA`策略
7080

7181
```python
@@ -91,6 +101,7 @@ if (shortCondition)
91101
strategy.close_all()
92102
strategy.entry("My Short Entry Id", strategy.short)
93103
```
104+
94105
### `Python`
95106

96107
#### 7/19 Superposition `EMA` Python 策略
@@ -108,7 +119,7 @@ class Strategy(StrategyBase):
108119
def __init__(self):
109120
# strategy property
110121
self.subscribed_books = {}
111-
self.period = 60 * 30
122+
self.period = 60 * 30
112123
self.options = {}
113124
self.last_type = 'sell'
114125

@@ -117,7 +128,7 @@ class Strategy(StrategyBase):
117128
self.sp1_period = 14
118129
self.sp2_period =14
119130
self.slow_period = 14
120-
131+
121132
self.divide_quote = 0
122133
self.proportion = 0.2
123134

@@ -128,7 +139,7 @@ class Strategy(StrategyBase):
128139
def trade(self, candles):
129140
exchange, pair, base, quote = CA.get_exchange_pair()
130141
ca_position = self.get_ca_position()
131-
142+
132143
close_price_history = [candle['close'] for candle in candles[exchange][pair]]
133144
high_price_history = [candle['high'] for candle in candles[exchange][pair]]
134145
low_price_history = [candle['low'] for candle in candles[exchange][pair]]
@@ -155,10 +166,10 @@ class Strategy(StrategyBase):
155166
EMA_superposition_2 = talib.EMA(EMA_superposition_1_filled,self.sp2_period)
156167
EMA_superposition_2_filled = np.nan_to_num(EMA_superposition_2, nan=0)
157168
EMA_slow = talib.EMA(EMA_superposition_2_filled, self.slow_period)
158-
169+
159170
if len(close_price_history) < self.slow_period + 1:
160171
return []
161-
172+
162173
# current ema fast / slow
163174
curr_ema_fast = EMA_fast[-1]
164175
curr_ema_slow = EMA_slow[-1]
@@ -184,7 +195,7 @@ class Strategy(StrategyBase):
184195
# open short position
185196
if curr_ema_fast < curr_ema_slow and prev_ema_fast > prev_ema_slow:
186197
signal = -1
187-
198+
188199
# Sell short
189200
if signal == -1:
190201
self['is_shorting'] = 'true'
@@ -203,7 +214,7 @@ class Strategy(StrategyBase):
203214
else:
204215
CA.place_order(exchange, pair, action='open_long', percent=80)
205216

206-
217+
207218
# return current total position: -n 0, +n where n is number of contracts
208219
def get_ca_position(self):
209220
exchange, pair, base, quote = CA.get_exchange_pair()
@@ -218,5 +229,3 @@ class Strategy(StrategyBase):
218229

219230
return 0
220231
```
221-
222-

docs/developer/api/python/ca-apis/buy.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
sidebar_position: 3
33
sidebar_label: buy (SPOT)
44
hide_title: false
5+
title: Buy (SPOT)
6+
description: Python function to buy SPOT
7+
tags:
8+
- python
59
---
610

7-
import { Highlight } from "../../../../../src/components/Highlight.js";
8-
911
# buy (SPOT)
1012

11-
<Highlight color="#ffba00"> This function can only be used in trade(). </Highlight>
12-
1313
To put one buy order. Each period can put at max 500# orders.
1414

1515
## Input

docs/developer/get-started/python/make-order.mdx

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@ sidebar_label: Make an Order
44
hide_title: false
55
---
66

7-
import { Highlight } from "../../../../src/components/Highlight.js";
8-
97
# Make an Order
108

11-
<Highlight color="#ffba00">
12-
{" "}
13-
This article is only for educational purpose and doesn't provide any financial and investment advice.{" "}
14-
</Highlight>
15-
16-
In the previous article, we learned how to get K bar data. In this article, we will trade based on the K bar data
9+
In the previous article, we learned how to get K bar data. In this article, we will trade based on the K bar data
1710

1811
## Calculate SMA(Simple Moving Average)
1912

Original file line numberDiff line numberDiff line change
@@ -1,37 +1,44 @@
1-
import Image from '@theme/IdealImage';
1+
---
2+
hide_table_of_contents: false
3+
title: Binance
4+
description: Binance
5+
tags:
6+
- quant
7+
- tradingview
8+
- python
9+
- ema
10+
---
211

312
# Binance
413

5-
614
## API Keys | Whitelist IP
715

816
**Copy and Paste to the API Keys**
917

10-
<Image img={require('/img/trader/api-keys/ip_access.png')} />
18+
<Image img={require("/img/trader/api-keys/ip_access.png")} />
1119

1220
```
1321
35.234.241.52 35.203.55.44 34.95.27.45
1422
```
1523

1624
**Enable the following permissions**
1725

26+
<Image img={require("/img/trader/api-keys/secret_key.png")} />
1827

19-
<Image img={require('/img/trader/api-keys/secret_key.png')} />
20-
21-
## Setup for Futures
28+
## Setup for Futures
2229

2330
Wallet Setup
2431

25-
💡 Click the ```Wallet``` and select ```Futures```
32+
💡 Click the `Wallet` and select `Futures`
2633

27-
<Image img={require('/img/trader/binance/wallet.png')} />
34+
<Image img={require("/img/trader/binance/wallet.png")} />
2835

29-
<Image img={require('/img/trader/binance/futures.png')} />
36+
<Image img={require("/img/trader/binance/futures.png")} />
3037

31-
💡 Check if ```USD-M``` has enough balance if not hit ```Transfer```
38+
💡 Check if `USD-M` has enough balance if not hit `Transfer`
3239

33-
<Image img={require('/img/trader/binance/USD-M.png')} />
40+
<Image img={require("/img/trader/binance/USD-M.png")} />
3441

35-
<Image img={require('/img/trader/binance/Transfer.png')} />
42+
<Image img={require("/img/trader/binance/Transfer.png")} />
3643

37-
<Image img={require('/img/trader/binance/USD-M-Futures.png')} />
44+
<Image img={require("/img/trader/binance/USD-M-Futures.png")} />

docs/trader/03-q&a/binance.md

+8-19
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
1-
import Image from '@theme/IdealImage';
2-
31
# Binance | Exchange Setup For Futures Trading
42

53
This guide will help you set up to trade Futures on Crypto Arsenal
4+
65
- [Create and Setup API Key](https://help.crypto-arsenal.io/en/articles/6621513-binance-exchange-setup-for-futures-trading#h_08b0b7c6d0)
76
- [Wallet Setup](https://help.crypto-arsenal.io/en/articles/6621513-binance-exchange-setup-for-futures-trading#h_96c8132dae)
87
- [Exchange Trading Preference Setup](http://exchange%20trading%20preference%20setup/)
98

10-
Create and Setup API Key
9+
Create and Setup API Key
1110

1211
💡 Visit API Management on Binance
1312

1413
<Image img={require('/img/trader/binance/api_management.png')} />
1514

1615
<Image img={require('/img/trader/binance/create_api.png')} />
1716

18-
💡 Copy and paste the whitelist IP ```35.234.241.52 35.203.55.44 34.95.27.45``` and hit Confirm
17+
💡 Copy and paste the whitelist IP `35.234.241.52 35.203.55.44 34.95.27.45` and hit Confirm
1918

2019
<Image img={require('/img/trader/binance/restrict.png')} />
2120

2221
<Image img={require('/img/trader/binance/confirm.png')} />
2322

24-
💡 Enable ```Enable Spot & Margin Trading``` and ```Enable Futures```
23+
💡 Enable `Enable Spot & Margin Trading` and `Enable Futures`
2524

2625
<Image img={require('/img/trader/binance/enable_spot.png')} />
2726

2827
<Image img={require('/img/trader/binance/enable_feature.png')} />
2928

3029
Wallet Setup
3130

32-
💡 Click the ```Wallet``` and select ```Futures```
31+
💡 Click the `Wallet` and select `Futures`
3332

3433
<Image img={require('/img/trader/binance/wallet.png')} />
3534

3635
<Image img={require('/img/trader/binance/futures.png')} />
3736

38-
💡 Check if ```USD-M``` has enough balance if not hit ```Transfer```
37+
💡 Check if `USD-M` has enough balance if not hit `Transfer`
3938

4039
<Image img={require('/img/trader/binance/USD-M.png')} />
4140

@@ -51,18 +50,8 @@ Exchange Trading Preference Setup
5150

5251
<Image img={require('/img/trader/binance/preference.png')} />
5352

54-
💡The position mode is set to ```Hedge position mode```. Note that position mode adjustments cannot be made while you have any open positions or pending orders.
53+
💡The position mode is set to `Hedge position mode`. Note that position mode adjustments cannot be made while you have any open positions or pending orders.
5554

56-
💡The asset mode is set to ```Single-Asset mode```. Note that position mode adjustments cannot be made while you have any open positions or pending orders.
55+
💡The asset mode is set to `Single-Asset mode`. Note that position mode adjustments cannot be made while you have any open positions or pending orders.
5756

5857
<Image img={require('/img/trader/binance/single_assets.png')} />
59-
60-
61-
62-
63-
64-
65-
66-
67-
68-

docs/trader/03-q&a/trading-bot.md

+2-22
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,27 @@ import Image from '@theme/IdealImage';
33
# Common Trading Bot Error
44

55
Report an error
6-
76

87
When reporting an error, please go to the Portfolio and check the robot ID, and provide your email.
98

10-
<Image img={require('/img/trader/trading_error.png')} />
11-
9+
<Image img={require('/img/trader/trading_error.png')} />
1210

1311
Below are common strategy error messages and their causes.
14-
15-
16-
1712

1813
AuthenticationError: Invalid API key, IP, or permissions for the action
1914

2015
This error indicates that there is an error in your exchange API configuration. Please check here to ensure that you have provided the correct permissions. Once you have set it up correctly, the next action should not result in an error.
2116

22-
23-
24-
25-
2617
Error: amount 0 should be greater than 0.001
2718

2819
Possible explanation:
2920

3021
Before following the trades, the quantitative strategy has already opened a position. When the closing signal comes, we do not have any position to close, resulting in the error message 'Quantity cannot be zero.' This error does not require any action; you just need to wait for the next trade to be executed by the quantitative strategy.
3122

32-
33-
3423
ExchangeError: Order's position side does not match user's setting
3524

3625
This error indicates that there is an error in your exchange settings. Please check here for verification.
3726

38-
3927
When the robot is activated, it uses the API to set the correct configurations on the exchange:
4028

4129
1. Position mode should be set to dual (both long and short positions).
@@ -44,17 +32,11 @@ When the robot is activated, it uses the API to set the correct configurations o
4432

4533
Currently, we are aware that if there are existing positions and the leverage is adjusted, the exchange may return an error. If the setting fails, it will result in this error.
4634

47-
48-
4935
InvalidOrder: ReduceOnly Order is rejected
50-
Got error while sending order to exchange. InvalidOrder: binance {"code":-2022,"msg":"ReduceOnly Order is rejected."}
51-
52-
36+
Got error while sending order to exchange. InvalidOrder: binance `{"code":-2022,"msg":"ReduceOnly Order is rejected."}`
5337

5438
https://dev.binance.vision/t/why-do-you-get-reduceonly-rejection-errors/1198
5539

56-
57-
5840
A:
5941
Several reasons you might want to check for reduceOnly order rejection:
6042

@@ -69,5 +51,3 @@ A little bit explanation for #3 -
6951
Let’s say your current position is 1 BTC for short; And you have an open order to close this BTC at 10000; If you place another order to close 1 BTC at 9999, it’d be rejected. (Because the order with 10000 for sure would be filled and close everything before this “9999” order )
7052

7153
If you still think you shouldn’t have been rejected after checking above things, please contact CS
72-
73-

0 commit comments

Comments
 (0)