Skip to content

Commit

Permalink
New Feature: set an optional alert name
Browse files Browse the repository at this point in the history
  • Loading branch information
mlake committed Nov 12, 2020
1 parent 1d87fb1 commit 7df80b6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ alert:
indicator: MTF Deviation
signal: Tier1 long
option: Once Per Bar Close
# alert name is optional - can override in csv if desired and use {{symbol|base|quote}}
# name: MI dev3 for {{base}} {{quote}}
# indentation matters! {{quote}} and {{base}} are swapped out for quote asset(eg. USDT) and the base (eg. BTC)
message: >
{
Expand Down
4 changes: 3 additions & 1 deletion config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ alert:
indicator: MTF Deviation
signal: Tier1 long
option: Once Per Bar Close
# alert name is optional - can override in csv if you add a "name" column. can use {{symbol|base|quote}}
# name: MI dev3 for {{base}} {{quote}}
# indentation matters! {{quote}} and {{base}} are swapped out for quote asset(eg. USDT) and the base (eg. BTC)
message: >
{
Expand All @@ -16,4 +18,4 @@ alert:
"email_token": "fffffff-fffff-fffff-ffff-ffffffffff",
"delay_seconds": 0,
"pair": "{{quote}}_{{base}}"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@alleyway/add-tradingview-alerts-tool",
"repository": "[email protected]:alleyway/add-tradingview-alerts-tool.git",
"version": "1.0.3",
"version": "1.1.0",
"description": "Add TradingView Alerts in bulk",
"scripts": {
"build": "tsc",
Expand Down
17 changes: 14 additions & 3 deletions src/add-tradingview-alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ const fetchFirstXPath = async (selector: string, page, timeout = 20000) => {

// made using XPath Generator 1.1.0

const addAlert = async (symbol: string, quote: string, base: string, alertConfig: any, page) => {
const addAlert = async (symbol: string, quote: string, base: string, rowName: string, alertConfig: any, page) => {


const {indicator, signal, option, message} = alertConfig
const {indicator, signal, option, message } = alertConfig

//await page.waitForXPath('//*[@id="header-toolbar-symbol-search"]/div/input')

Expand Down Expand Up @@ -81,6 +81,17 @@ const addAlert = async (symbol: string, quote: string, base: string, alertConfig

await delay(1000);

const alertName = (rowName || alertConfig.name || "").toString().replace(/{{symbol}}/g, symbol).replace(/{{quote}}/g, quote).replace().replace(/{{base}}/g, base).replace()

if (!!alertName) {
const nameInput = await fetchFirstXPath("//input[@name='alert-name']", page)
nameInput.click()
await nameInput.press('Backspace');
await nameInput.type(alertName)
await delay(1000);

}

//await page.evaluate("textarea[name=description]", el => el.value = "")

const messageTextarea = await fetchFirstXPath("//textarea[@class='tv-control-textarea']", page)
Expand Down Expand Up @@ -181,7 +192,7 @@ const main = async () => {

console.log(`Adding symbol: ${row.symbol} ( ${row.base} priced in ${row.quote} )`)
await delay(5000)
await addAlert(row.symbol, row.quote, row.base, alertConfig, page)
await addAlert(row.symbol, row.quote, row.base, row.name, alertConfig, page)
}
}

Expand Down

0 comments on commit 7df80b6

Please sign in to comment.