Skip to content

Commit

Permalink
Fix for BinUtils().extractFormulaParams() and adding appsscript.json …
Browse files Browse the repository at this point in the history
…to release.
  • Loading branch information
diegomanuel committed May 25, 2021
1 parent 09289c2 commit bea144f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ jobs:
echo "::set-output name=filename::$filename"
echo "::set-output name=filepath::$filepath"
- name: Upload as artifact
- name: Upload BINANCE.gs as artifact
uses: actions/upload-artifact@v1
with:
name: ${{ steps.build_file.outputs.filename }}
path: ${{ steps.build_file.outputs.filepath }}
- name: Upload appsscript.json as artifact
uses: actions/upload-artifact@v1
with:
name: appsscript.json
path: appsscript.json

- name: Upload as release asset
- name: Upload BINANCE.gs as release asset
id: upload_release
uses: actions/upload-release-asset@v1
env:
Expand All @@ -42,4 +47,14 @@ jobs:
upload_url: ${{ github.event.release.upload_url }}
asset_name: ${{ steps.build_file.outputs.filename }}
asset_path: ${{ steps.build_file.outputs.filepath }}
asset_content_type: application/javascript
asset_content_type: application/javascript
- name: Upload appsscript.json as release asset
id: upload_appsscript
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_name: appsscript.json
asset_path: appsscript.json
asset_content_type: application/json
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ First of all, open your desired Google Spreadsheet and configure it properly:

### The quick'n easy way for everybody

Just [download the latest **BINANCE.gs**](https://github.com/diegomanuel/binance-to-google-sheets/releases/latest/download/BINANCE.gs) _all-in-one_ file and **copy & paste** its contents following these steps:
Just [download the latest **BINANCE.gs**](https://github.com/diegomanuel/binance-to-google-sheets/releases/latest/download/BINANCE.gs) _all-in-one_ file + [**appsscript.json**](https://github.com/diegomanuel/binance-to-google-sheets/releases/latest/download/appsscript.json) and **copy & paste** its contents following these steps:

1. With your desired `Google Spreadsheet` opened, go to `Tools -> Script editor`.
* It should open a new page with a `Code.gs` file containing an empty function.
2. Remove any contents from `Code.gs` and paste the contents from the downloaded `BINANCE.gs` file.
3. Save the project at `File -> Save`. Give any name you want.
4. Refresh/reload your Google Spreadsheet (hit `F5` on the browser).
* It should open an editor in a new page with a `Code.gs` file containing an empty function.
* Remove any contents from `Code.gs` and save the project at `File -> Save`. Give any name you want.
2. Go to project properties and make sure to select `Show "appsscript.json" manifest file in editor` checkbox.
3. Go back to code editor, select the `Code.gs` file and paste the contents from the downloaded `BINANCE.gs` file.
4. Do the same for `appsscript.json` and optionally set your desired timezone.
5. Save the project again and refresh/reload your Google Spreadsheet (hit `F5` on the browser).
* Once reloaded, you should see a little message box (toast) at the bottom-right corner.
5. Go to `Binance` item at your spreadsheet's main menu and click on the `Authorize add-on!` item.
6. A Google's dialog should appear asking for permissions, proceed with all the steps and click `Allow`.
6. Go to `Binance` item at your spreadsheet's main menu and click on the `Authorize add-on!` item.
7. A Google's dialog should appear asking for permissions, proceed with all the steps and click `Allow`.
* The popup will close and nothing will change on your spreadsheet yet!
7. Once the add-on is authorized, repeat step `5` (click `Authorize add-on!` again) and voila!
8. Once the add-on is authorized, repeat step `5` (click `Authorize add-on!` again) and voila!

### If you are a developer =]

Expand All @@ -55,6 +57,7 @@ You will need [node](https://nodejs.org) and [clasp](https://github.com/google/c
1. With your `Google Spreadsheet` open, go to `Tools -> Script editor`.
2. At the `Google Script` screen, go to `File -> Project properties`.
3. The needed ID is the one under the `Script ID` label!
4. Make sure to select `Show "appsscript.json" manifest file in editor` checkbox.
4. Just for the first time, run the target `make setup SCRIPT_ID=my-script-id` replacing `my-script-id` with the ID obtained at point `3`.
* It should create the file `.clasp.json` with your `scriptId` inside for future use.
* **NOTE:** You only need to re-run this step if you want to change the configured `scriptId`.
Expand Down
2 changes: 1 addition & 1 deletion appsscript.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
}
}
},
"urlFetchWhitelist": ["https://api.binance.com/"]
"urlFetchWhitelist": ["https://api.binance.com/", "https://fapi.binance.com/"]
}
17 changes: 12 additions & 5 deletions misc/utils.gs
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,31 @@ function BinUtils() {
range_or_cell = extracted[1];
options = extracted[2];
} else {
// 2 params formula
regex_formula = base_regex+"(.*)\\s*\\)";
// 2 params formula with string 2nd param
regex_formula = base_regex+"\"(.*)\"";
extracted = new RegExp(regex_formula, "ig").exec(formula);
if (extracted && extracted[1]) {
range_or_cell = extracted[1];
} else {
// 2 params formula with NOT-string 2nd param
regex_formula = base_regex+"(.*)\\s*\\)";
extracted = new RegExp(regex_formula, "ig").exec(formula);
if (extracted && extracted[1]) {
range_or_cell = extracted[1];
}
}
}
}

if (DEBUG) {
Logger.log("FORMULA: "+JSON.stringify(formula));
Logger.log("FORMULA: "+formula);
if (extracted) {
extracted.map(function(val) {
Logger.log("REGEXP VAL: "+val);
});
}
Logger.log("RANGE OR CELL: "+JSON.stringify(range_or_cell));
Logger.log("OPTIONS: "+JSON.stringify(options));
Logger.log("RANGE OR CELL: "+range_or_cell);
Logger.log("OPTIONS: "+options);
}

return [range_or_cell, parseOptions(options)];
Expand Down
1 change: 1 addition & 0 deletions tasks/do-orders-table.gs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function BinDoOrdersTable() {
if (!range.length) {
throw new Error("A range with crypto symbols must be given!");
}
Logger.log("[BinDoOrdersTable] Processing "+range.length+" sheet's assets: "+range);

_setStatus(sheet, "fetching data..");
const opts = {
Expand Down

0 comments on commit bea144f

Please sign in to comment.